changeset 2017:e6a5d095c356 jdk7-b77

Merge
author ohair
date Wed, 25 Nov 2009 11:08:25 -0800
parents ad1c88142958 (current diff) 5f452be1691e (diff)
children 5f24048612f3 c4752fd11cf0 e0905e36766a
files src/share/classes/com/sun/jmx/event/DaemonThreadFactory.java src/share/classes/com/sun/jmx/event/EventBuffer.java src/share/classes/com/sun/jmx/event/EventClientFactory.java src/share/classes/com/sun/jmx/event/EventConnection.java src/share/classes/com/sun/jmx/event/EventParams.java src/share/classes/com/sun/jmx/event/LeaseManager.java src/share/classes/com/sun/jmx/event/LeaseRenewer.java src/share/classes/com/sun/jmx/event/ReceiverBuffer.java src/share/classes/com/sun/jmx/event/RepeatedSingletonJob.java src/share/classes/com/sun/jmx/interceptor/DispatchInterceptor.java src/share/classes/com/sun/jmx/interceptor/DomainDispatchInterceptor.java src/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptorSupport.java src/share/classes/com/sun/jmx/interceptor/NamespaceDispatchInterceptor.java src/share/classes/com/sun/jmx/interceptor/SingleMBeanForwarder.java src/share/classes/com/sun/jmx/mbeanserver/MBeanInjector.java src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java src/share/classes/com/sun/jmx/mbeanserver/NotifySupport.java src/share/classes/com/sun/jmx/mbeanserver/PerThreadGroupPool.java src/share/classes/com/sun/jmx/namespace/DomainInterceptor.java src/share/classes/com/sun/jmx/namespace/HandlerInterceptor.java src/share/classes/com/sun/jmx/namespace/NamespaceInterceptor.java src/share/classes/com/sun/jmx/namespace/ObjectNameRouter.java src/share/classes/com/sun/jmx/namespace/RoutingConnectionProxy.java src/share/classes/com/sun/jmx/namespace/RoutingMBeanServerConnection.java src/share/classes/com/sun/jmx/namespace/RoutingProxy.java src/share/classes/com/sun/jmx/namespace/RoutingServerProxy.java src/share/classes/com/sun/jmx/namespace/package.html src/share/classes/com/sun/jmx/namespace/serial/DefaultRewritingProcessor.java src/share/classes/com/sun/jmx/namespace/serial/IdentityProcessor.java src/share/classes/com/sun/jmx/namespace/serial/JMXNamespaceContext.java src/share/classes/com/sun/jmx/namespace/serial/RewritingProcessor.java src/share/classes/com/sun/jmx/namespace/serial/RoutingOnlyProcessor.java src/share/classes/com/sun/jmx/namespace/serial/SerialRewritingProcessor.java src/share/classes/com/sun/jmx/namespace/serial/package.html src/share/classes/com/sun/jmx/remote/internal/ProxyInputStream.java src/share/classes/com/sun/jmx/remote/util/EventClientConnection.java src/share/classes/javax/management/ClientContext.java src/share/classes/javax/management/Description.java src/share/classes/javax/management/DescriptorFields.java src/share/classes/javax/management/DynamicWrapperMBean.java src/share/classes/javax/management/GenericMBeanException.java src/share/classes/javax/management/Impact.java src/share/classes/javax/management/MBean.java src/share/classes/javax/management/ManagedAttribute.java src/share/classes/javax/management/ManagedOperation.java src/share/classes/javax/management/NotificationInfo.java src/share/classes/javax/management/NotificationInfos.java src/share/classes/javax/management/ObjectNameTemplate.java src/share/classes/javax/management/QueryNotificationFilter.java src/share/classes/javax/management/QueryParser.java src/share/classes/javax/management/SendNotification.java src/share/classes/javax/management/event/EventClient.java src/share/classes/javax/management/event/EventClientDelegate.java src/share/classes/javax/management/event/EventClientDelegateMBean.java src/share/classes/javax/management/event/EventClientNotFoundException.java src/share/classes/javax/management/event/EventConsumer.java src/share/classes/javax/management/event/EventForwarder.java src/share/classes/javax/management/event/EventReceiver.java src/share/classes/javax/management/event/EventRelay.java src/share/classes/javax/management/event/EventSubscriber.java src/share/classes/javax/management/event/FetchingEventForwarder.java src/share/classes/javax/management/event/FetchingEventRelay.java src/share/classes/javax/management/event/ListenerInfo.java src/share/classes/javax/management/event/NotificationManager.java src/share/classes/javax/management/event/RMIPushEventForwarder.java src/share/classes/javax/management/event/RMIPushEventRelay.java src/share/classes/javax/management/event/RMIPushServer.java src/share/classes/javax/management/event/package-info.java src/share/classes/javax/management/namespace/JMXDomain.java src/share/classes/javax/management/namespace/JMXNamespace.java src/share/classes/javax/management/namespace/JMXNamespaceMBean.java src/share/classes/javax/management/namespace/JMXNamespacePermission.java src/share/classes/javax/management/namespace/JMXNamespaceView.java src/share/classes/javax/management/namespace/JMXNamespaces.java src/share/classes/javax/management/namespace/JMXRemoteNamespace.java src/share/classes/javax/management/namespace/JMXRemoteNamespaceMBean.java src/share/classes/javax/management/namespace/MBeanServerConnectionWrapper.java src/share/classes/javax/management/namespace/MBeanServerSupport.java src/share/classes/javax/management/namespace/VirtualEventManager.java src/share/classes/javax/management/namespace/package-info.java src/share/classes/javax/management/openmbean/MXBeanMapping.java src/share/classes/javax/management/openmbean/MXBeanMappingClass.java src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java src/share/classes/javax/management/openmbean/MXBeanMappingFactoryClass.java src/share/classes/javax/management/remote/IdentityMBeanServerForwarder.java src/share/classes/sun/net/www/protocol/http/HttpLogFormatter.java src/share/classes/sun/net/www/protocol/http/NegotiateCallbackHandler.java src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java src/share/classes/sun/security/ssl/KerberosPreMasterSecret.java src/windows/classes/sun/net/www/protocol/http/NTLMAuthSequence.java src/windows/classes/sun/net/www/protocol/http/NTLMAuthentication.java src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c test/javax/management/Introspector/AnnotatedMBeanTest.java test/javax/management/Introspector/AnnotatedNotificationInfoTest.java test/javax/management/Introspector/ExceptionsDescriptorTest.java test/javax/management/Introspector/MBeanDescriptionTest.java test/javax/management/Introspector/ObjectNameTemplateTest.java test/javax/management/Introspector/ParameterNameTest.java test/javax/management/Introspector/ResourceInjectionTest.java test/javax/management/MBeanServer/AttributeListMapTest.java test/javax/management/MBeanServer/DynamicWrapperMBeanTest.java test/javax/management/MBeanServer/InstanceNotFoundExceptionTest.java test/javax/management/MBeanServerFactory/NamedMBeanServerTest.java test/javax/management/ObjectName/ValueOfTest.java test/javax/management/context/ContextForwarderTest.java test/javax/management/context/ContextTest.java test/javax/management/context/LocaleAwareBroadcasterTest.java test/javax/management/context/LocaleTest.java test/javax/management/context/LocalizableTest.java test/javax/management/context/RemoteContextTest.java test/javax/management/context/localizable/MBeanDescriptions.properties test/javax/management/context/localizable/MBeanDescriptions_fr.java test/javax/management/context/localizable/Whatsit.java test/javax/management/context/localizable/WhatsitMBean.java test/javax/management/descriptor/DescriptorConstructorTest.java test/javax/management/eventService/AddRemoveListenerTest.java test/javax/management/eventService/CustomForwarderTest.java test/javax/management/eventService/EventClientExecutorTest.java test/javax/management/eventService/EventClientThreadTest.java test/javax/management/eventService/EventDelegateSecurityTest.java test/javax/management/eventService/EventManagerTest.java test/javax/management/eventService/FetchingTest.java test/javax/management/eventService/LeaseManagerDeadlockTest.java test/javax/management/eventService/LeaseTest.java test/javax/management/eventService/ListenerTest.java test/javax/management/eventService/MyFetchingEventForwarder.java test/javax/management/eventService/NotSerializableNotifTest.java test/javax/management/eventService/PublishTest.java test/javax/management/eventService/ReconnectableConnectorTest.java test/javax/management/eventService/SharingThreadTest.java test/javax/management/eventService/SubUnsubTest.java test/javax/management/eventService/SubscribeTest.java test/javax/management/eventService/UsingEventService.java test/javax/management/interop/MBeanExceptionInteropTest.java test/javax/management/modelmbean/DefaultDescriptorFieldTest.java test/javax/management/monitor/InstantiateMonitorNotificationTest.java test/javax/management/mxbean/CustomTypeTest.java test/javax/management/mxbean/JMXServiceURLTest.java test/javax/management/mxbean/customtypes/CustomLongMXBean.java test/javax/management/mxbean/customtypes/CustomMXBean.java test/javax/management/mxbean/customtypes/IntegerIsLongFactory.java test/javax/management/mxbean/customtypes/IntegerIsStringFactory.java test/javax/management/mxbean/customtypes/package-info.java test/javax/management/namespace/DomainCreationTest.java test/javax/management/namespace/EventWithNamespaceControlTest.java test/javax/management/namespace/EventWithNamespaceTest.java test/javax/management/namespace/ExportNamespaceTest.java test/javax/management/namespace/JMXDomainTest.java test/javax/management/namespace/JMXNamespaceSecurityTest.java test/javax/management/namespace/JMXNamespaceTest.java test/javax/management/namespace/JMXNamespaceViewTest.java test/javax/management/namespace/JMXNamespacesTest.java test/javax/management/namespace/JMXRemoteNamespaceTest.java test/javax/management/namespace/JMXRemoteTargetNamespace.java test/javax/management/namespace/LazyDomainTest.java test/javax/management/namespace/LeadingSeparatorsTest.java test/javax/management/namespace/MXBeanRefTest.java test/javax/management/namespace/NamespaceController.java test/javax/management/namespace/NamespaceControllerMBean.java test/javax/management/namespace/NamespaceCreationTest.java test/javax/management/namespace/NamespaceNotificationsTest.java test/javax/management/namespace/NullDomainObjectNameTest.java test/javax/management/namespace/NullObjectNameTest.java test/javax/management/namespace/QueryNamesTest.java test/javax/management/namespace/RemoveNotificationListenerTest.java test/javax/management/namespace/RoutingServerProxyTest.java test/javax/management/namespace/SerialParamProcessorTest.java test/javax/management/namespace/SourceNamespaceTest.java test/javax/management/namespace/VirtualMBeanNotifTest.java test/javax/management/namespace/VirtualMBeanTest.java test/javax/management/namespace/VirtualNamespaceQueryTest.java test/javax/management/namespace/VirtualPropsTest.java test/javax/management/namespace/Wombat.java test/javax/management/namespace/WombatMBean.java test/javax/management/namespace/namespace.policy test/javax/management/notification/SupportClearTest.java test/javax/management/openmbean/CompositeDataToMapTest.java test/javax/management/openmbean/GenericMBeanExceptionTest.java test/javax/management/query/QueryDottedAttrTest.java test/javax/management/query/QueryNotifFilterTest.java test/javax/management/query/QueryParseTest.java test/javax/management/remote/mandatory/connectorServer/CloseConnectionTest.java test/javax/management/remote/mandatory/connectorServer/ForwarderChainTest.java test/javax/management/remote/mandatory/connectorServer/StandardForwardersTest.java test/javax/management/remote/mandatory/version/JMXSpecVersionTest.java test/javax/management/standardmbean/FindMethodTest.java test/javax/management/standardmbean/RegistrationTest.java
diffstat 625 files changed, 26488 insertions(+), 63833 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Nov 23 10:04:47 2009 +0000
+++ b/.hgtags	Wed Nov 25 11:08:25 2009 -0800
@@ -50,3 +50,4 @@
 f708138c9aca4b389872838fe6773872fce3609e jdk7-b73
 eacb36e30327e7ae33baa068e82ddccbd91eaae2 jdk7-b74
 8885b22565077236a927e824ef450742e434a230 jdk7-b75
+8fb602395be0f7d5af4e7e93b7df2d960faf9d17 jdk7-b76
--- a/make/docs/CORE_PKGS.gmk	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/docs/CORE_PKGS.gmk	Wed Nov 25 11:08:25 2009 -0800
@@ -160,10 +160,8 @@
   javax.lang.model.type                          \
   javax.lang.model.util                          \
   javax.management                               \
-  javax.management.event                         \
   javax.management.loading                       \
   javax.management.monitor                       \
-  javax.management.namespace                     \
   javax.management.relation                      \
   javax.management.openmbean                     \
   javax.management.timer                         \
--- a/make/java/java/FILES_java.gmk	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/java/java/FILES_java.gmk	Wed Nov 25 11:08:25 2009 -0800
@@ -251,6 +251,7 @@
 	java/util/IdentityHashMap.java \
 	java/util/EnumMap.java \
     java/util/Arrays.java \
+    java/util/DualPivotQuicksort.java \
     java/util/TimSort.java \
     java/util/ComparableTimSort.java \
     java/util/ConcurrentModificationException.java \
--- a/make/java/net/Makefile	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/java/net/Makefile	Wed Nov 25 11:08:25 2009 -0800
@@ -83,7 +83,7 @@
 #
 # Find platform specific native code
 #
-vpath %.c $(PLATFORM_SRC)/native/sun/net/dns $(PLATFORM_SRC)/native/sun/net/www/protocol/http $(PLATFORM_SRC)/native/sun/net/spi
+vpath %.c $(PLATFORM_SRC)/native/sun/net/dns $(PLATFORM_SRC)/native/sun/net/www/protocol/http/ntlm $(PLATFORM_SRC)/native/sun/net/spi
 
 #
 # Include rules
--- a/make/jprt.properties	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/jprt.properties	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright 2006-2008 Sun Microsystems, Inc.  All Rights Reserved.
+# Copyright 2006-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
@@ -34,8 +34,8 @@
 solaris_x64_5.10,\
 linux_i586_2.6,\
 linux_x64_2.6,\
-windows_i586,\
-windows_x64
+windows_i586_5.0,\
+windows_x64_5.2
 
 # The different build flavors we want
 jprt.build.flavors=product,fastdebug
@@ -51,21 +51,37 @@
 jprt.solaris_sparcv9.build.platform.match32=solaris_sparc_5.10
 jprt.solaris_x64.build.platform.match32=solaris_i586_5.10
 
-# Standard list of jprt test targets for this workspace
+# Standard test target for everybody
 jprt.test.targets=*-*-*-jvm98
-jprt.regression.test.targets=        \
-   *-product-*-java/lang,            \
-   *-product-*-java/security,        \
-   *-product-*-java/text,            \
-   *-product-*-java/util
 
-#jprt.regression.test.targets=   \
-#   *-product-*-java/awt,       \
-#   *-product-*-java/beans,     \
-#   *-product-*-java/io,        \
-#   *-product-*-java/net,       \
-#   *-product-*-java/nio,       \
-#   *-product-*-java/rmi,       \
+# Test targets in test/Makefile (some longer running tests only test c2)
+jprt.make.rule.test.targets=    \
+   *-product-*-jdk_beans1,      \
+   *-product-*-jdk_beans2,      \
+   *-product-*-jdk_beans3,      \
+   *-product-*-jdk_io,          \
+   *-product-*-jdk_lang,        \
+   *-product-*-jdk_management1, \
+   *-product-*-jdk_management2, \
+   *-product-*-jdk_math,        \
+   *-product-*-jdk_misc,        \
+   *-product-*-jdk_net,         \
+   *-product-*-jdk_nio1,        \
+   *-product-*-jdk_nio2,        \
+   *-product-*-jdk_nio3,        \
+   *-product-*-jdk_security1,   \
+   *-product-*-jdk_security2,   \
+   *-product-*-jdk_security3,   \
+   *-product-*-jdk_text,        \
+   *-product-*-jdk_tools1,      \
+   *-product-*-jdk_tools2,      \
+   *-product-*-jdk_util
+
+# Some of these are crashing Xvfb or windows manager, need dedicated DISPLAY per test batch
+jprt2.make.rule.test.targets=    \
+   *-product-*-jdk_awt,         \
+   *-product-*-jdk_rmi,         \
+   *-product-*-jdk_swing,       \
 
 # Directories needed to build
 jprt.bundle.exclude.src.dirs=build
--- a/make/sun/awt/mapfile-vers	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/awt/mapfile-vers	Wed Nov 25 11:08:25 2009 -0800
@@ -53,7 +53,6 @@
 		Java_sun_awt_image_GifImageDecoder_initIDs;
 		Java_sun_awt_image_GifImageDecoder_parseImage;
 		Java_sun_awt_image_ImageRepresentation_initIDs;
-		Java_sun_awt_image_ImageRepresentation_setBytePixels;
 		Java_sun_awt_image_ImageRepresentation_setDiffICM;
 		Java_sun_awt_image_ImageRepresentation_setICMpixels;
 		Java_sun_awt_image_ImagingLib_convolveBI;
--- a/make/sun/awt/mapfile-vers-linux	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/awt/mapfile-vers-linux	Wed Nov 25 11:08:25 2009 -0800
@@ -55,7 +55,6 @@
 		Java_sun_awt_image_GifImageDecoder_parseImage;
 		Java_sun_awt_image_Image_initIDs;
 		Java_sun_awt_image_ImageRepresentation_initIDs;
-		Java_sun_awt_image_ImageRepresentation_setBytePixels;
 		Java_sun_awt_image_ImageRepresentation_setDiffICM;
 		Java_sun_awt_image_ImageRepresentation_setICMpixels;
 		Java_sun_awt_image_ImagingLib_convolveBI;
--- a/make/sun/javazic/tzdata/VERSION	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/javazic/tzdata/VERSION	Wed Nov 25 11:08:25 2009 -0800
@@ -21,4 +21,4 @@
 # CA 95054 USA or visit www.sun.com if you need additional information or
 # have any questions.
 #
-tzdata2009l
+tzdata2009r
--- a/make/sun/javazic/tzdata/antarctica	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/javazic/tzdata/antarctica	Wed Nov 25 11:08:25 2009 -0800
@@ -102,15 +102,38 @@
 # Davis, Vestfold Hills, -6835+07759, since 1957-01-13
 #	(except 1964-11 - 1969-02)
 # Mawson, Holme Bay, -6736+06253, since 1954-02-13
+
+# From Steffen Thorsen (2009-03-11):
+# Three Australian stations in Antarctica have changed their time zone:
+# Casey moved from UTC+8 to UTC+11
+# Davis moved from UTC+7 to UTC+5
+# Mawson moved from UTC+6 to UTC+5
+# The changes occurred on 2009-10-18 at 02:00 (local times).
+#
+# Government source: (Australian Antarctic Division)
+# <a href="http://www.aad.gov.au/default.asp?casid=37079">
+# http://www.aad.gov.au/default.asp?casid=37079
+# </a>
+#
+# We have more background information here:
+# <a href="http://www.timeanddate.com/news/time/antarctica-new-times.html">
+# http://www.timeanddate.com/news/time/antarctica-new-times.html
+# </a>
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Antarctica/Casey	0	-	zzz	1969
-			8:00	-	WST	# Western (Aus) Standard Time
+			8:00	-	WST	2009 Oct 18 2:00
+						# Western (Aus) Standard Time
+			11:00	-	CAST	# Casey Time
 Zone Antarctica/Davis	0	-	zzz	1957 Jan 13
 			7:00	-	DAVT	1964 Nov # Davis Time
 			0	-	zzz	1969 Feb
-			7:00	-	DAVT
+			7:00	-	DAVT	2009 Oct 18 2:0
+			5:00	-	DAVT
 Zone Antarctica/Mawson	0	-	zzz	1954 Feb 13
-			6:00	-	MAWT	# Mawson Time
+			6:00	-	MAWT	2009 Oct 18 2:00
+						# Mawson Time
+			5:00	-	MAWT
 # References:
 # <a href="http://www.antdiv.gov.au/aad/exop/sfo/casey/casey_aws.html">
 # Casey Weather (1998-02-26)
--- a/make/sun/javazic/tzdata/asia	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/javazic/tzdata/asia	Wed Nov 25 11:08:25 2009 -0800
@@ -21,7 +21,6 @@
 # CA 95054 USA or visit www.sun.com if you need additional information or
 # have any questions.
 #
-# <pre>
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -194,11 +193,30 @@
 #
 # No DST end date has been announced yet.
 
-# From Arthur David Olson (2009-07-11):
-# Arbitrarily end DST at the end of 2009 so that a POSIX-sytle time zone string
-# can appear in the Dhaka binary file and for the benefit of old glibc
-# reimplementations of the time zone software that mishandle permanent DST.
-# A change will be required once the end date is known.
+# From Alexander Krivenyshev (2009-09-25):
+# Bangladesh won't go back to Standard Time from October 1, 2009, 
+# instead it will continue DST measure till the cabinet makes a fresh decision. 
+#
+# Following report by same newspaper-"The Daily Star Friday":
+# "DST change awaits cabinet decision-Clock won't go back by 1-hr from Oct 1"
+# <a href="http://www.thedailystar.net/newDesign/news-details.php?nid=107021">
+# http://www.thedailystar.net/newDesign/news-details.php?nid=107021
+# </a>
+# or
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_bangladesh04.html">
+# http://www.worldtimezone.com/dst_news/dst_news_bangladesh04.html
+# </a>
+
+# From Steffen Thorsen (2009-10-13):
+# IANS (Indo-Asian News Service) now reports:
+# Bangladesh has decided that the clock advanced by an hour to make 
+# maximum use of daylight hours as an energy saving measure would 
+# "continue for an indefinite period."
+#
+# One of many places where it is published:
+# <a href="http://www.thaindian.com/newsportal/business/bangladesh-to-continue-indefinitely-with-advanced-time_100259987.html">
+# http://www.thaindian.com/newsportal/business/bangladesh-to-continue-indefinitely-with-advanced-time_100259987.html
+# </a>
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dhaka	6:01:40 -	LMT	1890
@@ -208,8 +226,7 @@
 			6:30	-	BURT	1951 Sep 30
 			6:00	-	DACT	1971 Mar 26 # Dacca Time
 			6:00	-	BDT	2009 Jun 19 23:00 # Bangladesh Time
-			6:00	1:00	BDST	2010
-			6:00	-	BDT
+			6:00	1:00	BDST
 
 # Bhutan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -373,14 +390,84 @@
 			5:00	-	KAST	1980 May
 			8:00	PRC	C%sT
 
+
+# From Lee Yiu Chung (2009-10-24):
+# I found there are some mistakes for the historial DST rule for Hong
+# Kong. Accoring to the DST record from Hong Kong Observatory (actually,
+# it is not [an] observatory, but the official meteorological agency of HK,
+# and also serves as the official timing agency), there are some missing
+# and incorrect rules. Although the exact switch over time is missing, I
+# think 3:30 is correct. The official DST record for Hong Kong can be
+# obtained from
+# <a href="http://www.hko.gov.hk/gts/time/Summertime.htm">
+# http://www.hko.gov.hk/gts/time/Summertime.htm
+# </a>.
+
+# From Arthur David Olson (2009-10-28):
+# Here are the dates given at
+# <a href="http://www.hko.gov.hk/gts/time/Summertime.htm">
+# http://www.hko.gov.hk/gts/time/Summertime.htm
+# </a>
+# as of 2009-10-28:
+# Year        Period
+# 1941        1 Apr to 30 Sep
+# 1942        Whole year 
+# 1943        Whole year
+# 1944        Whole year
+# 1945        Whole year
+# 1946        20 Apr to 1 Dec
+# 1947        13 Apr to 30 Dec
+# 1948        2 May to 31 Oct
+# 1949        3 Apr to 30 Oct
+# 1950        2 Apr to 29 Oct
+# 1951        1 Apr to 28 Oct
+# 1952        6 Apr to 25 Oct
+# 1953        5 Apr to 1 Nov
+# 1954        21 Mar to 31 Oct
+# 1955        20 Mar to 6 Nov
+# 1956        18 Mar to 4 Nov
+# 1957        24 Mar to 3 Nov
+# 1958        23 Mar to 2 Nov
+# 1959        22 Mar to 1 Nov
+# 1960        20 Mar to 6 Nov
+# 1961        19 Mar to 5 Nov
+# 1962        18 Mar to 4 Nov
+# 1963        24 Mar to 3 Nov
+# 1964        22 Mar to 1 Nov
+# 1965        18 Apr to 17 Oct
+# 1966        17 Apr to 16 Oct
+# 1967        16 Apr to 22 Oct
+# 1968        21 Apr to 20 Oct
+# 1969        20 Apr to 19 Oct
+# 1970        19 Apr to 18 Oct
+# 1971        18 Apr to 17 Oct
+# 1972        16 Apr to 22 Oct
+# 1973        22 Apr to 21 Oct
+# 1973/74     30 Dec 73 to 20 Oct 74
+# 1975        20 Apr to 19 Oct
+# 1976        18 Apr to 17 Oct
+# 1977        Nil
+# 1978        Nil
+# 1979        13 May to 21 Oct
+# 1980 to Now Nil
+# The page does not give start or end times of day.
+# The page does not give a start date for 1942.
+# The page does not givw an end date for 1945.
+# The Japanese occupation of Hong Kong began on 1941-12-25.
+# The Japanese surrender of Hong Kong was signed 1945-09-15.
+# For lack of anything better, use start of those days as the transition times.
+
 # Hong Kong (Xianggang)
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
+Rule	HK	1941	only	-	Apr	1	3:30	1:00	S
+Rule	HK	1941	only	-	Sep	30	3:30	0	-
 Rule	HK	1946	only	-	Apr	20	3:30	1:00	S
 Rule	HK	1946	only	-	Dec	1	3:30	0	-
 Rule	HK	1947	only	-	Apr	13	3:30	1:00	S
 Rule	HK	1947	only	-	Dec	30	3:30	0	-
 Rule	HK	1948	only	-	May	2	3:30	1:00	S
-Rule	HK	1948	1952	-	Oct	lastSun	3:30	0	-
+Rule	HK	1948	1951	-	Oct	lastSun	3:30	0	-
+Rule	HK	1952	only	-	Oct	25	3:30	0	-
 Rule	HK	1949	1953	-	Apr	Sun>=1	3:30	1:00	S
 Rule	HK	1953	only	-	Nov	1	3:30	0	-
 Rule	HK	1954	1964	-	Mar	Sun>=18	3:30	1:00	S
@@ -388,13 +475,15 @@
 Rule	HK	1955	1964	-	Nov	Sun>=1	3:30	0	-
 Rule	HK	1965	1977	-	Apr	Sun>=16	3:30	1:00	S
 Rule	HK	1965	1977	-	Oct	Sun>=16	3:30	0	-
-Rule	HK	1979	1980	-	May	Sun>=8	3:30	1:00	S
-Rule	HK	1979	1980	-	Oct	Sun>=16	3:30	0	-
+Rule	HK	1973	only	-	Dec	30	3:30	1:00	S
+Rule	HK	1979	only	-	May	Sun>=8	3:30	1:00	S
+Rule	HK	1979	only	-	Oct	Sun>=16	3:30	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Hong_Kong	7:36:36 -	LMT	1904 Oct 30
+			8:00	HK	HK%sT	1941 Dec 25
+			9:00	-	JST	1945 Sep 15
 			8:00	HK	HK%sT
 
-
 ###############################################################################
 
 # Taiwan
@@ -1696,16 +1785,66 @@
 # advance clocks in the country by one hour from April 15 to
 # conserve energy"
 
-# From Arthur David Olson (2009-04-10):
-# Assume for now that Pakistan will end DST in 2009 as it did in 2008.
+# From Steffen Thorsen (2009-09-17):
+# "The News International," Pakistan reports that: "The Federal
+# Government has decided to restore the previous time by moving the
+# clocks backward by one hour from October 1. A formal announcement to
+# this effect will be made after the Prime Minister grants approval in
+# this regard." 
+# <a href="http://www.thenews.com.pk/updates.asp?id=87168">
+# http://www.thenews.com.pk/updates.asp?id=87168
+# </a>
+
+# From Alexander Krivenyshev (2009-09-28):
+# According to Associated Press Of Pakistan, it is confirmed that
+# Pakistan clocks across the country would be turned back by an hour from October
+# 1, 2009.
+#
+# "Clocks to go back one hour from 1 Oct"
+# <a href="http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=86715&Itemid=2">
+# http://www.app.com.pk/en_/index.php?option=com_content&task=view&id=86715&Itemid=2
+# </a>
+# or
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_pakistan07.htm">
+# http://www.worldtimezone.com/dst_news/dst_news_pakistan07.htm
+# </a>
+
+# From Steffen Thorsen (2009-09-29):
+# Alexander Krivenyshev wrote:
+# > According to Associated Press Of Pakistan, it is confirmed that
+# > Pakistan clocks across the country would be turned back by an hour from October
+# > 1, 2009.
+#
+# Now they seem to have changed their mind, November 1 is the new date:
+# <a href="http://www.thenews.com.pk/top_story_detail.asp?Id=24742">
+# http://www.thenews.com.pk/top_story_detail.asp?Id=24742
+# </a>
+# "The country's clocks will be reversed by one hour on November 1.
+# Officials of Federal Ministry for Interior told this to Geo News on
+# Monday."
+#
+# And more importantly, it seems that these dates will be kept every year:
+# "It has now been decided that clocks will be wound forward by one hour
+# on April 15 and reversed by an hour on November 1 every year without
+# obtaining prior approval, the officials added."
+#
+# We have confirmed this year's end date with both with the Ministry of
+# Water and Power and the Pakistan Electric Power Company:
+# <a href="http://www.timeanddate.com/news/time/pakistan-ends-dst09.html">
+# http://www.timeanddate.com/news/time/pakistan-ends-dst09.html
+# </a>
+
+# From Christoph Goehre (2009-10-01):
+# [T]he German Consulate General in Karachi reported me today that Pakistan
+# will go back to standard time on 1st of November.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule Pakistan	2002	only	-	Apr	Sun>=2	0:01	1:00	S
 Rule Pakistan	2002	only	-	Oct	Sun>=2	0:01	0	-
 Rule Pakistan	2008	only	-	Jun	1	0:00	1:00	S
 Rule Pakistan	2008	only	-	Nov	1	0:00	0	-
-Rule Pakistan	2009	only	-	Apr	15	0:00	1:00	S
-Rule Pakistan	2009	only	-	Nov	1	0:00	0	-
+Rule Pakistan	2009	max	-	Apr	15	0:00	1:00	S
+Rule Pakistan	2009	max	-	Nov	1	0:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Karachi	4:28:12 -	LMT	1907
 			5:30	-	IST	1942 Sep
@@ -1858,6 +1997,42 @@
 # http://www.worldtimezone.com/dst_news/dst_news_westbank01.html
 # </a>
 
+# From Steffen Thorsen (2009-08-31):
+# Palestine's Council of Ministers announced that they will revert back to
+# winter time on Friday, 2009-09-04.
+#
+# One news source:
+# <a href="http://www.safa.ps/ara/?action=showdetail&seid=4158">
+# http://www.safa.ps/ara/?action=showdetail&seid=4158
+# </a>
+# (Palestinian press agency, Arabic),
+# Google translate: "Decided that the Palestinian government in Ramallah
+# headed by Salam Fayyad, the start of work in time for the winter of
+# 2009, starting on Friday approved the fourth delay Sept. clock sixty
+# minutes per hour as of Friday morning."
+#
+# We are not sure if Gaza will do the same, last year they had a different
+# end date, we will keep this page updated:
+# <a href="http://www.timeanddate.com/news/time/westbank-gaza-dst-2009.html">
+# http://www.timeanddate.com/news/time/westbank-gaza-dst-2009.html
+# </a>
+
+# From Alexander Krivenyshev (2009-09-02):
+# Seems that Gaza Strip will go back to Winter Time same date as West Bank.
+#
+# According to Palestinian Ministry Of Interior, West Bank and Gaza Strip plan
+# to change time back to Standard time on September 4, 2009.
+#
+# "Winter time unite the West Bank and Gaza"
+# (from Palestinian National Authority):
+# <a href="http://www.moi.gov.ps/en/?page=633167343250594025&nid=11505
+# http://www.moi.gov.ps/en/?page=633167343250594025&nid=11505
+# </a>
+# or
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_gazastrip02.html>
+# http://www.worldtimezone.com/dst_news/dst_news_gazastrip02.html
+# </a>
+
 # The rules for Egypt are stolen from the `africa' file.
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule EgyptAsia	1957	only	-	May	10	0:00	1:00	S
@@ -1876,7 +2051,7 @@
 Rule Palestine	2007	only	-	Sep	Thu>=8	2:00	0	-
 Rule Palestine	2008	only	-	Aug	lastFri	2:00	0	-
 Rule Palestine	2009	max	-	Mar	lastFri	0:00	1:00	S
-Rule Palestine	2009	max	-	Sep	lastMon	2:00	0	-
+Rule Palestine	2009	max	-	Sep	Fri>=1	2:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Gaza	2:17:52	-	LMT	1900 Oct
@@ -2154,9 +2329,23 @@
 # http://www.timeanddate.com/news/time/syria-dst-starts-march-27-2009.html
 # </a>
 
+# From Steffen Thorsen (2009-10-27):
+# The Syrian Arab News Network on 2009-09-29 reported that Syria will 
+# revert back to winter (standard) time on midnight between Thursday 
+# 2009-10-29 and Friday 2009-10-30:
+# <a href="http://www.sana.sy/ara/2/2009/09/29/247012.htm">
+# http://www.sana.sy/ara/2/2009/09/29/247012.htm (Arabic)
+# </a>
+
+# From Arthur David Olson (2009-10-28):
+# We'll see if future DST switching times turn out to be end of the last
+# Thursday of the month or the start of the last Friday of the month or
+# something else. For now, use the start of the last Friday.
+
 Rule	Syria	2008	only	-	Apr	Fri>=1	0:00	1:00	S
-Rule	Syria	2008	max	-	Nov	1	0:00	0	-
+Rule	Syria	2008	only	-	Nov	1	0:00	0	-
 Rule	Syria	2009	max	-	Mar	lastFri	0:00	1:00	S
+Rule	Syria	2009	max	-	Oct	lastFri	0:00	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Damascus	2:25:12 -	LMT	1920	# Dimashq
--- a/make/sun/javazic/tzdata/australasia	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/javazic/tzdata/australasia	Wed Nov 25 11:08:25 2009 -0800
@@ -465,10 +465,56 @@
 # http://www.worldtimezone.com/dst_news/dst_news_samoa01.html
 # </a>
 
+# From Steffen Thorsen (2009-08-27):
+# Samoa's parliament passed the Daylight Saving Bill 2009, and will start 
+# daylight saving time on the first Sunday of October 2009 and end on the 
+# last Sunday of March 2010. We hope that the full text will be published 
+# soon, but we believe that the bill is only valid for 2009-2010. Samoa's 
+# Daylight Saving Act 2009 will be enforced as soon as the Head of State 
+# executes a proclamation publicizing this Act.
+#
+# Some background information here, which will be updated once we have 
+# more details:
+# <a href="http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html">
+# http://www.timeanddate.com/news/time/samoa-dst-plan-2009.html
+# </a>
+
+# From Alexander Krivenyshev (2009-10-03):
+# First, my deepest condolences to people of Samoa islands and all families and
+# loved ones around the world who lost their lives in the earthquake and tsunami.
+#
+# Considering the recent devastation on Samoa by earthquake and tsunami and that
+# many government offices/ ministers are closed- not sure if "Daylight Saving
+# Bill 2009" will be implemented in next few days- on October 4, 2009.
+#
+# Here is reply from Consulate-General of Samoa in New Zealand
+# ---------------------------
+# Consul General
+# consulgeneral@samoaconsulate.org.nz
+#
+# Talofa Alexander,
+#
+# Thank you for your sympathy for our country but at this time we have not
+# been informed about the Daylight Savings Time Change.  Most Ministries in
+# Apia are closed or relocating due to weather concerns.
+#
+# When we do find out if they are still proceeding with the time change we
+# will advise you soonest.
+#
+# Kind Regards,
+# Lana
+# for: Consul General
+
+# From Steffen Thorsen (2009-10-05):
+# We have called a hotel in Samoa and asked about local time there - they 
+# are still on standard time.
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
-			-11:00	-	WST			# Samoa Time
+			-11:00	-	WST	2009 Oct 4
+			-11:00	1:00	WSDT	2010 Mar 28
+			-11:00	-	WST
 
 # Solomon Is
 # excludes Bougainville, for which see Papua New Guinea
--- a/make/sun/javazic/tzdata/europe	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/javazic/tzdata/europe	Wed Nov 25 11:08:25 2009 -0800
@@ -2094,9 +2094,43 @@
 			 6:00	Russia	NOV%sT	1992 Jan 19 2:00s
 			 7:00	Russia	NOV%sT	1993 May 23 # say Shanks & P.
 			 6:00	Russia	NOV%sT
+
+# From Alexander Krivenyshev (2009-10-13):
+# Kemerovo oblast' (Kemerovo region) in Russia will change current time zone on
+# March 28, 2010:
+# from current Russia Zone 6 - Krasnoyarsk Time Zone (KRA) UTC +0700
+# to Russia Zone 5 - Novosibirsk Time Zone (NOV) UTC +0600
+#
+# This is according to Government of Russia decree # 740, on September
+# 14, 2009 "Application in the territory of the Kemerovo region the Fifth
+# time zone." ("Russia Zone 5" or old "USSR Zone 5" is GMT +0600)
+#
+# Russian Government web site (Russian language)
+# <a href="http://www.government.ru/content/governmentactivity/rfgovernmentdecisions/archiv">
+# http://www.government.ru/content/governmentactivity/rfgovernmentdecisions/archive/2009/09/14/991633.htm
+# </a>
+# or Russian-English translation by WorldTimeZone.com with reference
+# map to local region and new Russia Time Zone map after March 28, 2010
+# <a href="http://www.worldtimezone.com/dst_news/dst_news_russia03.html">
+# http://www.worldtimezone.com/dst_news/dst_news_russia03.html
+# </a>
+#
+# Thus, when Russia will switch to DST on the night of March 28, 2010
+# Kemerovo region (Kemerovo oblast') will not change the clock.
+#
+# As a result, Kemerovo oblast' will be in the same time zone as
+# Novosibirsk, Omsk, Tomsk, Barnaul and Altai Republic.
+
+Zone Asia/Novokuznetsk	 5:48:48 -	NMT	1920 Jan  6
+			 6:00	-	KRAT	1930 Jun 21 # Krasnoyarsk Time
+			 7:00	Russia	KRA%sT	1991 Mar 31 2:00s
+			 6:00	Russia	KRA%sT	1992 Jan 19 2:00s
+			 7:00	Russia	KRA%sT	2010 Mar 28 2:00s
+			 6:00	Russia	NOV%sT # Novosibirsk/Novokuznetsk Time
+
 #
 # From Oscar van Vlijmen (2001-08-25): [This region consists of]
-# Kemerovskaya oblast', Krasnoyarskij kraj,
+# Krasnoyarskij kraj,
 # Tajmyrskij (Dolgano-Nenetskij) avtonomnyj okrug,
 # Respublika Tuva, Respublika Khakasiya, Evenkijskij avtonomnyj okrug.
 Zone Asia/Krasnoyarsk	 6:11:20 -	LMT	1920 Jan  6
--- a/make/sun/javazic/tzdata/southamerica	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/javazic/tzdata/southamerica	Wed Nov 25 11:08:25 2009 -0800
@@ -237,9 +237,23 @@
 # http://www.jujuy.gov.ar/index2/partes_prensa/18_10_08/235-181008.doc
 # </a>
 
+# From fullinet (2009-10-18):
+# As announced in
+# <a hef="http://www.argentina.gob.ar/argentina/portal/paginas.dhtml?pagina=356">
+# http://www.argentina.gob.ar/argentina/portal/paginas.dhtml?pagina=356
+# </a>
+# (an official .gob.ar) under title: "Sin Cambio de Hora" (english: "No hour change")
+#
+# "Por el momento, el Gobierno Nacional resolvio no modificar la hora
+# oficial, decision que estaba en estudio para su implementacion el
+# domingo 18 de octubre. Desde el Ministerio de Planificacion se anuncio
+# que la Argentina hoy, en estas condiciones meteorologicas, no necesita
+# la modificacion del huso horario, ya que 2009 nos encuentra con
+# crecimiento en la produccion y distribucion energetica."
+
 Rule	Arg	2007	only	-	Dec	30	0:00	1:00	S
-Rule	Arg	2008	max	-	Mar	Sun>=15	0:00	0	-
-Rule	Arg	2008	max	-	Oct	Sun>=15	0:00	1:00	S
+Rule	Arg	2008	2009	-	Mar	Sun>=15	0:00	0	-
+Rule	Arg	2008	only	-	Oct	Sun>=15	0:00	1:00	S
  
 # From Mariano Absatz (2004-05-21):
 # Today it was officially published that the Province of Mendoza is changing
@@ -411,15 +425,40 @@
 # during 2009, this timezone change will run from 00:00 the third Sunday
 # in March until 24:00 of the second Saturday in October.
 
-# From Arthur David Olson (2009-03-16):
-# The unofficial claim at
-# <a href="http://www.timeanddate.com/news/time/san-luis-new-time-zone.html">
-# http://www.timeanddate.com/news/time/san-luis-new-time-zone.html
+# From Mariano Absatz (2009-10-16):
+# ...the Province of San Luis is a case in itself.
+#
+# The Law at
+# <a href="http://www.diputadossanluis.gov.ar/diputadosasp/paginas/verNorma.asp?NormaID=276>"
+# http://www.diputadossanluis.gov.ar/diputadosasp/paginas/verNorma.asp?NormaID=276
 # </a>
-# is that "The province will most likely follow the next daylight saving schedule,
-# which is planned for the second Sunday in October."
+# is ambiguous because establishes a calendar from the 2nd Sunday in
+# October at 0:00 thru the 2nd Saturday in March at 24:00 and the
+# complement of that starting on the 2nd Sunday of March at 0:00 and
+# ending on the 2nd Saturday of March at 24:00.
+#
+# This clearly breaks every time the 1st of March or October is a Sunday.
+#
+# IMHO, the "spirit of the Law" is to make the changes at 0:00 on the 2nd
+# Sunday of October and March.
+#
+# The problem is that the changes in the rest of the Provinces that did
+# change in 2007/2008, were made according to the Federal Law and Decrees
+# that did so on the 3rd Sunday of October and March.
+#
+# In fact, San Luis actually switched from UTC-4 to UTC-3 last Sunday
+# (October 11th) at 0:00.
+#
+# So I guess a new set of rules, besides "Arg", must be made and the last
+# America/Argentina/San_Luis entries should change to use these...
+#
+# I'm enclosing a patch that does what I say... regretfully, the San Luis
+# timezone must be called "WART/WARST" even when most of the time (like,
+# right now) WARST == ART... that is, since last Sunday, all the country
+# is using UTC-3, but in my patch, San Luis calls it "WARST" and the rest
+# of the country calls it "ART".
+# ...
 
-#
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 #
 # Buenos Aires (BA), Capital Federal (CF),
@@ -552,6 +591,10 @@
 			-3:00	-	ART
 #
 # San Luis (SL)
+
+Rule	SanLuis	2008	max	-	Mar	Sun>=8	0:00	0	-
+Rule	SanLuis	2007	max	-	Oct	Sun>=8	0:00	1:00	S
+
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
 			-4:00	-	ART	1930 Dec
@@ -566,8 +609,7 @@
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
 			-3:00	Arg	AR%sT	2008 Jan 21
-			-3:00	-	ART	2009 Mar 15
-			-4:00	Arg	WAR%sT
+			-4:00	SanLuis	WAR%sT
 #
 # Santa Cruz (SC)
 Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31
--- a/make/sun/javazic/tzdata/zone.tab	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/javazic/tzdata/zone.tab	Wed Nov 25 11:08:25 2009 -0800
@@ -352,6 +352,7 @@
 RU	+5651+06036	Asia/Yekaterinburg	Moscow+02 - Urals
 RU	+5500+07324	Asia/Omsk	Moscow+03 - west Siberia
 RU	+5502+08255	Asia/Novosibirsk	Moscow+03 - Novosibirsk
+RU	+5345+08707	Asia/Novokuznetsk	Moscow+03 - Novokuznetsk
 RU	+5601+09250	Asia/Krasnoyarsk	Moscow+04 - Yenisei River
 RU	+5216+10420	Asia/Irkutsk	Moscow+05 - Lake Baikal
 RU	+6200+12940	Asia/Yakutsk	Moscow+06 - Lena River
--- a/make/sun/net/FILES_java.gmk	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/net/FILES_java.gmk	Wed Nov 25 11:08:25 2009 -0800
@@ -45,8 +45,14 @@
 	sun/net/dns/ResolverConfiguration.java \
 	sun/net/dns/ResolverConfigurationImpl.java \
 	sun/net/ftp/FtpClient.java \
+	sun/net/ftp/FtpClientProvider.java \
+	sun/net/ftp/FtpDirEntry.java \
+	sun/net/ftp/FtpReplyCode.java \
+	sun/net/ftp/FtpDirParser.java \
 	sun/net/ftp/FtpLoginException.java \
 	sun/net/ftp/FtpProtocolException.java \
+	sun/net/ftp/impl/FtpClient.java \
+	sun/net/ftp/impl/DefaultFtpClientProvider.java \
 	sun/net/spi/DefaultProxySelector.java \
 	sun/net/spi/nameservice/NameServiceDescriptor.java \
 	sun/net/spi/nameservice/NameService.java \
@@ -79,7 +85,6 @@
 	sun/net/www/http/Hurryable.java \
 	sun/net/www/protocol/http/Handler.java \
 	sun/net/www/protocol/http/HttpURLConnection.java \
-	sun/net/www/protocol/http/HttpLogFormatter.java \
 	sun/net/www/protocol/http/HttpAuthenticator.java \
 	sun/net/www/protocol/http/AuthenticationHeader.java \
 	sun/net/www/protocol/http/AuthenticationInfo.java \
@@ -89,11 +94,13 @@
 	sun/net/www/protocol/http/AuthScheme.java \
 	sun/net/www/protocol/http/BasicAuthentication.java \
 	sun/net/www/protocol/http/DigestAuthentication.java \
-	sun/net/www/protocol/http/NTLMAuthentication.java \
 	sun/net/www/protocol/http/NTLMAuthenticationProxy.java \
 	sun/net/www/protocol/http/NegotiateAuthentication.java \
-	sun/net/www/protocol/http/NegotiatorImpl.java \
-	sun/net/www/protocol/http/NegotiateCallbackHandler.java \
+	sun/net/www/protocol/http/Negotiator.java \
+	sun/net/www/protocol/http/ntlm/NTLMAuthentication.java \
+	sun/net/www/protocol/http/spnego/NegotiatorImpl.java \
+	sun/net/www/protocol/http/spnego/NegotiateCallbackHandler.java \
+	sun/net/www/protocol/http/logging/HttpLogFormatter.java \
 	sun/net/www/protocol/https/AbstractDelegateHttpsURLConnection.java \
 	sun/net/www/protocol/https/HttpsClient.java \
 	sun/net/www/protocol/https/DefaultHostnameVerifier.java \
@@ -128,7 +135,7 @@
 	sun/net/idn/StringPrep.java
 
 ifeq ($(PLATFORM), windows)
-    FILES_java += sun/net/www/protocol/http/NTLMAuthSequence.java 
+    FILES_java += sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java 
 endif
 
 ifeq ($(PLATFORM), solaris)
--- a/make/sun/security/other/Makefile	Mon Nov 23 10:04:47 2009 +0000
+++ b/make/sun/security/other/Makefile	Wed Nov 25 11:08:25 2009 -0800
@@ -39,6 +39,7 @@
     sun/security/provider \
     sun/security/rsa \
     sun/security/ssl \
+    sun/security/ssl/krb5 \
     sun/security/timestamp \
     sun/security/validator \
     sun/security/x509 \
--- a/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java	Wed Nov 25 11:08:25 2009 -0800
@@ -62,6 +62,8 @@
 
 import java.io.*;
 import java.nio.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.StringTokenizer;
@@ -502,12 +504,18 @@
             iis.reset();
 
             try {
-                if (metadata.colorSpace == PROFILE_LINKED)
+                if (metadata.colorSpace == PROFILE_LINKED &&
+                    isLinkedProfileAllowed() &&
+                    !isUncOrDevicePath(profile))
+                {
+                    String path = new String(profile, "windows-1252");
+
                     colorSpace =
-                        new ICC_ColorSpace(ICC_Profile.getInstance(new String(profile)));
-                else
+                        new ICC_ColorSpace(ICC_Profile.getInstance(path));
+                } else {
                     colorSpace =
                         new ICC_ColorSpace(ICC_Profile.getInstance(profile));
+                }
             } catch (Exception e) {
                 colorSpace = ColorSpace.getInstance(ColorSpace.CS_sRGB);
             }
@@ -1745,4 +1753,69 @@
         public void sequenceStarted(ImageReader src, int minIndex) {}
         public void readAborted(ImageReader src) {}
     }
+
+    private static Boolean isLinkedProfileDisabled = null;
+
+    private static boolean isLinkedProfileAllowed() {
+        if (isLinkedProfileDisabled == null) {
+            PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
+                public Boolean run() {
+                    return Boolean.getBoolean("sun.imageio.plugins.bmp.disableLinkedProfiles");
+                }
+            };
+            isLinkedProfileDisabled = AccessController.doPrivileged(a);
+        }
+        return !isLinkedProfileDisabled;
+    }
+
+    private static Boolean isWindowsPlatform = null;
+
+    /**
+     * Verifies whether the byte array contans a unc path.
+     * Non-UNC path examples:
+     *  c:\path\to\file  - simple notation
+     *  \\?\c:\path\to\file - long notation
+     *
+     * UNC path examples:
+     *  \\server\share - a UNC path in simple notation
+     *  \\?\UNC\server\share - a UNC path in long notation
+     *  \\.\some\device - a path to device.
+     */
+    private static boolean isUncOrDevicePath(byte[] p) {
+        if (isWindowsPlatform == null) {
+            PrivilegedAction<Boolean> a = new PrivilegedAction<Boolean>() {
+                public Boolean run() {
+                    String osname = System.getProperty("os.name");
+                    return (osname != null &&
+                            osname.toLowerCase().startsWith("win"));
+                }
+            };
+            isWindowsPlatform = AccessController.doPrivileged(a);
+        }
+
+        if (!isWindowsPlatform) {
+            /* no need for the check on platforms except windows */
+            return false;
+        }
+
+        /* normalize prefix of the path */
+        if (p[0] == '/') p[0] = '\\';
+        if (p[1] == '/') p[1] = '\\';
+        if (p[3] == '/') p[3] = '\\';
+
+
+        if ((p[0] == '\\') && (p[1] == '\\')) {
+            if ((p[2] == '?') && (p[3] == '\\')) {
+                // long path: whether unc or local
+                return ((p[4] == 'U' || p[4] == 'u') &&
+                        (p[5] == 'N' || p[5] == 'n') &&
+                        (p[6] == 'C' || p[6] == 'c'));
+            } else {
+                // device path or short unc notation
+                return true;
+            }
+        } else {
+            return false;
+        }
+    }
 }
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.motif;
 
+import sun.awt.AppContext;
+
 import javax.swing.*;
 import javax.swing.border.*;
 import javax.swing.plaf.basic.*;
@@ -46,16 +48,23 @@
  */
 public class MotifButtonUI extends BasicButtonUI {
 
-    private final static MotifButtonUI motifButtonUI = new MotifButtonUI();
-
     protected Color selectColor;
 
     private boolean defaults_initialized = false;
 
+    private static final Object MOTIF_BUTTON_UI_KEY = new Object();
+
     // ********************************
     //          Create PLAF
     // ********************************
-    public static ComponentUI createUI(JComponent c){
+    public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        MotifButtonUI motifButtonUI =
+                (MotifButtonUI) appContext.get(MOTIF_BUTTON_UI_KEY);
+        if (motifButtonUI == null) {
+            motifButtonUI = new MotifButtonUI();
+            appContext.put(MOTIF_BUTTON_UI_KEY, motifButtonUI);
+        }
         return motifButtonUI;
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifCheckBoxUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifCheckBoxUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.motif;
 
+import sun.awt.AppContext;
+
 import javax.swing.*;
 
 import javax.swing.plaf.*;
@@ -45,7 +47,7 @@
  */
 public class MotifCheckBoxUI extends MotifRadioButtonUI {
 
-    private static final MotifCheckBoxUI motifCheckBoxUI = new MotifCheckBoxUI();
+    private static final Object MOTIF_CHECK_BOX_UI_KEY = new Object();
 
     private final static String propertyPrefix = "CheckBox" + ".";
 
@@ -55,7 +57,14 @@
     // ********************************
     //         Create PLAF
     // ********************************
-    public static ComponentUI createUI(JComponent c){
+    public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        MotifCheckBoxUI motifCheckBoxUI =
+                (MotifCheckBoxUI) appContext.get(MOTIF_CHECK_BOX_UI_KEY);
+        if (motifCheckBoxUI == null) {
+            motifCheckBoxUI = new MotifCheckBoxUI();
+            appContext.put(MOTIF_CHECK_BOX_UI_KEY, motifCheckBoxUI);
+        }
         return motifCheckBoxUI;
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifLabelUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifLabelUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.motif;
 
+import sun.awt.AppContext;
+
 import javax.swing.*;
 import javax.swing.plaf.basic.BasicLabelUI;
 import javax.swing.plaf.ComponentUI;
@@ -44,9 +46,16 @@
  */
 public class MotifLabelUI extends BasicLabelUI
 {
-    static MotifLabelUI sharedInstance = new MotifLabelUI();
+    private static final Object MOTIF_LABEL_UI_KEY = new Object();
 
     public static ComponentUI createUI(JComponent c) {
-        return sharedInstance;
+        AppContext appContext = AppContext.getAppContext();
+        MotifLabelUI motifLabelUI =
+                (MotifLabelUI) appContext.get(MOTIF_LABEL_UI_KEY);
+        if (motifLabelUI == null) {
+            motifLabelUI = new MotifLabelUI();
+            appContext.put(MOTIF_LABEL_UI_KEY, motifLabelUI);
+        }
+        return motifLabelUI;
     }
 }
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifRadioButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.motif;
 
+import sun.awt.AppContext;
+
 import javax.swing.*;
 import javax.swing.border.*;
 import javax.swing.plaf.basic.BasicRadioButtonUI;
@@ -47,7 +49,7 @@
  */
 public class MotifRadioButtonUI extends BasicRadioButtonUI {
 
-    private static final MotifRadioButtonUI motifRadioButtonUI = new MotifRadioButtonUI();
+    private static final Object MOTIF_RADIO_BUTTON_UI_KEY = new Object();
 
     protected Color focusColor;
 
@@ -57,6 +59,13 @@
     //         Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        MotifRadioButtonUI motifRadioButtonUI =
+                (MotifRadioButtonUI) appContext.get(MOTIF_RADIO_BUTTON_UI_KEY);
+        if (motifRadioButtonUI == null) {
+            motifRadioButtonUI = new MotifRadioButtonUI();
+            appContext.put(MOTIF_RADIO_BUTTON_UI_KEY, motifRadioButtonUI);
+        }
         return motifRadioButtonUI;
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/motif/MotifToggleButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/motif/MotifToggleButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.motif;
 
+import sun.awt.AppContext;
+
 import java.awt.*;
 import java.awt.event.*;
 
@@ -48,7 +50,7 @@
  */
 public class MotifToggleButtonUI extends BasicToggleButtonUI
 {
-    private final static MotifToggleButtonUI motifToggleButtonUI = new MotifToggleButtonUI();
+    private static final Object MOTIF_TOGGLE_BUTTON_UI_KEY = new Object();
 
     protected Color selectColor;
 
@@ -58,6 +60,13 @@
     //         Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent b) {
+        AppContext appContext = AppContext.getAppContext();
+        MotifToggleButtonUI motifToggleButtonUI =
+                (MotifToggleButtonUI) appContext.get(MOTIF_TOGGLE_BUTTON_UI_KEY);
+        if (motifToggleButtonUI == null) {
+            motifToggleButtonUI = new MotifToggleButtonUI();
+            appContext.put(MOTIF_TOGGLE_BUTTON_UI_KEY, motifToggleButtonUI);
+        }
         return motifToggleButtonUI;
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -35,6 +35,7 @@
 import static com.sun.java.swing.plaf.windows.TMSchema.*;
 import static com.sun.java.swing.plaf.windows.TMSchema.Part.*;
 import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+import sun.awt.AppContext;
 
 
 /**
@@ -52,8 +53,6 @@
  */
 public class WindowsButtonUI extends BasicButtonUI
 {
-    private final static WindowsButtonUI windowsButtonUI = new WindowsButtonUI();
-
     protected int dashedRectGapX;
     protected int dashedRectGapY;
     protected int dashedRectGapWidth;
@@ -63,11 +62,19 @@
 
     private boolean defaults_initialized = false;
 
+    private static final Object WINDOWS_BUTTON_UI_KEY = new Object();
 
     // ********************************
     //          Create PLAF
     // ********************************
-    public static ComponentUI createUI(JComponent c){
+    public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        WindowsButtonUI windowsButtonUI =
+                (WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY);
+        if (windowsButtonUI == null) {
+            windowsButtonUI = new WindowsButtonUI();
+            appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI);
+        }
         return windowsButtonUI;
     }
 
@@ -151,7 +158,7 @@
      * allocating them in each paint call substantially reduced the time
      * it took paint to run.  Obviously, this method can't be re-entered.
      */
-    private static Rectangle viewRect = new Rectangle();
+    private Rectangle viewRect = new Rectangle();
 
     public void paint(Graphics g, JComponent c) {
         if (XPStyle.getXP() != null) {
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsCheckBoxUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.windows;
 
+import sun.awt.AppContext;
+
 import javax.swing.plaf.basic.*;
 import javax.swing.*;
 import javax.swing.plaf.*;
@@ -49,7 +51,7 @@
     // of BasicCheckBoxUI because we want to pick up all the
     // painting changes made in MetalRadioButtonUI.
 
-    private static final WindowsCheckBoxUI windowsCheckBoxUI = new WindowsCheckBoxUI();
+    private static final Object WINDOWS_CHECK_BOX_UI_KEY = new Object();
 
     private final static String propertyPrefix = "CheckBox" + ".";
 
@@ -59,6 +61,13 @@
     //          Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        WindowsCheckBoxUI windowsCheckBoxUI =
+                (WindowsCheckBoxUI) appContext.get(WINDOWS_CHECK_BOX_UI_KEY);
+        if (windowsCheckBoxUI == null) {
+            windowsCheckBoxUI = new WindowsCheckBoxUI();
+            appContext.put(WINDOWS_CHECK_BOX_UI_KEY, windowsCheckBoxUI);
+        }
         return windowsCheckBoxUI;
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLabelUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
 package com.sun.java.swing.plaf.windows;
 
 import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
+
 import java.awt.Color;
 import java.awt.Graphics;
 
@@ -51,12 +53,19 @@
  */
 public class WindowsLabelUI extends BasicLabelUI {
 
-    private final static WindowsLabelUI windowsLabelUI = new WindowsLabelUI();
+    private static final Object WINDOWS_LABEL_UI_KEY = new Object();
 
     // ********************************
     //          Create PLAF
     // ********************************
-    public static ComponentUI createUI(JComponent c){
+    public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        WindowsLabelUI windowsLabelUI =
+                (WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY);
+        if (windowsLabelUI == null) {
+            windowsLabelUI = new WindowsLabelUI();
+            appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
+        }
         return windowsLabelUI;
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsRadioButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.windows;
 
+import sun.awt.AppContext;
+
 import javax.swing.plaf.basic.*;
 import javax.swing.*;
 import javax.swing.plaf.*;
@@ -44,7 +46,7 @@
  */
 public class WindowsRadioButtonUI extends BasicRadioButtonUI
 {
-    private static final WindowsRadioButtonUI windowsRadioButtonUI = new WindowsRadioButtonUI();
+    private static final Object WINDOWS_RADIO_BUTTON_UI_KEY = new Object();
 
     protected int dashedRectGapX;
     protected int dashedRectGapY;
@@ -59,6 +61,13 @@
     //          Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        WindowsRadioButtonUI windowsRadioButtonUI =
+                (WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY);
+        if (windowsRadioButtonUI == null) {
+            windowsRadioButtonUI = new WindowsRadioButtonUI();
+            appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI);
+        }
         return windowsRadioButtonUI;
     }
 
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsToggleButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package com.sun.java.swing.plaf.windows;
 
+import sun.awt.AppContext;
+
 import javax.swing.plaf.basic.*;
 import javax.swing.border.*;
 import javax.swing.plaf.*;
@@ -49,18 +51,25 @@
  */
 public class WindowsToggleButtonUI extends BasicToggleButtonUI
 {
-    protected static int dashedRectGapX;
-    protected static int dashedRectGapY;
-    protected static int dashedRectGapWidth;
-    protected static int dashedRectGapHeight;
+    protected int dashedRectGapX;
+    protected int dashedRectGapY;
+    protected int dashedRectGapWidth;
+    protected int dashedRectGapHeight;
 
     protected Color focusColor;
 
-    private final static WindowsToggleButtonUI windowsToggleButtonUI = new WindowsToggleButtonUI();
+    private static final Object WINDOWS_TOGGLE_BUTTON_UI_KEY = new Object();
 
     private boolean defaults_initialized = false;
 
     public static ComponentUI createUI(JComponent b) {
+        AppContext appContext = AppContext.getAppContext();
+        WindowsToggleButtonUI windowsToggleButtonUI =
+                (WindowsToggleButtonUI) appContext.get(WINDOWS_TOGGLE_BUTTON_UI_KEY);
+        if (windowsToggleButtonUI == null) {
+            windowsToggleButtonUI = new WindowsToggleButtonUI();
+            appContext.put(WINDOWS_TOGGLE_BUTTON_UI_KEY, windowsToggleButtonUI);
+        }
         return windowsToggleButtonUI;
     }
 
--- a/src/share/classes/com/sun/jmx/defaults/JmxProperties.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/defaults/JmxProperties.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-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
@@ -177,18 +177,6 @@
             "javax.management.relation";
 
     /**
-     * Logger name for Namespaces.
-     */
-    public static final String NAMESPACE_LOGGER_NAME =
-            "javax.management.namespace";
-
-     /**
-     * Logger name for Namespaces.
-     */
-    public static final Logger NAMESPACE_LOGGER =
-            Logger.getLogger(NAMESPACE_LOGGER_NAME);
-
-    /**
      * Logger for Relation Service.
      */
     public static final Logger RELATION_LOGGER =
--- a/src/share/classes/com/sun/jmx/defaults/ServiceName.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/defaults/ServiceName.java	Wed Nov 25 11:08:25 2009 -0800
@@ -69,9 +69,9 @@
     /**
      * The version of the JMX specification implemented by this product.
      * <BR>
-     * The value is <CODE>2.0</CODE>.
+     * The value is <CODE>1.4</CODE>.
      */
-    public static final String JMX_SPEC_VERSION = "2.0";
+    public static final String JMX_SPEC_VERSION = "1.4";
 
     /**
      * The vendor of the JMX specification implemented by this product.
--- a/src/share/classes/com/sun/jmx/event/DaemonThreadFactory.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class DaemonThreadFactory implements ThreadFactory {
-    public DaemonThreadFactory(String nameTemplate) {
-        this(nameTemplate, null);
-    }
-
-    // nameTemplate should be a format with %d in it, which will be replaced
-    // by a sequence number of threads created by this factory.
-    public DaemonThreadFactory(String nameTemplate, ThreadGroup threadGroup) {
-        if (logger.debugOn()) {
-            logger.debug("DaemonThreadFactory",
-                    "Construct a new daemon factory: "+nameTemplate);
-        }
-
-        if (threadGroup == null) {
-            SecurityManager s = System.getSecurityManager();
-            threadGroup = (s != null) ? s.getThreadGroup() :
-                                  Thread.currentThread().getThreadGroup();
-        }
-
-        this.nameTemplate = nameTemplate;
-        this.threadGroup = threadGroup;
-    }
-
-    public Thread newThread(Runnable r) {
-        final String name =
-                String.format(nameTemplate, threadNumber.getAndIncrement());
-        Thread t = new Thread(threadGroup, r, name, 0);
-        t.setDaemon(true);
-        if (t.getPriority() != Thread.NORM_PRIORITY)
-            t.setPriority(Thread.NORM_PRIORITY);
-
-        if (logger.debugOn()) {
-            logger.debug("newThread",
-                    "Create a new daemon thread with the name "+t.getName());
-        }
-
-        return t;
-    }
-
-    private final String nameTemplate;
-    private final ThreadGroup threadGroup;
-    private final AtomicInteger threadNumber = new AtomicInteger(1);
-
-    private static final ClassLogger logger =
-        new ClassLogger("com.sun.jmx.event", "DaemonThreadFactory");
-}
--- a/src/share/classes/com/sun/jmx/event/EventBuffer.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,252 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.management.remote.NotificationResult;
-import javax.management.remote.TargetedNotification;
-
-public class EventBuffer {
-
-    public EventBuffer() {
-        this(Integer.MAX_VALUE, null);
-    }
-
-    public EventBuffer(int capacity) {
-        this(capacity, new ArrayList<TargetedNotification>());
-    }
-
-    public EventBuffer(int capacity, final List<TargetedNotification> list) {
-        if (logger.traceOn()) {
-            logger.trace("EventBuffer", "New buffer with the capacity: "
-                    +capacity);
-        }
-        if (capacity < 1) {
-            throw new IllegalArgumentException(
-                    "The capacity must be bigger than 0");
-        }
-
-        if (list == null) {
-            throw new NullPointerException("Null list.");
-        }
-
-        this.capacity = capacity;
-        this.list = list;
-    }
-
-    public void add(TargetedNotification tn) {
-        if (logger.traceOn()) {
-            logger.trace("add", "Add one notif.");
-        }
-
-        synchronized(lock) {
-            if (list.size() == capacity) { // have to throw one
-                passed++;
-                list.remove(0);
-
-                if (logger.traceOn()) {
-                    logger.trace("add", "Over, remove the oldest one.");
-                }
-            }
-
-            list.add(tn);
-            lock.notify();
-        }
-    }
-
-    public void add(TargetedNotification[] tns) {
-        if (tns == null || tns.length == 0) {
-            return;
-        }
-
-        if (logger.traceOn()) {
-            logger.trace("add", "Add notifs: "+tns.length);
-        }
-
-        synchronized(lock) {
-            final int d = list.size() - capacity + tns.length;
-            if (d > 0) { // have to throw
-                passed += d;
-                if (logger.traceOn()) {
-                    logger.trace("add",
-                            "Over, remove the oldest: "+d);
-                }
-                if (tns.length <= capacity){
-                    list.subList(0, d).clear();
-                } else {
-                    list.clear();
-                    TargetedNotification[] tmp =
-                            new TargetedNotification[capacity];
-                    System.arraycopy(tns, tns.length-capacity, tmp, 0, capacity);
-                    tns = tmp;
-                }
-            }
-
-            Collections.addAll(list,tns);
-            lock.notify();
-        }
-    }
-
-    public NotificationResult fetchNotifications(long startSequenceNumber,
-            long timeout,
-            int maxNotifications) {
-        if (logger.traceOn()) {
-            logger.trace("fetchNotifications",
-                    "Being called: "
-                    +startSequenceNumber+" "
-                    +timeout+" "+maxNotifications);
-        }
-        if (startSequenceNumber < 0 ||
-                timeout < 0 ||
-                maxNotifications < 0) {
-            throw new IllegalArgumentException("Negative value.");
-        }
-
-        TargetedNotification[] tns = new TargetedNotification[0];
-        long earliest = startSequenceNumber < passed ?
-            passed : startSequenceNumber;
-        long next = earliest;
-
-        final long startTime = System.currentTimeMillis();
-        long toWait = timeout;
-        synchronized(lock) {
-            int toSkip = (int)(startSequenceNumber - passed);
-
-            // skip those before startSequenceNumber.
-            while (!closed && toSkip > 0) {
-                toWait = timeout - (System.currentTimeMillis() - startTime);
-                if (list.size() == 0) {
-                    if (toWait <= 0) {
-                        // the notification of startSequenceNumber
-                        // does not arrive yet.
-                        return new NotificationResult(startSequenceNumber,
-                                startSequenceNumber,
-                                new TargetedNotification[0]);
-                    }
-
-                    waiting(toWait);
-                    continue;
-                }
-
-                if (toSkip <= list.size()) {
-                    list.subList(0, toSkip).clear();
-                    passed += toSkip;
-
-                    break;
-                } else {
-                    passed += list.size();
-                    toSkip -= list.size();
-
-                    list.clear();
-                }
-            }
-
-            earliest = passed;
-
-            if (list.size() == 0) {
-                toWait = timeout - (System.currentTimeMillis() - startTime);
-
-                waiting(toWait);
-            }
-
-            if (list.size() == 0) {
-                tns = new TargetedNotification[0];
-            } else if (list.size() <= maxNotifications) {
-                tns = list.toArray(new TargetedNotification[0]);
-            } else {
-                tns = new TargetedNotification[maxNotifications];
-                for (int i=0; i<maxNotifications; i++) {
-                    tns[i] = list.get(i);
-                }
-            }
-
-            next = earliest + tns.length;
-        }
-
-        if (logger.traceOn()) {
-            logger.trace("fetchNotifications",
-                    "Return: "+earliest+" "+next+" "+tns.length);
-        }
-
-        return new NotificationResult(earliest, next, tns);
-    }
-
-    public int size() {
-        return list.size();
-    }
-
-    public void addLost(long nb) {
-        synchronized(lock) {
-            passed += nb;
-        }
-    }
-
-    public void close() {
-        if (logger.traceOn()) {
-            logger.trace("clear", "done");
-        }
-
-        synchronized(lock) {
-            list.clear();
-            closed = true;
-            lock.notifyAll();
-        }
-    }
-
-
-    // -------------------------------------------
-    // private classes
-    // -------------------------------------------
-    private void waiting(long timeout) {
-        final long startTime = System.currentTimeMillis();
-        long toWait = timeout;
-        synchronized(lock) {
-            while (!closed && list.size() == 0 && toWait > 0) {
-                try {
-                    lock.wait(toWait);
-
-                    toWait = timeout - (System.currentTimeMillis() - startTime);
-                } catch (InterruptedException ire) {
-                    logger.trace("waiting", ire);
-                    break;
-                }
-            }
-        }
-    }
-
-    private final int capacity;
-    private final List<TargetedNotification> list;
-    private boolean closed;
-
-    private long passed = 0;
-    private final int[] lock = new int[0];
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "EventBuffer");
-}
--- a/src/share/classes/com/sun/jmx/event/EventClientFactory.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import javax.management.event.*;
-
-/**
- * Implemented by objects which are using an {@link EventClient} to
- * subscribe for Notifications.
- *
- */
-public interface EventClientFactory {
-    /**
-     * Returns the {@code EventClient} that the object implementing this
-     * interface uses to subscribe for Notifications. This method returns
-     * {@code null} if no {@code EventClient} can be used - e.g. because
-     * the underlying server does not have any {@link EventDelegate}.
-     *
-     * @return an {@code EventClient} or {@code null}.
-     **/
-    public EventClient getEventClient();
-
-}
--- a/src/share/classes/com/sun/jmx/event/EventConnection.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright 2002-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.jmx.event;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import javax.management.MBeanServerConnection;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventConsumer;
-import javax.management.event.NotificationManager;
-
-/**
- * Override the methods related to the notification to use the
- * Event service.
- */
-public interface EventConnection extends MBeanServerConnection, EventConsumer {
-    public EventClient getEventClient();
-
-    public static class Factory {
-        public static EventConnection make(
-                final MBeanServerConnection mbsc,
-                final EventClient eventClient)
-                throws IOException {
-            if (!mbsc.isRegistered(EventClientDelegate.OBJECT_NAME)) {
-                throw new IOException(
-                        "The server does not support the event service.");
-            }
-            InvocationHandler ih = new InvocationHandler() {
-                public Object invoke(Object proxy, Method method, Object[] args)
-                        throws Throwable {
-                    Class<?> intf = method.getDeclaringClass();
-                    try {
-                        if (intf.isInstance(eventClient))
-                            return method.invoke(eventClient, args);
-                        else
-                            return method.invoke(mbsc, args);
-                    } catch (InvocationTargetException e) {
-                        throw e.getCause();
-                    }
-                }
-            };
-            // It is important to declare NotificationManager.class first
-            // in the array below, so that the relevant addNL and removeNL
-            // methods will show up with method.getDeclaringClass() as
-            // being from that interface and not MBeanServerConnection.
-            return (EventConnection) Proxy.newProxyInstance(
-                    NotificationManager.class.getClassLoader(),
-                    new Class<?>[] {
-                        NotificationManager.class, EventConnection.class,
-                    },
-                    ih);
-        }
-    }
-}
--- a/src/share/classes/com/sun/jmx/event/EventParams.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import com.sun.jmx.mbeanserver.GetPropertyAction;
-import com.sun.jmx.remote.util.ClassLogger;
-import java.security.AccessController;
-import javax.management.event.EventClient;
-
-/**
- *
- * @author sjiang
- */
-public class EventParams {
-    public static final String DEFAULT_LEASE_TIMEOUT =
-            "com.sun.event.lease.time";
-
-
-    @SuppressWarnings("cast") // cast for jdk 1.5
-    public static long getLeaseTimeout() {
-        long timeout = EventClient.DEFAULT_REQUESTED_LEASE_TIME;
-        try {
-            final GetPropertyAction act =
-                  new GetPropertyAction(DEFAULT_LEASE_TIMEOUT);
-            final String s = (String)AccessController.doPrivileged(act);
-            if (s != null) {
-                timeout = Long.parseLong(s);
-            }
-        } catch (RuntimeException e) {
-            logger.fine("getLeaseTimeout", "exception getting property", e);
-        }
-
-        return timeout;
-    }
-
-    /** Creates a new instance of EventParams */
-    private EventParams() {
-    }
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "EventParams");
-}
--- a/src/share/classes/com/sun/jmx/event/LeaseManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-
-/**
- * <p>Manage a renewable lease.  The lease can be renewed indefinitely
- * but if the lease runs to its current expiry date without being renewed
- * then the expiry callback is invoked.  If the lease has already expired
- * when renewal is attempted then the lease method returns zero.</p>
- * @author sjiang
- * @author emcmanus
- */
-// The synchronization logic of this class is tricky to deal correctly with the
-// case where the lease expires at the same time as the |lease| or |stop| method
-// is called.  If the lease is active then the field |scheduled| represents
-// the expiry task; otherwise |scheduled| is null.  Renewing or stopping the
-// lease involves canceling this task and setting |scheduled| either to a new
-// task (to renew) or to null (to stop).
-//
-// Suppose the expiry task runs at the same time as the |lease| method is called.
-// If the task enters its synchronized block before the method starts, then
-// it will set |scheduled| to null and the method will return 0.  If the method
-// starts before the task enters its synchronized block, then the method will
-// cancel the task which will see that when it later enters the block.
-// Similar reasoning applies to the |stop| method.  It is not expected that
-// different threads will call |lease| or |stop| simultaneously, although the
-// logic should be correct then too.
-public class LeaseManager {
-    public LeaseManager(Runnable callback) {
-        this(callback, EventParams.getLeaseTimeout());
-    }
-
-    public LeaseManager(Runnable callback, long timeout) {
-        if (logger.traceOn()) {
-            logger.trace("LeaseManager", "new manager with lease: "+timeout);
-        }
-        if (callback == null) {
-            throw new NullPointerException("Null callback.");
-        }
-        if (timeout <= 0)
-            throw new IllegalArgumentException("Timeout must be positive: " + timeout);
-
-        this.callback = callback;
-        schedule(timeout);
-    }
-
-    /**
-     * <p>Renew the lease for the given time.  The new time can be shorter
-     * than the previous one, in which case the lease will expire earlier
-     * than it would have.</p>
-     *
-     * <p>Calling this method after the lease has expired will return zero
-     * immediately and have no other effect.</p>
-     *
-     * @param timeout the new lifetime.  If zero, the lease
-     * will expire immediately.
-     */
-    public synchronized long lease(long timeout) {
-        if (logger.traceOn()) {
-            logger.trace("lease", "new lease to: "+timeout);
-        }
-
-        if (timeout < 0)
-            throw new IllegalArgumentException("Negative lease: " + timeout);
-
-        if (scheduled == null)
-            return 0L;
-
-        scheduled.cancel(false);
-
-        if (logger.traceOn())
-            logger.trace("lease", "start lease: "+timeout);
-        schedule(timeout);
-
-        return timeout;
-    }
-
-    private class Expire implements Runnable {
-        ScheduledFuture<?> task;
-
-        public void run() {
-            synchronized (LeaseManager.this) {
-                if (task.isCancelled())
-                    return;
-                scheduled = null;
-            }
-            callback.run();
-            executor.shutdown();
-        }
-    }
-
-    private synchronized void schedule(long timeout) {
-        Expire expire = new Expire();
-        scheduled = executor.schedule(expire, timeout, TimeUnit.MILLISECONDS);
-        expire.task = scheduled;
-    }
-
-    /**
-     * <p>Cancel the lease without calling the expiry callback.</p>
-     */
-    public synchronized void stop() {
-        logger.trace("stop", "canceling lease");
-        scheduled.cancel(false);
-        scheduled = null;
-        try {
-            executor.shutdown();
-        } catch (SecurityException e) {
-            // OK: caller doesn't have RuntimePermission("modifyThread")
-            // which is unlikely in reality but triggers a test failure otherwise
-            logger.trace("stop", "exception from executor.shutdown", e);
-        }
-    }
-
-    private final Runnable callback;
-    private ScheduledFuture<?> scheduled;  // If null, the lease has expired.
-
-    private static final ThreadFactory threadFactory =
-            new DaemonThreadFactory("JMX LeaseManager %d");
-    private final ScheduledExecutorService executor
-            = Executors.newScheduledThreadPool(1, threadFactory);
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "LeaseManager");
-
-}
--- a/src/share/classes/com/sun/jmx/event/LeaseRenewer.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-/**
- *
- * @author sjiang
- */
-public class LeaseRenewer {
-    public LeaseRenewer(ScheduledExecutorService scheduler, Callable<Long> doRenew) {
-        if (logger.traceOn()) {
-            logger.trace("LeaseRenewer", "New LeaseRenewer.");
-        }
-
-        if (doRenew == null) {
-            throw new NullPointerException("Null job to call server.");
-        }
-
-        this.doRenew = doRenew;
-        nextRenewTime = System.currentTimeMillis();
-
-        this.scheduler = scheduler;
-        future = this.scheduler.schedule(myRenew, 0, TimeUnit.MILLISECONDS);
-    }
-
-    public void close() {
-        if (logger.traceOn()) {
-            logger.trace("close", "Close the lease.");
-        }
-
-        synchronized(lock) {
-            if (closed) {
-                return;
-            } else {
-                closed = true;
-            }
-        }
-
-        try {
-            future.cancel(false); // not interrupt if running
-        } catch (Exception e) {
-            // OK
-            if (logger.debugOn()) {
-                logger.debug("close", "Failed to cancel the leasing job.", e);
-            }
-        }
-    }
-
-    public boolean closed() {
-        synchronized(lock) {
-            return closed;
-        }
-    }
-
-    // ------------------------------
-    // private
-    // ------------------------------
-    private final Runnable myRenew = new Runnable() {
-        public void run() {
-            synchronized(lock) {
-                if (closed()) {
-                    return;
-                }
-            }
-
-            long next = nextRenewTime - System.currentTimeMillis();
-            if (next < MIN_MILLIS) {
-                try {
-                    if (logger.traceOn()) {
-                        logger.trace("myRenew-run", "");
-                    }
-                    next = doRenew.call().longValue();
-
-                } catch (Exception e) {
-                    logger.fine("myRenew-run", "Failed to renew lease", e);
-                    close();
-                }
-
-                if (next > 0 && next < Long.MAX_VALUE) {
-                    next = next/2;
-                    next = (next < MIN_MILLIS) ? MIN_MILLIS : next;
-                } else {
-                    close();
-                }
-            }
-
-            nextRenewTime = System.currentTimeMillis() + next;
-
-            if (logger.traceOn()) {
-                logger.trace("myRenew-run", "Next leasing: "+next);
-            }
-
-            synchronized(lock) {
-                if (!closed) {
-                    future = scheduler.schedule(this, next, TimeUnit.MILLISECONDS);
-                }
-            }
-        }
-    };
-
-    private final Callable<Long> doRenew;
-    private ScheduledFuture<?> future;
-    private boolean closed = false;
-    private long nextRenewTime;
-
-    private final int[] lock = new int[0];
-
-    private final ScheduledExecutorService scheduler;
-
-    private static final long MIN_MILLIS = 50;
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "LeaseRenewer");
-}
--- a/src/share/classes/com/sun/jmx/event/ReceiverBuffer.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.management.remote.NotificationResult;
-import javax.management.remote.TargetedNotification;
-
-
-public class ReceiverBuffer {
-    public void addNotifs(NotificationResult nr) {
-        if (nr == null) {
-            return;
-        }
-
-        TargetedNotification[] tns = nr.getTargetedNotifications();
-
-        if (logger.traceOn()) {
-            logger.trace("addNotifs", "" + tns.length);
-        }
-
-        long impliedStart = nr.getEarliestSequenceNumber();
-        final long missed = impliedStart - start;
-        start = nr.getNextSequenceNumber();
-
-        if (missed > 0) {
-            if (logger.traceOn()) {
-                logger.trace("addNotifs",
-                        "lost: "+missed);
-            }
-
-            lost += missed;
-        }
-
-        Collections.addAll(notifList, nr.getTargetedNotifications());
-    }
-
-    public TargetedNotification[] removeNotifs() {
-        if (logger.traceOn()) {
-            logger.trace("removeNotifs", String.valueOf(notifList.size()));
-        }
-
-        if (notifList.size() == 0) {
-            return null;
-        }
-
-        TargetedNotification[] ret = notifList.toArray(
-                new TargetedNotification[]{});
-        notifList.clear();
-
-        return ret;
-    }
-
-    public int size() {
-        return notifList.size();
-    }
-
-    public int removeLost() {
-        int ret = lost;
-        lost = 0;
-        return ret;
-    }
-
-    private List<TargetedNotification> notifList
-            = new ArrayList<TargetedNotification>();
-    private long start = 0;
-    private int lost = 0;
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "ReceiverBuffer");
-}
--- a/src/share/classes/com/sun/jmx/event/RepeatedSingletonJob.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.util.concurrent.Executor;
-import java.util.concurrent.RejectedExecutionException;
-
-/**
- * <p>A task that is repeatedly run by an Executor.  The task will be
- * repeated as long as the {@link #isSuspended()} method returns true.  Once
- * that method returns false, the task is no longer executed until someone
- * calls {@link #resume()}.</p>
- * @author sjiang
- */
-public abstract class RepeatedSingletonJob implements Runnable {
-    public RepeatedSingletonJob(Executor executor) {
-        if (executor == null) {
-            throw new NullPointerException("Null executor!");
-        }
-
-        this.executor = executor;
-    }
-
-    public boolean isWorking() {
-        return working;
-    }
-
-    public void resume() {
-
-        synchronized(this) {
-            if (!working)  {
-                if (logger.traceOn()) {
-                    logger.trace("resume", "");
-                }
-                working = true;
-                execute();
-            }
-        }
-    }
-
-    public abstract void task();
-    public abstract boolean isSuspended();
-
-    public void run() {
-        if (logger.traceOn()) {
-            logger.trace("run", "execute the task");
-        }
-        try {
-            task();
-        } catch (Exception e) {
-            // A correct task() implementation should not throw exceptions.
-            // It may cause isSuspended() to start returning true, though.
-            logger.trace("run", "failed to execute the task", e);
-        }
-
-        synchronized(this) {
-            if (!isSuspended()) {
-                execute();
-            } else {
-                if (logger.traceOn()) {
-                    logger.trace("run", "suspend the task");
-                }
-                working = false;
-            }
-        }
-
-    }
-
-    private void execute() {
-        try {
-            executor.execute(this);
-        } catch (RejectedExecutionException e) {
-            logger.warning(
-                    "execute",
-                    "Executor threw exception (" + this.getClass().getName() + ")",
-                    e);
-            throw new RejectedExecutionException(
-                    "Executor.execute threw exception -" +
-                    "should not be possible", e);
-            // User-supplied Executor should not be configured in a way that
-            // might cause this exception, for example if it is shared between
-            // several client objects and doesn't have capacity for one job
-            // from each one.  CR 6732037 will add text to the spec explaining
-            // the problem.  The rethrown exception will propagate either out
-            // of resume() to user code, or out of run() to the Executor
-            // (which will probably ignore it).
-        }
-    }
-
-    private boolean working = false;
-    private final Executor executor;
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "RepeatedSingletonJob");
-}
--- a/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java	Wed Nov 25 11:08:25 2009 -0800
@@ -30,16 +30,15 @@
 import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
 import com.sun.jmx.mbeanserver.DynamicMBean2;
 import com.sun.jmx.mbeanserver.Introspector;
-import com.sun.jmx.mbeanserver.MBeanInjector;
 import com.sun.jmx.mbeanserver.MBeanInstantiator;
 import com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository;
 import com.sun.jmx.mbeanserver.NamedObject;
-import com.sun.jmx.mbeanserver.NotifySupport;
 import com.sun.jmx.mbeanserver.Repository;
 import com.sun.jmx.mbeanserver.Repository.RegistrationContext;
 import com.sun.jmx.mbeanserver.Util;
 import com.sun.jmx.remote.util.EnvHelp;
 
+import java.io.ObjectInputStream;
 import java.lang.ref.WeakReference;
 import java.security.AccessControlContext;
 import java.security.AccessController;
@@ -48,10 +47,7 @@
 import java.security.ProtectionDomain;
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.Queue;
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.logging.Level;
@@ -61,7 +57,6 @@
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
 import javax.management.DynamicMBean;
-import javax.management.DynamicWrapperMBean;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.IntrospectionException;
@@ -70,7 +65,6 @@
 import javax.management.ListenerNotFoundException;
 import javax.management.MBeanException;
 import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanPermission;
 import javax.management.MBeanRegistration;
 import javax.management.MBeanRegistrationException;
@@ -81,19 +75,19 @@
 import javax.management.NotCompliantMBeanException;
 import javax.management.Notification;
 import javax.management.NotificationBroadcaster;
-import javax.management.NotificationBroadcasterSupport;
 import javax.management.NotificationEmitter;
 import javax.management.NotificationFilter;
 import javax.management.NotificationListener;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
+import javax.management.OperationsException;
 import javax.management.QueryEval;
 import javax.management.QueryExp;
 import javax.management.ReflectionException;
 import javax.management.RuntimeErrorException;
 import javax.management.RuntimeMBeanException;
 import javax.management.RuntimeOperationsException;
-import javax.management.namespace.JMXNamespace;
+import javax.management.loading.ClassLoaderRepository;
 
 /**
  * This is the default class for MBean manipulation on the agent side. It
@@ -116,8 +110,7 @@
  *
  * @since 1.5
  */
-public class DefaultMBeanServerInterceptor
-        extends MBeanServerInterceptorSupport {
+public class DefaultMBeanServerInterceptor implements MBeanServerInterceptor {
 
     /** The MBeanInstantiator object used by the
      *  DefaultMBeanServerInterceptor */
@@ -142,14 +135,9 @@
                 new WeakHashMap<ListenerWrapper,
                                 WeakReference<ListenerWrapper>>();
 
-    private final NamespaceDispatchInterceptor dispatcher;
-
     /** The default domain of the object names */
     private final String domain;
 
-    /** The mbeanServerName  */
-    private final String mbeanServerName;
-
     /** The sequence number identifying the notifications sent */
     // Now sequence number is handled by MBeanServerDelegate.
     // private int sequenceNumber=0;
@@ -168,13 +156,11 @@
      * @param instantiator The MBeanInstantiator that will be used to
      *        instantiate MBeans and take care of class loading issues.
      * @param repository The repository to use for this MBeanServer.
-     * @param dispatcher The dispatcher used by this MBeanServer
      */
     public DefaultMBeanServerInterceptor(MBeanServer         outer,
                                          MBeanServerDelegate delegate,
                                          MBeanInstantiator   instantiator,
-                                         Repository          repository,
-                                         NamespaceDispatchInterceptor dispatcher)  {
+                                         Repository          repository) {
         if (outer == null) throw new
             IllegalArgumentException("outer MBeanServer cannot be null");
         if (delegate == null) throw new
@@ -189,8 +175,6 @@
         this.instantiator = instantiator;
         this.repository   = repository;
         this.domain       = repository.getDefaultDomain();
-        this.dispatcher   = dispatcher;
-        this.mbeanServerName = Util.getMBeanServerSecurityName(delegate);
     }
 
     public ObjectInstance createMBean(String className, ObjectName name)
@@ -269,8 +253,8 @@
             name = nonDefaultDomain(name);
         }
 
-        checkMBeanPermission(mbeanServerName,className, null, null, "instantiate");
-        checkMBeanPermission(mbeanServerName,className, null, name, "registerMBean");
+        checkMBeanPermission(className, null, null, "instantiate");
+        checkMBeanPermission(className, null, name, "registerMBean");
 
         /* Load the appropriate class. */
         if (withDefaultLoaderRepository) {
@@ -334,7 +318,7 @@
 
         final String infoClassName = getNewMBeanClassName(object);
 
-        checkMBeanPermission(mbeanServerName,infoClassName, null, name, "registerMBean");
+        checkMBeanPermission(infoClassName, null, name, "registerMBean");
         checkMBeanTrustPermission(theClass);
 
         return registerObject(infoClassName, object, name);
@@ -443,8 +427,7 @@
         DynamicMBean instance = getMBean(name);
         // may throw InstanceNotFoundException
 
-        checkMBeanPermission(mbeanServerName, instance, null, name,
-                "unregisterMBean");
+        checkMBeanPermission(instance, null, name, "unregisterMBean");
 
         if (instance instanceof MBeanRegistration)
             preDeregisterInvoke((MBeanRegistration) instance);
@@ -478,8 +461,7 @@
         name = nonDefaultDomain(name);
         DynamicMBean instance = getMBean(name);
 
-        checkMBeanPermission(mbeanServerName,
-                instance, null, name, "getObjectInstance");
+        checkMBeanPermission(instance, null, name, "getObjectInstance");
 
         final String className = getClassName(instance);
 
@@ -491,7 +473,7 @@
         if (sm != null) {
             // Check if the caller has the right to invoke 'queryMBeans'
             //
-            checkMBeanPermission(mbeanServerName,(String) null, null, null, "queryMBeans");
+            checkMBeanPermission((String) null, null, null, "queryMBeans");
 
             // Perform query without "query".
             //
@@ -504,7 +486,7 @@
                 new HashSet<ObjectInstance>(list.size());
             for (ObjectInstance oi : list) {
                 try {
-                    checkMBeanPermission(mbeanServerName,oi.getClassName(), null,
+                    checkMBeanPermission(oi.getClassName(), null,
                                          oi.getObjectName(), "queryMBeans");
                     allowedList.add(oi);
                 } catch (SecurityException e) {
@@ -537,7 +519,7 @@
         if (sm != null) {
             // Check if the caller has the right to invoke 'queryNames'
             //
-            checkMBeanPermission(mbeanServerName,(String) null, null, null, "queryNames");
+            checkMBeanPermission((String) null, null, null, "queryNames");
 
             // Perform query without "query".
             //
@@ -550,7 +532,7 @@
                 new HashSet<ObjectInstance>(list.size());
             for (ObjectInstance oi : list) {
                 try {
-                    checkMBeanPermission(mbeanServerName, oi.getClassName(), null,
+                    checkMBeanPermission(oi.getClassName(), null,
                                          oi.getObjectName(), "queryNames");
                     allowedList.add(oi);
                 } catch (SecurityException e) {
@@ -602,7 +584,7 @@
         if (sm != null) {
             // Check if the caller has the right to invoke 'getDomains'
             //
-            checkMBeanPermission(mbeanServerName, (String) null, null, null, "getDomains");
+            checkMBeanPermission((String) null, null, null, "getDomains");
 
             // Return domains
             //
@@ -614,8 +596,8 @@
             List<String> result = new ArrayList<String>(domains.length);
             for (int i = 0; i < domains.length; i++) {
                 try {
-                    ObjectName dom = ObjectName.valueOf(domains[i] + ":x=x");
-                    checkMBeanPermission(mbeanServerName, (String) null, null, dom, "getDomains");
+                    ObjectName dom = Util.newObjectName(domains[i] + ":x=x");
+                    checkMBeanPermission((String) null, null, dom, "getDomains");
                     result.add(domains[i]);
                 } catch (SecurityException e) {
                     // OK: Do not add this domain to the list
@@ -659,8 +641,7 @@
         }
 
         final DynamicMBean instance = getMBean(name);
-        checkMBeanPermission(mbeanServerName, instance, attribute,
-                name, "getAttribute");
+        checkMBeanPermission(instance, attribute, name, "getAttribute");
 
         try {
             return instance.getAttribute(attribute);
@@ -705,7 +686,7 @@
 
             // Check if the caller has the right to invoke 'getAttribute'
             //
-            checkMBeanPermission(mbeanServerName, classname, null, name, "getAttribute");
+            checkMBeanPermission(classname, null, name, "getAttribute");
 
             // Check if the caller has the right to invoke 'getAttribute'
             // on each specific attribute
@@ -714,8 +695,7 @@
                 new ArrayList<String>(attributes.length);
             for (String attr : attributes) {
                 try {
-                    checkMBeanPermission(mbeanServerName, classname, attr,
-                                         name, "getAttribute");
+                    checkMBeanPermission(classname, attr, name, "getAttribute");
                     allowedList.add(attr);
                 } catch (SecurityException e) {
                     // OK: Do not add this attribute to the list
@@ -760,8 +740,7 @@
         }
 
         DynamicMBean instance = getMBean(name);
-        checkMBeanPermission(mbeanServerName, instance, attribute.getName(),
-                             name, "setAttribute");
+        checkMBeanPermission(instance, attribute.getName(), name, "setAttribute");
 
         try {
             instance.setAttribute(attribute);
@@ -803,7 +782,7 @@
 
             // Check if the caller has the right to invoke 'setAttribute'
             //
-            checkMBeanPermission(mbeanServerName, classname, null, name, "setAttribute");
+            checkMBeanPermission(classname, null, name, "setAttribute");
 
             // Check if the caller has the right to invoke 'setAttribute'
             // on each specific attribute
@@ -811,7 +790,7 @@
             allowedAttributes = new AttributeList(attributes.size());
             for (Attribute attribute : attributes.asList()) {
                 try {
-                    checkMBeanPermission(mbeanServerName, classname, attribute.getName(),
+                    checkMBeanPermission(classname, attribute.getName(),
                                          name, "setAttribute");
                     allowedAttributes.add(attribute);
                 } catch (SecurityException e) {
@@ -835,8 +814,7 @@
         name = nonDefaultDomain(name);
 
         DynamicMBean instance = getMBean(name);
-        checkMBeanPermission(mbeanServerName, instance, operationName,
-                name, "invoke");
+        checkMBeanPermission(instance, operationName, name, "invoke");
         try {
             return instance.invoke(operationName, params, signature);
         } catch (Throwable t) {
@@ -919,12 +897,6 @@
 
         DynamicMBean mbean = Introspector.makeDynamicMBean(object);
 
-        //Access the ObjectName template value only if the provided name is null
-        if(name == null) {
-            name = Introspector.templateToObjectName(mbean.getMBeanInfo().
-                    getDescriptor(), mbean);
-        }
-
         return registerDynamicMBean(classname, mbean, name);
     }
 
@@ -953,8 +925,6 @@
         ResourceContext context = null;
 
         try {
-            mbean = injectResources(mbean, server, logicalName);
-
             if (mbean instanceof DynamicMBean2) {
                 try {
                     ((DynamicMBean2) mbean).preRegister2(server, logicalName);
@@ -973,8 +943,7 @@
                         ObjectName.getInstance(nonDefaultDomain(logicalName));
             }
 
-            checkMBeanPermission(mbeanServerName, classname, null, logicalName,
-                    "registerMBean");
+            checkMBeanPermission(classname, null, logicalName, "registerMBean");
 
             if (logicalName == null) {
                 final RuntimeException wrapped =
@@ -988,10 +957,9 @@
             // Register the MBean with the repository.
             // Returns the resource context that was used.
             // The returned context does nothing for regular MBeans.
-            // For ClassLoader MBeans and JMXNamespace (and JMXDomain)
-            // MBeans - the context makes it possible to register these
+            // For ClassLoader MBeans the context makes it possible to register these
             // objects with the appropriate framework artifacts, such as
-            // the CLR or the dispatcher, from within the repository lock.
+            // the CLR, from within the repository lock.
             // In case of success, we also need to call context.done() at the
             // end of this method.
             //
@@ -1045,27 +1013,6 @@
         else return name;
     }
 
-    private static DynamicMBean injectResources(
-            DynamicMBean mbean, MBeanServer mbs, ObjectName name)
-    throws MBeanRegistrationException {
-        try {
-            Object resource = getResource(mbean);
-            MBeanInjector.inject(resource, mbs, name);
-            if (MBeanInjector.injectsSendNotification(resource)) {
-                MBeanNotificationInfo[] mbnis =
-                        mbean.getMBeanInfo().getNotifications();
-                NotificationBroadcasterSupport nbs =
-                        new NotificationBroadcasterSupport(mbnis);
-                MBeanInjector.injectSendNotification(resource, nbs);
-                mbean = NotifySupport.wrap(mbean, nbs);
-            }
-            return mbean;
-        } catch (Throwable t) {
-            throwMBeanRegistrationException(t, "injecting @Resources");
-            return null;  // not reached
-        }
-    }
-
     private static void postRegister(
             ObjectName logicalName, DynamicMBean mbean,
             boolean registrationDone, boolean registerFailed) {
@@ -1151,19 +1098,12 @@
     }
 
     private static Object getResource(DynamicMBean mbean) {
-        if (mbean instanceof DynamicWrapperMBean)
-            return ((DynamicWrapperMBean) mbean).getWrappedObject();
+        if (mbean instanceof DynamicMBean2)
+            return ((DynamicMBean2) mbean).getResource();
         else
             return mbean;
     }
 
-    private static ClassLoader getResourceLoader(DynamicMBean mbean) {
-        if (mbean instanceof DynamicWrapperMBean)
-            return ((DynamicWrapperMBean) mbean).getWrappedClassLoader();
-        else
-            return mbean.getClass().getClassLoader();
-    }
-
     private ObjectName nonDefaultDomain(ObjectName name) {
         if (name == null || name.getDomain().length() > 0)
             return name;
@@ -1177,7 +1117,7 @@
            if one is supplied where it shouldn't be).  */
         final String completeName = domain + name;
 
-        return ObjectName.valueOf(completeName);
+        return Util.newObjectName(completeName);
     }
 
     public String getDefaultDomain()  {
@@ -1243,8 +1183,7 @@
         }
 
         DynamicMBean instance = getMBean(name);
-        checkMBeanPermission(mbeanServerName, instance, null,
-                name, "addNotificationListener");
+        checkMBeanPermission(instance, null, name, "addNotificationListener");
 
         NotificationBroadcaster broadcaster =
                 getNotificationBroadcaster(name, instance,
@@ -1381,8 +1320,7 @@
         }
 
         DynamicMBean instance = getMBean(name);
-        checkMBeanPermission(mbeanServerName, instance, null, name,
-                             "removeNotificationListener");
+        checkMBeanPermission(instance, null, name, "removeNotificationListener");
 
         /* We could simplify the code by assigning broadcaster after
            assigning listenerWrapper, but that would change the error
@@ -1415,8 +1353,8 @@
                                          Class<T> reqClass) {
         if (reqClass.isInstance(instance))
             return reqClass.cast(instance);
-        if (instance instanceof DynamicWrapperMBean)
-            instance = ((DynamicWrapperMBean) instance).getWrappedObject();
+        if (instance instanceof DynamicMBean2)
+            instance = ((DynamicMBean2) instance).getResource();
         if (reqClass.isInstance(instance))
             return reqClass.cast(instance);
         final RuntimeException exc =
@@ -1452,7 +1390,7 @@
             throw new JMRuntimeException("MBean " + name +
                                          "has no MBeanInfo");
 
-        checkMBeanPermission(mbeanServerName, mbi.getClassName(), null, name, "getMBeanInfo");
+        checkMBeanPermission(mbi.getClassName(), null, name, "getMBeanInfo");
 
         return mbi;
     }
@@ -1461,8 +1399,7 @@
         throws InstanceNotFoundException {
 
         final DynamicMBean instance = getMBean(name);
-        checkMBeanPermission(mbeanServerName,
-                instance, null, name, "isInstanceOf");
+        checkMBeanPermission(instance, null, name, "isInstanceOf");
 
         try {
             Object resource = getResource(instance);
@@ -1474,20 +1411,12 @@
 
             if (resourceClassName.equals(className))
                 return true;
-            final ClassLoader cl = getResourceLoader(instance);
+            final ClassLoader cl = resource.getClass().getClassLoader();
 
             final Class<?> classNameClass = Class.forName(className, false, cl);
             if (classNameClass.isInstance(resource))
                 return true;
 
-            // Ensure that isInstanceOf(NotificationEmitter) is true when
-            // the MBean is a NotificationEmitter by virtue of a @Resource
-            // annotation specifying a SendNotification resource.
-            // This is a hack.
-            if (instance instanceof NotificationBroadcaster &&
-                    classNameClass.isAssignableFrom(NotificationEmitter.class))
-                return true;
-
             final Class<?> resourceClass = Class.forName(resourceClassName, false, cl);
             return classNameClass.isAssignableFrom(resourceClass);
         } catch (Exception x) {
@@ -1513,9 +1442,8 @@
         throws InstanceNotFoundException {
 
         DynamicMBean instance = getMBean(mbeanName);
-        checkMBeanPermission(mbeanServerName, instance, null, mbeanName,
-                "getClassLoaderFor");
-        return getResourceLoader(instance);
+        checkMBeanPermission(instance, null, mbeanName, "getClassLoaderFor");
+        return getResource(instance).getClass().getClassLoader();
     }
 
     /**
@@ -1529,13 +1457,12 @@
             throws InstanceNotFoundException {
 
         if (loaderName == null) {
-            checkMBeanPermission(mbeanServerName, (String) null, null, null, "getClassLoader");
+            checkMBeanPermission((String) null, null, null, "getClassLoader");
             return server.getClass().getClassLoader();
         }
 
         DynamicMBean instance = getMBean(loaderName);
-        checkMBeanPermission(mbeanServerName, instance, null, loaderName,
-                "getClassLoader");
+        checkMBeanPermission(instance, null, loaderName, "getClassLoader");
 
         Object resource = getResource(instance);
 
@@ -1757,6 +1684,49 @@
         }
     }
 
+    public Object instantiate(String className) throws ReflectionException,
+                                                       MBeanException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public Object instantiate(String className, ObjectName loaderName) throws ReflectionException,
+                                                                              MBeanException,
+                                                                              InstanceNotFoundException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public Object instantiate(String className, Object[] params,
+            String[] signature) throws ReflectionException, MBeanException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public Object instantiate(String className, ObjectName loaderName,
+            Object[] params, String[] signature) throws ReflectionException,
+                                                        MBeanException,
+                                                        InstanceNotFoundException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public ObjectInputStream deserialize(ObjectName name, byte[] data) throws InstanceNotFoundException,
+                                                                              OperationsException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException,
+                                                                               ReflectionException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public ObjectInputStream deserialize(String className, ObjectName loaderName,
+            byte[] data) throws InstanceNotFoundException, OperationsException,
+                                ReflectionException {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
+    public ClassLoaderRepository getClassLoaderRepository() {
+        throw new UnsupportedOperationException("Not supported yet.");
+    }
+
     private static class ListenerWrapper implements NotificationListener {
         ListenerWrapper(NotificationListener l, ObjectName name,
                         Object mbean) {
@@ -1834,30 +1804,26 @@
             return mbean.getMBeanInfo().getClassName();
     }
 
-    private static void checkMBeanPermission(String mbeanServerName,
-                                             DynamicMBean mbean,
+    private static void checkMBeanPermission(DynamicMBean mbean,
                                              String member,
                                              ObjectName objectName,
                                              String actions) {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            checkMBeanPermission(mbeanServerName,
-                                 safeGetClassName(mbean),
+            checkMBeanPermission(safeGetClassName(mbean),
                                  member,
                                  objectName,
                                  actions);
         }
     }
 
-    private static void checkMBeanPermission(String mbeanServerName,
-                                             String classname,
+    private static void checkMBeanPermission(String classname,
                                              String member,
                                              ObjectName objectName,
                                              String actions) {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            Permission perm = new MBeanPermission(mbeanServerName,
-                                                  classname,
+            Permission perm = new MBeanPermission(classname,
                                                   member,
                                                   objectName,
                                                   actions);
@@ -1923,12 +1889,6 @@
             throws InstanceAlreadyExistsException,
             MBeanRegistrationException {
 
-        // this will throw an exception if the pair (resource, logicalName)
-        // violates namespace conventions - for instance, if logicalName
-        // ends with // but resource is not a JMXNamespace.
-        //
-        checkResourceObjectNameConstraints(resource, logicalName);
-
         // Creates a registration context, if needed.
         //
         final ResourceContext context =
@@ -1996,56 +1956,6 @@
 
 
     /**
-     * Checks that the ObjectName is legal with regards to the
-     * type of the MBean resource.
-     * If the MBean name is  domain:type=JMXDomain, the
-     *     MBean must be a JMXDomain.
-     * If the MBean name is  namespace//:type=JMXNamespace, the
-     *     MBean must be a JMXNamespace.
-     * If the MBean is a JMXDomain, its name
-     *      must be domain:type=JMXDomain.
-     * If the MBean is a JMXNamespace,  its name
-     *      must be namespace//:type=JMXNamespace.
-     */
-    private void checkResourceObjectNameConstraints(Object resource,
-            ObjectName logicalName)
-            throws MBeanRegistrationException {
-        try {
-            dispatcher.checkLocallyRegistrable(resource, logicalName);
-        } catch (Throwable x) {
-            DefaultMBeanServerInterceptor.throwMBeanRegistrationException(x, "validating ObjectName");
-        }
-    }
-
-    /**
-     * Registers a JMXNamespace with the dispatcher.
-     * This method is called by the ResourceContext from within the
-     * repository lock.
-     * @param namespace    The JMXNamespace
-     * @param logicalName  The JMXNamespaceMBean ObjectName
-     * @param postQueue    A queue that will be processed after postRegister.
-     */
-    private void addJMXNamespace(JMXNamespace namespace,
-            final ObjectName logicalName,
-            final Queue<Runnable> postQueue) {
-        dispatcher.addInterceptorFor(logicalName, namespace, postQueue);
-    }
-
-    /**
-     * Unregisters a JMXNamespace from the dispatcher.
-     * This method is called by the ResourceContext from within the
-     * repository lock.
-     * @param namespace    The JMXNamespace
-     * @param logicalName  The JMXNamespaceMBean ObjectName
-     * @param postQueue    A queue that will be processed after postDeregister.
-     */
-    private void removeJMXNamespace(JMXNamespace namespace,
-            final ObjectName logicalName,
-            final Queue<Runnable> postQueue) {
-        dispatcher.removeInterceptorFor(logicalName, namespace, postQueue);
-    }
-
-    /**
      * Registers a ClassLoader with the CLR.
      * This method is called by the ResourceContext from within the
      * repository lock.
@@ -2100,51 +2010,6 @@
 
 
     /**
-     * Creates a ResourceContext for a JMXNamespace MBean.
-     * The resource context makes it possible to add the JMXNamespace to
-     * (ResourceContext.registering) or resp. remove the JMXNamespace from
-     * (ResourceContext.unregistered) the NamespaceDispatchInterceptor
-     * when the associated MBean is added to or resp. removed from the
-     * repository.
-     * Note: JMXDomains are special sub classes of JMXNamespaces and
-     *       are also handled by this object.
-     *
-     * @param namespace    The JMXNamespace MBean being registered or
-     *                     unregistered.
-     * @param logicalName  The name of the JMXNamespace MBean.
-     * @return a ResourceContext that takes in charge the addition or removal
-     *         of the namespace to or from the NamespaceDispatchInterceptor.
-     */
-    private ResourceContext createJMXNamespaceContext(
-            final JMXNamespace namespace,
-            final ObjectName logicalName) {
-        final Queue<Runnable> doneTaskQueue = new LinkedList<Runnable>();
-        return new ResourceContext() {
-
-            public void registering() {
-                addJMXNamespace(namespace, logicalName, doneTaskQueue);
-            }
-
-            public void unregistered() {
-                removeJMXNamespace(namespace, logicalName,
-                                   doneTaskQueue);
-            }
-
-            public void done() {
-                for (Runnable r : doneTaskQueue) {
-                    try {
-                        r.run();
-                    } catch (RuntimeException x) {
-                        MBEANSERVER_LOGGER.log(Level.FINE,
-                                "Failed to process post queue for "+
-                                logicalName, x);
-                    }
-                }
-            }
-        };
-    }
-
-    /**
      * Creates a ResourceContext for a ClassLoader MBean.
      * The resource context makes it possible to add the ClassLoader to
      * (ResourceContext.registering) or resp. remove the ClassLoader from
@@ -2180,8 +2045,7 @@
      * Creates a ResourceContext for the given resource.
      * If the resource does not need a ResourceContext, returns
      * ResourceContext.NONE.
-     * At this time, only JMXNamespaces and ClassLoaders need a
-     * ResourceContext.
+     * At this time, only ClassLoaders need a ResourceContext.
      *
      * @param resource     The resource being registered or unregistered.
      * @param logicalName  The name of the associated MBean.
@@ -2189,10 +2053,6 @@
      */
     private ResourceContext makeResourceContextFor(Object resource,
             ObjectName logicalName) {
-        if (resource instanceof JMXNamespace) {
-            return createJMXNamespaceContext((JMXNamespace) resource,
-                    logicalName);
-        }
         if (resource instanceof ClassLoader) {
             return createClassLoaderContext((ClassLoader) resource,
                     logicalName);
--- a/src/share/classes/com/sun/jmx/interceptor/DispatchInterceptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,551 +0,0 @@
-/*
- * 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.jmx.interceptor;
-
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.namespace.JMXNamespace;
-
-/**
- * A dispatcher that dispatches to MBeanServers.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-//
-// This is the base class for implementing dispatchers. We have two concrete
-// dispatcher implementations:
-//
-//   * A NamespaceDispatchInterceptor, which dispatch calls to existing
-//     namespace interceptors
-//   * A DomainDispatchInterceptor, which dispatch calls to existing domain
-//     interceptors.
-//
-// With the JMX Namespaces feature, the JMX MBeanServer is now structured
-// as follows:
-//
-// The JMX MBeanServer delegates to a NamespaceDispatchInterceptor,
-// which either dispatches to a namespace, or delegates to the
-// DomainDispatchInterceptor (if the object name contained no namespace).
-// The DomainDispatchInterceptor in turn either dispatches to a domain (if
-// there is a JMXDomain for that domain) or delegates to the
-// DefaultMBeanServerInterceptor (if there is no JMXDomain for that
-// domain). This makes the following picture:
-//
-//             JMX MBeanServer (outer shell)
-//                          |
-//                          |
-//              NamespaceDispatchInterceptor
-//                   /               \
-//     no namespace in object name?   \
-//                 /                   \
-//                /                   dispatch to namespace
-//         DomainDispatchInterceptor
-//              /              \
-//    no JMXDomain for domain?  \
-//            /                  \
-//           /                   dispatch to domain
-//  DefaultMBeanServerInterceptor
-//         /
-//   invoke locally registered MBean
-//
-//  The logic for maintaining a map of interceptors
-//  and dispatching to impacted interceptor, is implemented in this
-//  base class, which both NamespaceDispatchInterceptor and
-//  DomainDispatchInterceptor extend.
-//
-public abstract class DispatchInterceptor
-        <T extends MBeanServer, N extends JMXNamespace>
-        extends MBeanServerInterceptorSupport {
-
-    /**
-     * This is an abstraction which allows us to handle queryNames
-     * and queryMBeans with the same algorithm. There are some subclasses
-     * where we need to override both queryNames & queryMBeans to apply
-     * the same transformation (usually aggregation of results when
-     * several namespaces/domains are impacted) to both algorithms.
-     * Usually the only thing that varies between the algorithm of
-     * queryNames & the algorithm of queryMBean is the type of objects
-     * in the returned Set. By using a QueryInvoker we can implement the
-     * transformation only once and apply it to both queryNames &
-     * queryMBeans.
-     * @see QueryInterceptor below, and its subclass in
-     * {@link DomainDispatcher}.
-     **/
-    static abstract class QueryInvoker<T> {
-        abstract Set<T> query(MBeanServer mbs,
-                        ObjectName pattern, QueryExp query);
-    }
-
-    /**
-     * Used to perform queryNames. A QueryInvoker that invokes
-     * queryNames on an MBeanServer.
-     **/
-    final static QueryInvoker<ObjectName> queryNamesInvoker =
-            new QueryInvoker<ObjectName>() {
-        Set<ObjectName> query(MBeanServer mbs,
-                        ObjectName pattern, QueryExp query) {
-            return mbs.queryNames(pattern,query);
-        }
-    };
-
-    /**
-     * Used to perform queryMBeans. A QueryInvoker that invokes
-     * queryMBeans on an MBeanServer.
-     **/
-    final static QueryInvoker<ObjectInstance> queryMBeansInvoker =
-            new QueryInvoker<ObjectInstance>() {
-        Set<ObjectInstance> query(MBeanServer mbs,
-                        ObjectName pattern, QueryExp query) {
-            return mbs.queryMBeans(pattern,query);
-        }
-    };
-
-    /**
-     * We use this class to intercept queries.
-     * There's a special case for JMXNamespace MBeans, because
-     * "namespace//*:*" matches both "namespace//domain:k=v" and
-     * "namespace//:type=JMXNamespace".
-     * Therefore, queries may need to be forwarded to more than
-     * on interceptor and the results aggregated...
-     */
-     static class QueryInterceptor {
-        final MBeanServer wrapped;
-        QueryInterceptor(MBeanServer mbs) {
-            wrapped = mbs;
-        }
-        <X> Set<X> query(ObjectName pattern, QueryExp query,
-                QueryInvoker<X> invoker, MBeanServer server) {
-            return invoker.query(server, pattern, query);
-        }
-
-        public Set<ObjectName> queryNames(ObjectName pattern, QueryExp query) {
-            return query(pattern,query,queryNamesInvoker,wrapped);
-        }
-
-        public Set<ObjectInstance> queryMBeans(ObjectName pattern,
-                QueryExp query) {
-            return query(pattern,query,queryMBeansInvoker,wrapped);
-        }
-    }
-
-    // We don't need a ConcurrentHashMap here because getkeys() returns
-    // an array of keys. Therefore there's no risk to have a
-    // ConcurrentModificationException. We must however take into
-    // account the fact that there can be no interceptor for
-    // some of the returned keys if the map is being modified by
-    // another thread, or by a callback within the same thread...
-    // See getKeys() in this class and query() in DomainDispatcher.
-    //
-    private final Map<String,T> handlerMap =
-            Collections.synchronizedMap(
-            new HashMap<String,T>());
-
-    // The key at which an interceptor for accessing the named MBean can be
-    // found in the handlerMap. Note: there doesn't need to be an interceptor
-    // for that key in the Map.
-    //
-    abstract String getHandlerKey(ObjectName name);
-
-    // Returns an interceptor for that name, or null if there's no interceptor
-    // for that name.
-    abstract MBeanServer getInterceptorOrNullFor(ObjectName name);
-
-    // Returns a QueryInterceptor for that pattern.
-    abstract QueryInterceptor getInterceptorForQuery(ObjectName pattern);
-
-    // Returns the ObjectName of the JMXNamespace (or JMXDomain) for that
-    // key (a namespace or a domain name).
-    abstract ObjectName getHandlerNameFor(String key);
-
-    // Creates an interceptor for the given key, name, JMXNamespace (or
-    // JMXDomain). Note: this will be either a NamespaceInterceptor
-    // wrapping a JMXNamespace, if this object is an instance of
-    // NamespaceDispatchInterceptor, or a DomainInterceptor wrapping a
-    // JMXDomain, if this object is an instance of DomainDispatchInterceptor.
-    abstract T createInterceptorFor(String key, ObjectName name,
-            N jmxNamespace, Queue<Runnable> postRegisterQueue);
-    //
-    // The next interceptor in the chain.
-    //
-    // For the NamespaceDispatchInterceptor, this the DomainDispatchInterceptor.
-    // For the DomainDispatchInterceptor, this is the
-    // DefaultMBeanServerInterceptor.
-    //
-    // The logic of when to invoke the next interceptor in the chain depends
-    // on the logic of the concrete dispatcher class.
-    //
-    // For instance, the NamespaceDispatchInterceptor invokes the next
-    // interceptor when the object name doesn't contain any namespace.
-    //
-    // On the other hand, the DomainDispatchInterceptor invokes the
-    // next interceptor when there's no interceptor for the accessed domain.
-    //
-    abstract MBeanServer getNextInterceptor();
-
-    // hook for cleanup in subclasses.
-    void interceptorReleased(T interceptor,
-            Queue<Runnable> postDeregisterQueue) {
-        // hook
-    }
-
-    // Hook for subclasses.
-    MBeanServer getInterceptorForCreate(ObjectName name)
-        throws MBeanRegistrationException {
-        final MBeanServer ns = getInterceptorOrNullFor(name);
-        if (ns == null) // name cannot be null here.
-            throw new MBeanRegistrationException(
-                    new IllegalArgumentException("No such MBean handler: " +
-                        getHandlerKey(name) + " for " +name));
-        return ns;
-    }
-
-    // Hook for subclasses.
-    MBeanServer getInterceptorForInstance(ObjectName name)
-        throws InstanceNotFoundException {
-        final MBeanServer ns = getInterceptorOrNullFor(name);
-        if (ns == null) // name cannot be null here.
-            throw new InstanceNotFoundException(String.valueOf(name));
-        return ns;
-    }
-
-    // sanity checks
-    void validateHandlerNameFor(String key, ObjectName name) {
-        if (key == null || key.equals(""))
-            throw new IllegalArgumentException("invalid key for "+name+": "+key);
-        final ObjectName handlerName = getHandlerNameFor(key);
-        if (!name.equals(handlerName))
-            throw new IllegalArgumentException("bad handler name: "+name+
-                    ". Should be: "+handlerName);
-    }
-
-    // Called by the DefaultMBeanServerInterceptor when an instance
-    // of JMXNamespace (or a subclass of it) is registered as an MBean.
-    // This method is usually invoked from within the repository lock,
-    // hence the necessity of the postRegisterQueue.
-    public void addInterceptorFor(ObjectName name, N jmxNamespace,
-            Queue<Runnable> postRegisterQueue) {
-        final String key = getHandlerKey(name);
-        validateHandlerNameFor(key,name);
-        synchronized (handlerMap) {
-            final T exists =
-                    handlerMap.get(key);
-            if (exists != null)
-                throw new IllegalArgumentException(key+
-                        ": handler already exists");
-
-            final T ns = createInterceptorFor(key,name,jmxNamespace,
-                    postRegisterQueue);
-            handlerMap.put(key,ns);
-        }
-    }
-
-    // Called by the DefaultMBeanServerInterceptor when an instance
-    // of JMXNamespace (or a subclass of it) is deregistered.
-    // This method is usually invoked from within the repository lock,
-    // hence the necessity of the postDeregisterQueue.
-    public void removeInterceptorFor(ObjectName name, N jmxNamespace,
-            Queue<Runnable> postDeregisterQueue) {
-        final String key = getHandlerKey(name);
-        final T ns;
-        synchronized(handlerMap) {
-            ns = handlerMap.remove(key);
-        }
-        interceptorReleased(ns,postDeregisterQueue);
-    }
-
-    // Get the interceptor for that key.
-    T getInterceptor(String key) {
-        synchronized (handlerMap) {
-            return handlerMap.get(key);
-        }
-    }
-
-    // We return an array of keys, which makes it possible to make
-    // concurrent modifications of the handlerMap, provided that
-    // the code which loops over the keys is prepared to handle null
-    // interceptors.
-    // See declaration of handlerMap above, and see also query() in
-    // DomainDispatcher
-    //
-    public String[] getKeys() {
-        synchronized (handlerMap) {
-            final int size = handlerMap.size();
-            return handlerMap.keySet().toArray(new String[size]);
-        }
-    }
-
-    // From MBeanServer
-    public final ObjectInstance createMBean(String className, ObjectName name)
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException {
-        return getInterceptorForCreate(name).createMBean(className,name);
-    }
-
-    // From MBeanServer
-    public final ObjectInstance createMBean(String className, ObjectName name,
-                                      ObjectName loaderName)
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException, InstanceNotFoundException{
-        return getInterceptorForCreate(name).createMBean(className,name,loaderName);
-    }
-
-    // From MBeanServer
-    public final ObjectInstance createMBean(String className, ObjectName name,
-                                      Object params[], String signature[])
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException{
-        return getInterceptorForCreate(name).
-                createMBean(className,name,params,signature);
-    }
-
-    // From MBeanServer
-    public final ObjectInstance createMBean(String className, ObjectName name,
-                                      ObjectName loaderName, Object params[],
-                                      String signature[])
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException, InstanceNotFoundException{
-        return getInterceptorForCreate(name).createMBean(className,name,loaderName,
-                                                   params,signature);
-    }
-
-    // From MBeanServer
-    public final ObjectInstance registerMBean(Object object, ObjectName name)
-            throws InstanceAlreadyExistsException, MBeanRegistrationException,
-                   NotCompliantMBeanException {
-        return getInterceptorForCreate(name).registerMBean(object,name);
-    }
-
-    // From MBeanServer
-    public final void unregisterMBean(ObjectName name)
-            throws InstanceNotFoundException, MBeanRegistrationException {
-        getInterceptorForInstance(name).unregisterMBean(name);
-    }
-
-    // From MBeanServer
-    public final ObjectInstance getObjectInstance(ObjectName name)
-            throws InstanceNotFoundException {
-        return getInterceptorForInstance(name).getObjectInstance(name);
-    }
-
-    // From MBeanServer
-    public final Set<ObjectInstance> queryMBeans(ObjectName name,
-            QueryExp query) {
-        final QueryInterceptor queryInvoker =
-                getInterceptorForQuery(name);
-        if (queryInvoker == null)  return Collections.emptySet();
-        else return queryInvoker.queryMBeans(name,query);
-    }
-
-    // From MBeanServer
-    public final Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-        final QueryInterceptor queryInvoker =
-                getInterceptorForQuery(name);
-        if (queryInvoker == null)  return Collections.emptySet();
-        else return queryInvoker.queryNames(name,query);
-    }
-
-    // From MBeanServer
-    public final boolean isRegistered(ObjectName name) {
-        final MBeanServer mbs = getInterceptorOrNullFor(name);
-        if (mbs == null) return false;
-        else return mbs.isRegistered(name);
-    }
-
-    // From MBeanServer
-    public Integer getMBeanCount() {
-        return getNextInterceptor().getMBeanCount();
-    }
-
-    // From MBeanServer
-    public final Object getAttribute(ObjectName name, String attribute)
-            throws MBeanException, AttributeNotFoundException,
-                   InstanceNotFoundException, ReflectionException {
-        return getInterceptorForInstance(name).getAttribute(name,attribute);
-    }
-
-    // From MBeanServer
-    public final AttributeList getAttributes(ObjectName name,
-            String[] attributes)
-            throws InstanceNotFoundException, ReflectionException {
-        return getInterceptorForInstance(name).getAttributes(name,attributes);
-    }
-
-    // From MBeanServer
-    public final void setAttribute(ObjectName name, Attribute attribute)
-            throws InstanceNotFoundException, AttributeNotFoundException,
-                   InvalidAttributeValueException, MBeanException,
-                   ReflectionException {
-        getInterceptorForInstance(name).setAttribute(name,attribute);
-    }
-
-    // From MBeanServer
-    public final AttributeList setAttributes(ObjectName name,
-                                       AttributeList attributes)
-        throws InstanceNotFoundException, ReflectionException {
-        return getInterceptorForInstance(name).setAttributes(name,attributes);
-    }
-
-    // From MBeanServer
-    public final Object invoke(ObjectName name, String operationName,
-                         Object params[], String signature[])
-            throws InstanceNotFoundException, MBeanException,
-                   ReflectionException {
-        return getInterceptorForInstance(name).invoke(name,operationName,params,
-                signature);
-    }
-
-    // From MBeanServer
-    public String getDefaultDomain() {
-        return getNextInterceptor().getDefaultDomain();
-    }
-
-    /**
-     * Returns the list of domains in which any MBean is currently
-     * registered.
-     */
-    public abstract String[] getDomains();
-
-    // From MBeanServer
-    public final void addNotificationListener(ObjectName name,
-                                        NotificationListener listener,
-                                        NotificationFilter filter,
-                                        Object handback)
-            throws InstanceNotFoundException {
-        getInterceptorForInstance(name).
-                addNotificationListener(name,listener,filter,
-                handback);
-    }
-
-
-    // From MBeanServer
-    public final void addNotificationListener(ObjectName name,
-                                        ObjectName listener,
-                                        NotificationFilter filter,
-                                        Object handback)
-            throws InstanceNotFoundException {
-        getInterceptorForInstance(name).
-                addNotificationListener(name,listener,filter,
-                handback);
-    }
-
-    // From MBeanServer
-    public final void removeNotificationListener(ObjectName name,
-                                           ObjectName listener)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        getInterceptorForInstance(name).
-                removeNotificationListener(name,listener);
-    }
-
-    // From MBeanServer
-    public final void removeNotificationListener(ObjectName name,
-                                           ObjectName listener,
-                                           NotificationFilter filter,
-                                           Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        getInterceptorForInstance(name).
-                removeNotificationListener(name,listener,filter,
-                handback);
-    }
-
-
-    // From MBeanServer
-    public final void removeNotificationListener(ObjectName name,
-                                           NotificationListener listener)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        getInterceptorForInstance(name).
-                removeNotificationListener(name,listener);
-    }
-
-    // From MBeanServer
-    public final void removeNotificationListener(ObjectName name,
-                                           NotificationListener listener,
-                                           NotificationFilter filter,
-                                           Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        getInterceptorForInstance(name).
-                removeNotificationListener(name,listener,filter,
-                handback);
-    }
-
-    // From MBeanServer
-    public final MBeanInfo getMBeanInfo(ObjectName name)
-            throws InstanceNotFoundException, IntrospectionException,
-                   ReflectionException {
-        return getInterceptorForInstance(name).getMBeanInfo(name);
-    }
-
-
-    // From MBeanServer
-    public final boolean isInstanceOf(ObjectName name, String className)
-            throws InstanceNotFoundException {
-        return getInterceptorForInstance(name).isInstanceOf(name,className);
-    }
-
-    // From MBeanServer
-    public final ClassLoader getClassLoaderFor(ObjectName mbeanName)
-        throws InstanceNotFoundException {
-        return getInterceptorForInstance(mbeanName).
-                getClassLoaderFor(mbeanName);
-    }
-
-    // From MBeanServer
-    public final ClassLoader getClassLoader(ObjectName loaderName)
-        throws InstanceNotFoundException {
-        return getInterceptorForInstance(loaderName).
-                getClassLoader(loaderName);
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/interceptor/DomainDispatchInterceptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,350 +0,0 @@
-/*
- * 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.jmx.interceptor;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.mbeanserver.MBeanInstantiator;
-import com.sun.jmx.mbeanserver.Repository;
-import com.sun.jmx.mbeanserver.Util;
-import com.sun.jmx.namespace.DomainInterceptor;
-import java.util.Queue;
-import java.util.Set;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.namespace.JMXDomain;
-import static javax.management.namespace.JMXNamespaces.NAMESPACE_SEPARATOR;
-
-/**
- * A dispatcher that dispatch incoming MBeanServer requests to
- * DomainInterceptors.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-//
-// See comments in  DispatchInterceptor.
-//
-class DomainDispatchInterceptor
-        extends DispatchInterceptor<DomainInterceptor, JMXDomain> {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    private static final ObjectName ALL_DOMAINS =
-            JMXDomain.getDomainObjectName("*");
-
-
-    /**
-     *  A QueryInterceptor that perform & aggregates queries spanning several
-     *  domains.
-     */
-    final static class AggregatingQueryInterceptor extends QueryInterceptor {
-
-        private final DomainDispatchInterceptor parent;
-        AggregatingQueryInterceptor(DomainDispatchInterceptor dispatcher) {
-            super(dispatcher.nextInterceptor);
-            parent = dispatcher;
-        }
-
-        /**
-         * Perform queryNames or queryMBeans, depending on which QueryInvoker
-         * is passed as argument. This is closures without closures.
-         **/
-        @Override
-        <T> Set<T> query(ObjectName pattern, QueryExp query,
-                QueryInvoker<T> invoker, MBeanServer localNamespace) {
-            final Set<T> local = invoker.query(localNamespace, pattern, query);
-
-            // Add all matching MBeans from local namespace.
-            final Set<T> res = Util.cloneSet(local);
-
-            if (pattern == null) pattern = ObjectName.WILDCARD;
-            final boolean all = pattern.getDomain().equals("*");
-
-            final String domain = pattern.getDomain();
-
-            // If there's no domain pattern, just include the pattern's domain.
-            // Otherwiae, loop over all virtual domains (parent.getKeys()).
-            final String[] keys =
-                (pattern.isDomainPattern() ?
-                    parent.getKeys() : new String[]{domain});
-
-            // Add all matching MBeans from each virtual domain
-            //
-            for (String key : keys) {
-                // Only invoke those virtual domain which are selected
-                // by the domain pattern
-                //
-                if (!all && !Util.isDomainSelected(key, domain))
-                    continue;
-
-                try {
-                    final MBeanServer mbs = parent.getInterceptor(key);
-
-                    // mbs can be null if the interceptor was removed
-                    // concurrently...
-                    // See handlerMap and getKeys() in DispatchInterceptor
-                    //
-                    if (mbs == null) continue;
-
-                    // If the domain is selected, we can replace the pattern
-                    // by the actual domain. This is safer if we want to avoid
-                    // a domain (which could be backed up by an MBeanServer) to
-                    // return names from outside the domain.
-                    // So instead of asking the domain handler for "foo" to
-                    // return all names which match "?o*:type=Bla,*" we're
-                    // going to ask it to return all names which match
-                    // "foo:type=Bla,*"
-                    //
-                    final ObjectName subPattern = pattern.withDomain(key);
-                    res.addAll(invoker.query(mbs, subPattern, query));
-                } catch (Exception x) {
-                    LOG.finest("Ignoring exception " +
-                            "when attempting to query namespace "+key+": "+x);
-                    continue;
-                }
-            }
-            return res;
-        }
-    }
-
-    private final DefaultMBeanServerInterceptor nextInterceptor;
-    private final String mbeanServerName;
-    private final MBeanServerDelegate delegate;
-
-    /**
-     * Creates a DomainDispatchInterceptor with the specified
-     * repository instance.
-     *
-     * @param outer A pointer to the MBeanServer object that must be
-     *        passed to the MBeans when invoking their
-     *        {@link javax.management.MBeanRegistration} interface.
-     * @param delegate A pointer to the MBeanServerDelegate associated
-     *        with the new MBeanServer. The new MBeanServer must register
-     *        this MBean in its MBean repository.
-     * @param instantiator The MBeanInstantiator that will be used to
-     *        instantiate MBeans and take care of class loading issues.
-     * @param repository The repository to use for this MBeanServer
-     */
-    public DomainDispatchInterceptor(MBeanServer         outer,
-                            MBeanServerDelegate delegate,
-                            MBeanInstantiator   instantiator,
-                            Repository          repository,
-                            NamespaceDispatchInterceptor namespaces)  {
-           nextInterceptor = new DefaultMBeanServerInterceptor(outer,
-                   delegate, instantiator,repository,namespaces);
-           mbeanServerName = Util.getMBeanServerSecurityName(delegate);
-           this.delegate = delegate;
-    }
-
-    final boolean isLocalHandlerNameFor(String domain,
-            ObjectName handlerName) {
-        if (domain == null) return true;
-        return handlerName.getDomain().equals(domain) &&
-               JMXDomain.TYPE_ASSIGNMENT.equals(
-               handlerName.getKeyPropertyListString());
-    }
-
-    @Override
-    void validateHandlerNameFor(String key, ObjectName name) {
-        super.validateHandlerNameFor(key,name);
-        final String[] domains = nextInterceptor.getDomains();
-        for (int i=0;i<domains.length;i++) {
-            if (domains[i].equals(key))
-                throw new IllegalArgumentException("domain "+key+
-                        " is not empty");
-        }
-    }
-
-    @Override
-    final MBeanServer getInterceptorOrNullFor(ObjectName name) {
-
-        if (name == null) return nextInterceptor;
-
-        final String domain = name.getDomain();
-        if (domain.endsWith(NAMESPACE_SEPARATOR))
-            return nextInterceptor; // This can be a namespace handler.
-        if (domain.contains(NAMESPACE_SEPARATOR))
-            return null; // shouldn't reach here.
-        if (isLocalHandlerNameFor(domain,name)) {
-            // This is the name of a JMXDomain MBean. Return nextInterceptor.
-            LOG.finer("dispatching to local namespace");
-            return nextInterceptor;
-        }
-
-        final DomainInterceptor ns = getInterceptor(domain);
-        if (ns == null) {
-            // no JMXDomain found for that domain - return nextInterceptor.
-            if (LOG.isLoggable(Level.FINER)) {
-                LOG.finer("dispatching to local namespace: " + domain);
-            }
-            return getNextInterceptor();
-        }
-
-        if (LOG.isLoggable(Level.FINER)) {
-            LOG.finer("dispatching to domain: " + domain);
-        }
-        return ns;
-    }
-
-    // This method returns true if the given pattern must be evaluated against
-    // several interceptors. This happens when either:
-    //
-    //   a) the pattern can select several domains (it's null, or it's a
-    //        domain pattern)
-    //   or b) it's not a domain pattern, but it might select the name of a
-    //        JMXDomain MBean in charge of that domain. Since the JMXDomain
-    //        MBean is located in the nextInterceptor, the pattern might need
-    //        to be evaluated on two interceptors.
-    //
-    // 1. When this method returns false, the query is evaluated on a single
-    // interceptor:
-    //    The interceptor for pattern.getDomain(), if there is one,
-    //    or the next interceptor, if there is none.
-    //
-    // 2. When this method returns true, we loop over all the domain
-    // interceptors:
-    //    in the list, and if the domain pattern matches the interceptor domain
-    //    we evaluate the query on that interceptor and aggregate the results.
-    //    Eventually we also evaluate the pattern against the next interceptor.
-    //
-    // See getInterceptorForQuery below.
-    //
-    private boolean multipleQuery(ObjectName pattern) {
-        // case a) above
-        if (pattern == null) return true;
-        if (pattern.isDomainPattern()) return true;
-
-        // case b) above.
-        //
-        // This is a bit of a hack. If there's any chance that a JMXDomain
-        // MBean name is selected by the given pattern then we must include
-        // the local namespace in our search.
-        //
-        // Returning true will have this effect. see 2. above.
-        //
-        if (pattern.apply(ALL_DOMAINS.withDomain(pattern.getDomain())))
-            return true;
-
-        return false;
-    }
-
-    @Override
-    final QueryInterceptor getInterceptorForQuery(ObjectName pattern) {
-
-        // Check if we need to aggregate.
-        if (multipleQuery(pattern))
-            return new AggregatingQueryInterceptor(this);
-
-        // We don't need to aggregate: do the "simple" thing...
-        final String domain = pattern.getDomain();
-
-        // Do we have a virtual domain?
-        final DomainInterceptor ns = getInterceptor(domain);
-        if (ns != null) {
-            if (LOG.isLoggable(Level.FINER))
-                LOG.finer("dispatching to domain: " + domain);
-            return new QueryInterceptor(ns);
-        }
-
-        // We don't have a virtual domain. Send to local domains.
-        if (LOG.isLoggable(Level.FINER))
-             LOG.finer("dispatching to local namespace: " + domain);
-        return new QueryInterceptor(nextInterceptor);
-    }
-
-    @Override
-    final ObjectName getHandlerNameFor(String key) {
-        return JMXDomain.getDomainObjectName(key);
-    }
-
-    @Override
-    final public String getHandlerKey(ObjectName name) {
-        return name.getDomain();
-    }
-
-    @Override
-    final DomainInterceptor createInterceptorFor(String key,
-            ObjectName name, JMXDomain handler,
-            Queue<Runnable> postRegisterQueue) {
-        final DomainInterceptor ns =
-                new DomainInterceptor(mbeanServerName,handler,key);
-        ns.addPostRegisterTask(postRegisterQueue, delegate);
-        if (LOG.isLoggable(Level.FINER)) {
-            LOG.finer("DomainInterceptor created: "+ns);
-        }
-        return ns;
-    }
-
-    @Override
-    final void interceptorReleased(DomainInterceptor interceptor,
-            Queue<Runnable> postDeregisterQueue) {
-        interceptor.addPostDeregisterTask(postDeregisterQueue, delegate);
-    }
-
-    @Override
-    final DefaultMBeanServerInterceptor getNextInterceptor() {
-        return nextInterceptor;
-    }
-
-    /**
-     * Returns the list of domains in which any MBean is currently
-     * registered.
-     */
-    @Override
-    public String[] getDomains() {
-        // A JMXDomain is registered in its own domain.
-        // Therefore, nextInterceptor.getDomains() contains all domains.
-        // In addition, nextInterceptor will perform the necessary
-        // MBeanPermission checks for getDomains().
-        //
-        return nextInterceptor.getDomains();
-    }
-
-    /**
-     * Returns the number of MBeans registered in the MBean server.
-     */
-    @Override
-    public Integer getMBeanCount() {
-        int count = getNextInterceptor().getMBeanCount();
-        final String[] keys = getKeys();
-        for (String key:keys) {
-            final MBeanServer mbs = getInterceptor(key);
-            if (mbs == null) continue;
-            count += mbs.getMBeanCount();
-        }
-        return count;
-    }
-}
--- a/src/share/classes/com/sun/jmx/interceptor/MBeanServerInterceptorSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
- * 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.jmx.interceptor;
-
-import java.io.ObjectInputStream;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.ObjectName;
-import javax.management.OperationsException;
-import javax.management.ReflectionException;
-import javax.management.loading.ClassLoaderRepository;
-
-/**
- * An abstract class for MBeanServerInterceptorSupport.
- * Some methods in MBeanServerInterceptor should never be called.
- * This base class provides an implementation of these methods that simply
- * throw an {@link UnsupportedOperationException}.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public abstract class MBeanServerInterceptorSupport
-        implements MBeanServerInterceptor {
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className)
-            throws ReflectionException, MBeanException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className, ObjectName loaderName)
-            throws ReflectionException, MBeanException,
-            InstanceNotFoundException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className, Object[] params,
-            String[] signature) throws ReflectionException, MBeanException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className, ObjectName loaderName,
-            Object[] params, String[] signature)
-            throws ReflectionException, MBeanException,
-            InstanceNotFoundException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(ObjectName name, byte[] data)
-            throws InstanceNotFoundException, OperationsException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className, byte[] data)
-            throws OperationsException, ReflectionException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className,
-            ObjectName loaderName, byte[] data)
-            throws InstanceNotFoundException, OperationsException,
-            ReflectionException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public ClassLoaderRepository getClassLoaderRepository() {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/interceptor/NamespaceDispatchInterceptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,297 +0,0 @@
-/*
- * 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.jmx.interceptor;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.mbeanserver.MBeanInstantiator;
-import com.sun.jmx.mbeanserver.Repository;
-import com.sun.jmx.mbeanserver.Util;
-import com.sun.jmx.namespace.NamespaceInterceptor;
-
-import java.util.Queue;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-import javax.management.namespace.JMXDomain;
-import javax.management.namespace.JMXNamespace;
-import static javax.management.namespace.JMXNamespaces.NAMESPACE_SEPARATOR;
-
-/**
- * A dispatcher that dispatches to NamespaceInterceptors.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public class NamespaceDispatchInterceptor
-        extends DispatchInterceptor<NamespaceInterceptor, JMXNamespace> {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    private static final int NAMESPACE_SEPARATOR_LENGTH =
-            NAMESPACE_SEPARATOR.length();
-    private static final ObjectName X3 = ObjectName.valueOf("x:x=x");
-
-    private final DomainDispatchInterceptor nextInterceptor;
-    private final String           serverName;
-
-    /**
-     * Creates a NamespaceDispatchInterceptor with the specified
-     * repository instance.
-     * <p>Do not forget to call <code>initialize(outer,delegate)</code>
-     * before using this object.
-     *
-     * @param outer A pointer to the MBeanServer object that must be
-     *        passed to the MBeans when invoking their
-     *        {@link javax.management.MBeanRegistration} interface.
-     * @param delegate A pointer to the MBeanServerDelegate associated
-     *        with the new MBeanServer. The new MBeanServer must register
-     *        this MBean in its MBean repository.
-     * @param instantiator The MBeanInstantiator that will be used to
-     *        instantiate MBeans and take care of class loading issues.
-     * @param repository The repository to use for this MBeanServer
-     */
-    public NamespaceDispatchInterceptor(MBeanServer         outer,
-                               MBeanServerDelegate delegate,
-                               MBeanInstantiator   instantiator,
-                               Repository          repository)  {
-           nextInterceptor = new DomainDispatchInterceptor(outer,delegate,
-                   instantiator,repository,this);
-           serverName = Util.getMBeanServerSecurityName(delegate);
-    }
-
-    /**
-     * Get first name space in ObjectName path. Ignore leading namespace
-     * separators. Includes the trailing //.
-     *
-     * Examples:
-     * <pre>
-     *  For ObjectName:                   Returns:
-     *  foo//bar//baz:x=x         ->      "foo//"
-     *  foo//:type=JMXNamespace   ->      "foo//"
-     *  foo//:x=x                 ->      "foo//"
-     *  foo////:x=x               ->      "foo//"
-     *  //foo//bar//baz:x=x       ->      "//"
-     *  ////foo//bar//baz:x=x     ->      "//"
-     *  //:x=x                    ->      "//"
-     *  foo:x=x                   ->      ""
-     *  (null)                    ->      ""
-     *  :x=x                      ->      ""
-     *
-     * </pre>
-     **/
-    static String getFirstNamespaceWithSlash(ObjectName name) {
-        if (name == null) return "";
-        final String domain = name.getDomain();
-        if (domain.equals("")) return "";
-
-        // go to next separator
-        final int end = domain.indexOf(NAMESPACE_SEPARATOR);
-        if (end == -1) return ""; // no namespace
-
-        // This is the first element in the namespace path.
-        final String namespace =
-                domain.substring(0,end+NAMESPACE_SEPARATOR_LENGTH);
-
-        return namespace;
-    }
-
-    /**
-     * Called by the DefaultMBeanServerInterceptor, just before adding an
-     * MBean to the repository.
-     *
-     * @param resource the MBean to be registered.
-     * @param logicalName the name of the MBean to be registered.
-     */
-    final void checkLocallyRegistrable(Object resource,
-            ObjectName logicalName) {
-        if (!(resource instanceof JMXNamespace) &&
-                logicalName.getDomain().contains(NAMESPACE_SEPARATOR))
-            throw new IllegalArgumentException(String.valueOf(logicalName)+
-                    ": Invalid ObjectName for an instance of " +
-                    resource.getClass().getName());
-    }
-
-    // Removes the trailing //. namespaceWithSlash should be either
-    // "" or a namespace path ending with //.
-    //
-    private final String getKeyFor(String namespaceWithSlash) {
-        final int end = namespaceWithSlash.length() -
-                NAMESPACE_SEPARATOR_LENGTH;
-        if (end <= 0) return "";
-        final String key = namespaceWithSlash.substring(0,end);
-        return key;
-    }
-
-    @Override
-    final MBeanServer getInterceptorOrNullFor(ObjectName name) {
-        final String namespace = getFirstNamespaceWithSlash(name);
-
-        // Leading separators should trigger instance not found exception.
-        // returning null here has this effect.
-        //
-        if (namespace.equals(NAMESPACE_SEPARATOR)) {
-            LOG.finer("ObjectName starts with: "+namespace);
-            return null;
-        }
-
-        // namespace="" means that there was no namespace path in the
-        //   ObjectName. => delegate to the next interceptor (local MBS)
-        // name.getDomain()=namespace means that we have an ObjectName of
-        //   the form blah//:x=x. This is either a JMXNamespace or a non
-        //   existent MBean. => delegate to the next interceptor (local MBS)
-        if (namespace.equals("") || name.getDomain().equals(namespace)) {
-            LOG.finer("dispatching to local name space");
-            return nextInterceptor;
-        }
-
-        // There was a namespace path in the ObjectName. Returns the
-        // interceptor that handles it, or null if there is no such
-        // interceptor.
-        final String key = getKeyFor(namespace);
-        final NamespaceInterceptor ns = getInterceptor(key);
-        if (LOG.isLoggable(Level.FINER)) {
-            if (ns != null) {
-                LOG.finer("dispatching to name space: " + key);
-            } else {
-                LOG.finer("no handler for: " + key);
-            }
-        }
-        return ns;
-    }
-
-    @Override
-    final QueryInterceptor getInterceptorForQuery(ObjectName pattern) {
-        final String namespace = getFirstNamespaceWithSlash(pattern);
-
-        // Leading separators should trigger instance not found exception.
-        // returning null here has this effect.
-        //
-        if (namespace.equals(NAMESPACE_SEPARATOR)) {
-            LOG.finer("ObjectName starts with: "+namespace);
-            return null;
-        }
-
-        // namespace="" means that there was no namespace path in the
-        //   ObjectName. => delegate to the next interceptor (local MBS)
-        // name.getDomain()=namespace means that we have an ObjectName of
-        //   the form blah//:x=x. This is either a JMXNamespace or a non
-        //   existent MBean. => delegate to the next interceptor (local MBS)
-        if (namespace.equals("") || pattern.getDomain().equals(namespace)) {
-            LOG.finer("dispatching to local name space");
-            return new QueryInterceptor(nextInterceptor);
-        }
-
-        // This is a 'hack' to check whether the first namespace is a pattern.
-        // We wan to throw RTOE wrapping IAE in that case
-        if (X3.withDomain(namespace).isDomainPattern()) {
-            throw new RuntimeOperationsException(
-                new IllegalArgumentException("Pattern not allowed in namespace path"));
-        }
-
-        // There was a namespace path in the ObjectName. Returns the
-        // interceptor that handles it, or null if there is no such
-        // interceptor.
-        //
-        final String key = getKeyFor(namespace);
-        final NamespaceInterceptor ns = getInterceptor(key);
-        if (LOG.isLoggable(Level.FINER)) {
-            if (ns != null) {
-                LOG.finer("dispatching to name space: " + key);
-            } else {
-                LOG.finer("no handler for: " + key);
-            }
-        }
-        if (ns == null) return null;
-        return new QueryInterceptor(ns);
-    }
-
-    @Override
-    final ObjectName getHandlerNameFor(String key) {
-        return ObjectName.valueOf(key+NAMESPACE_SEPARATOR,
-                    "type", JMXNamespace.TYPE);
-    }
-
-    @Override
-    final public String getHandlerKey(ObjectName name) {
-        final String namespace = getFirstNamespaceWithSlash(name);
-        // namespace is either "" or a namespace ending with //
-        return getKeyFor(namespace);
-    }
-
-    @Override
-    final NamespaceInterceptor createInterceptorFor(String key,
-            ObjectName name, JMXNamespace handler,
-            Queue<Runnable> postRegisterQueue) {
-        final NamespaceInterceptor ns =
-                new NamespaceInterceptor(serverName,handler,key);
-        if (LOG.isLoggable(Level.FINER)) {
-            LOG.finer("NamespaceInterceptor created: "+ns);
-        }
-        return ns;
-    }
-
-    @Override
-    final DomainDispatchInterceptor getNextInterceptor() {
-        return nextInterceptor;
-    }
-
-    /**
-     * Returns the list of domains in which any MBean is currently
-     * registered.
-     */
-    @Override
-    public String[] getDomains() {
-        return nextInterceptor.getDomains();
-    }
-
-    @Override
-    public void addInterceptorFor(ObjectName name, JMXNamespace handler,
-            Queue<Runnable> postRegisterQueue) {
-        if (handler instanceof JMXDomain)
-            nextInterceptor.addInterceptorFor(name,
-                    (JMXDomain)handler,postRegisterQueue);
-        else super.addInterceptorFor(name,handler,postRegisterQueue);
-    }
-
-    @Override
-    public void removeInterceptorFor(ObjectName name, JMXNamespace handler,
-            Queue<Runnable> postDeregisterQueue) {
-        if (handler instanceof JMXDomain)
-            nextInterceptor.removeInterceptorFor(name,(JMXDomain)handler,
-                    postDeregisterQueue);
-        else super.removeInterceptorFor(name,handler,postDeregisterQueue);
-    }
-
-
-}
--- a/src/share/classes/com/sun/jmx/interceptor/SingleMBeanForwarder.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,442 +0,0 @@
-/*
- * 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.jmx.interceptor;
-
-import com.sun.jmx.mbeanserver.Util;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.MBeanServerSupport;
-import javax.management.remote.IdentityMBeanServerForwarder;
-
-/**
- * <p>An {@link MBeanServerForwarder} that simulates the existence of a
- * given MBean.  Requests for that MBean, call it X, are intercepted by the
- * forwarder, and requests for any other MBean are forwarded to the next
- * forwarder in the chain.  Requests such as queryNames which can span both the
- * X and other MBeans are handled by merging the results for X with the results
- * from the next forwarder, unless the "visible" parameter is false, in which
- * case X is invisible to such requests.</p>
- */
-public class SingleMBeanForwarder extends IdentityMBeanServerForwarder {
-
-    private final ObjectName mbeanName;
-    private final boolean visible;
-    private DynamicMBean mbean;
-
-    private MBeanServer mbeanMBS = new MBeanServerSupport() {
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            if (mbeanName.equals(name)) {
-                return mbean;
-            } else {
-                throw new InstanceNotFoundException(name.toString());
-            }
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            return Collections.singleton(mbeanName);
-        }
-
-        @Override
-        public NotificationEmitter getNotificationEmitterFor(
-                ObjectName name) {
-            if (mbean instanceof NotificationEmitter)
-                return (NotificationEmitter) mbean;
-            return null;
-        }
-
-        // This will only be called if mbeanName has an empty domain.
-        // In that case a getAttribute (e.g.) of that name will have the
-        // domain replaced by MBeanServerSupport with the default domain,
-        // so we must be sure that the default domain is empty too.
-        @Override
-        public String getDefaultDomain() {
-            return mbeanName.getDomain();
-        }
-    };
-
-    public SingleMBeanForwarder(
-            ObjectName mbeanName, DynamicMBean mbean, boolean visible) {
-        this.mbeanName = mbeanName;
-        this.visible = visible;
-        setSingleMBean(mbean);
-    }
-
-    protected void setSingleMBean(DynamicMBean mbean) {
-        this.mbean = mbean;
-    }
-
-    @Override
-    public void addNotificationListener(ObjectName name, ObjectName listener,
-                                         NotificationFilter filter,
-                                         Object handback)
-            throws InstanceNotFoundException {
-        if (mbeanName.equals(name))
-            mbeanMBS.addNotificationListener(name, listener, filter, handback);
-        else
-            super.addNotificationListener(name, listener, filter, handback);
-    }
-
-    @Override
-    public void addNotificationListener(ObjectName name,
-                                         NotificationListener listener,
-                                         NotificationFilter filter,
-                                         Object handback)
-            throws InstanceNotFoundException {
-        if (mbeanName.equals(name))
-            mbeanMBS.addNotificationListener(name, listener, filter, handback);
-        else
-            super.addNotificationListener(name, listener, filter, handback);
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                       ObjectName loaderName, Object[] params,
-                                       String[] signature)
-            throws ReflectionException,
-                   InstanceAlreadyExistsException,
-                   MBeanRegistrationException,
-                   MBeanException,
-                   NotCompliantMBeanException,
-                   InstanceNotFoundException {
-        if (mbeanName.equals(name))
-            throw new InstanceAlreadyExistsException(mbeanName.toString());
-        else
-            return super.createMBean(className, name, loaderName, params, signature);
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                       Object[] params, String[] signature)
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException {
-        if (mbeanName.equals(name))
-            throw new InstanceAlreadyExistsException(mbeanName.toString());
-        return super.createMBean(className, name, params, signature);
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                       ObjectName loaderName)
-            throws ReflectionException,
-                   InstanceAlreadyExistsException,
-                   MBeanRegistrationException,
-                   MBeanException,
-                   NotCompliantMBeanException,
-                   InstanceNotFoundException {
-        if (mbeanName.equals(name))
-            throw new InstanceAlreadyExistsException(mbeanName.toString());
-        return super.createMBean(className, name, loaderName);
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name)
-            throws ReflectionException,
-                   InstanceAlreadyExistsException,
-                   MBeanRegistrationException,
-                   MBeanException,
-                   NotCompliantMBeanException {
-        if (mbeanName.equals(name))
-            throw new InstanceAlreadyExistsException(mbeanName.toString());
-        return super.createMBean(className, name);
-    }
-
-    @Override
-    public Object getAttribute(ObjectName name, String attribute)
-            throws MBeanException,
-                   AttributeNotFoundException,
-                   InstanceNotFoundException,
-                   ReflectionException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.getAttribute(name, attribute);
-        else
-            return super.getAttribute(name, attribute);
-    }
-
-    @Override
-    public AttributeList getAttributes(ObjectName name, String[] attributes)
-            throws InstanceNotFoundException, ReflectionException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.getAttributes(name, attributes);
-        else
-            return super.getAttributes(name, attributes);
-    }
-
-    @Override
-    public ClassLoader getClassLoader(ObjectName loaderName)
-            throws InstanceNotFoundException {
-        if (mbeanName.equals(loaderName))
-            return mbeanMBS.getClassLoader(loaderName);
-        else
-            return super.getClassLoader(loaderName);
-    }
-
-    @Override
-    public ClassLoader getClassLoaderFor(ObjectName name)
-            throws InstanceNotFoundException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.getClassLoaderFor(name);
-        else
-            return super.getClassLoaderFor(name);
-    }
-
-    @Override
-    public String[] getDomains() {
-        String[] domains = super.getDomains();
-        if (!visible)
-            return domains;
-        TreeSet<String> domainSet = new TreeSet<String>(Arrays.asList(domains));
-        domainSet.add(mbeanName.getDomain());
-        return domainSet.toArray(new String[domainSet.size()]);
-    }
-
-    @Override
-    public Integer getMBeanCount() {
-        Integer count = super.getMBeanCount();
-        if (visible && !super.isRegistered(mbeanName))
-            count++;
-        return count;
-    }
-
-    @Override
-    public MBeanInfo getMBeanInfo(ObjectName name)
-            throws InstanceNotFoundException,
-                   IntrospectionException,
-                   ReflectionException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.getMBeanInfo(name);
-        else
-            return super.getMBeanInfo(name);
-    }
-
-    @Override
-    public ObjectInstance getObjectInstance(ObjectName name)
-            throws InstanceNotFoundException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.getObjectInstance(name);
-        else
-            return super.getObjectInstance(name);
-    }
-
-    @Override
-    public Object invoke(ObjectName name, String operationName, Object[] params,
-                          String[] signature)
-            throws InstanceNotFoundException,
-                   MBeanException,
-                   ReflectionException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.invoke(name, operationName, params, signature);
-        else
-            return super.invoke(name, operationName, params, signature);
-    }
-
-    @Override
-    public boolean isInstanceOf(ObjectName name, String className)
-            throws InstanceNotFoundException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.isInstanceOf(name, className);
-        else
-            return super.isInstanceOf(name, className);
-    }
-
-    @Override
-    public boolean isRegistered(ObjectName name) {
-        if (mbeanName.equals(name))
-            return true;
-        else
-            return super.isRegistered(name);
-    }
-
-    /**
-     * This is a ugly hack. Although jmx.context//*:* matches jmx.context//:*
-     * queryNames(jmx.context//*:*,null) must not return jmx.context//:*
-     * @param  pattern the pattern to match against. must not be null.
-     * @return true if mbeanName can be included, false if it must not.
-     */
-    private boolean applies(ObjectName pattern) {
-        // we know pattern is not null.
-        if (!visible || !pattern.apply(mbeanName))
-            return false;
-
-        final String dompat = pattern.getDomain();
-        if (!dompat.contains(JMXNamespaces.NAMESPACE_SEPARATOR))
-            return true; // We already checked that patterns apply.
-
-        if (mbeanName.getDomain().endsWith(JMXNamespaces.NAMESPACE_SEPARATOR)) {
-            // only matches if pattern ends with //
-            return dompat.endsWith(JMXNamespaces.NAMESPACE_SEPARATOR);
-        }
-
-        // should not come here, unless mbeanName contains a // in the
-        // middle of its domain, which would be weird.
-        // let query on mbeanMBS proceed and take care of that.
-        //
-        return true;
-    }
-
-    @Override
-    public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
-        Set<ObjectInstance> names = super.queryMBeans(name, query);
-        if (visible) {
-            if (name == null || applies(name) ) {
-                // Don't assume mbs.queryNames returns a writable set.
-                names = Util.cloneSet(names);
-                names.addAll(mbeanMBS.queryMBeans(name, query));
-            }
-        }
-        return names;
-    }
-
-    @Override
-    public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-        Set<ObjectName> names = super.queryNames(name, query);
-        if (visible) {
-            if (name == null || applies(name)) {
-                // Don't assume mbs.queryNames returns a writable set.
-                names = Util.cloneSet(names);
-                names.addAll(mbeanMBS.queryNames(name, query));
-            }
-        }
-        return names;
-    }
-
-
-    @Override
-    public ObjectInstance registerMBean(Object object, ObjectName name)
-            throws InstanceAlreadyExistsException,
-                   MBeanRegistrationException,
-                   NotCompliantMBeanException {
-        if (mbeanName.equals(name))
-            throw new InstanceAlreadyExistsException(mbeanName.toString());
-        else
-            return super.registerMBean(object, name);
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                                            NotificationListener listener,
-                                            NotificationFilter filter,
-                                            Object handback)
-            throws InstanceNotFoundException,
-                   ListenerNotFoundException {
-        if (mbeanName.equals(name))
-            mbeanMBS.removeNotificationListener(name, listener, filter, handback);
-        else
-            super.removeNotificationListener(name, listener, filter, handback);
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                                            NotificationListener listener)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        if (mbeanName.equals(name))
-            mbeanMBS.removeNotificationListener(name, listener);
-        else
-            super.removeNotificationListener(name, listener);
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name, ObjectName listener,
-                                            NotificationFilter filter,
-                                            Object handback)
-            throws InstanceNotFoundException,
-                   ListenerNotFoundException {
-        if (mbeanName.equals(name))
-            mbeanMBS.removeNotificationListener(name, listener, filter, handback);
-        else
-            super.removeNotificationListener(name, listener, filter, handback);
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name, ObjectName listener)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        if (mbeanName.equals(name))
-            mbeanMBS.removeNotificationListener(name, listener);
-        else
-            super.removeNotificationListener(name, listener);
-    }
-
-    @Override
-    public void setAttribute(ObjectName name, Attribute attribute)
-            throws InstanceNotFoundException,
-                   AttributeNotFoundException,
-                   InvalidAttributeValueException,
-                   MBeanException,
-                   ReflectionException {
-        if (mbeanName.equals(name))
-            mbeanMBS.setAttribute(name, attribute);
-        else
-            super.setAttribute(name, attribute);
-    }
-
-    @Override
-    public AttributeList setAttributes(ObjectName name,
-                                        AttributeList attributes)
-            throws InstanceNotFoundException, ReflectionException {
-        if (mbeanName.equals(name))
-            return mbeanMBS.setAttributes(name, attributes);
-        else
-            return super.setAttributes(name, attributes);
-    }
-
-    @Override
-    public void unregisterMBean(ObjectName name)
-            throws InstanceNotFoundException,
-                   MBeanRegistrationException {
-        if (mbeanName.equals(name))
-            mbeanMBS.unregisterMBean(name);
-        else
-            super.unregisterMBean(name);
-    }
-}
--- a/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/ConvertingMethod.java	Wed Nov 25 11:08:25 2009 -0800
@@ -31,15 +31,13 @@
 
 import javax.management.Descriptor;
 import javax.management.MBeanException;
-import javax.management.openmbean.MXBeanMapping;
-import javax.management.openmbean.MXBeanMappingFactory;
 import javax.management.openmbean.OpenDataException;
 import javax.management.openmbean.OpenType;
 
 final class ConvertingMethod {
-    static ConvertingMethod from(Method m, MXBeanMappingFactory mappingFactory) {
+    static ConvertingMethod from(Method m) {
         try {
-            return new ConvertingMethod(m, mappingFactory);
+            return new ConvertingMethod(m);
         } catch (OpenDataException ode) {
             final String msg = "Method " + m.getDeclaringClass().getName() +
                 "." + m.getName() + " has parameter or return type that " +
@@ -53,7 +51,7 @@
     }
 
     Descriptor getDescriptor() {
-        return Introspector.descriptorForElement(method, false);
+        return Introspector.descriptorForElement(method);
     }
 
     Type getGenericReturnType() {
@@ -206,9 +204,9 @@
         return method.getDeclaringClass() + "." + method.getName();
     }
 
-    private ConvertingMethod(Method m, MXBeanMappingFactory mappingFactory)
-    throws OpenDataException {
+    private ConvertingMethod(Method m) throws OpenDataException {
         this.method = m;
+        MXBeanMappingFactory mappingFactory = MXBeanMappingFactory.DEFAULT;
         returnMapping =
                 mappingFactory.mappingForType(m.getGenericReturnType(), mappingFactory);
         Type[] params = m.getGenericParameterTypes();
--- a/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java	Wed Nov 25 11:08:25 2009 -0800
@@ -28,8 +28,6 @@
 import static com.sun.jmx.mbeanserver.Util.*;
 import static com.sun.jmx.mbeanserver.MXBeanIntrospector.typeName;
 
-import javax.management.openmbean.MXBeanMappingClass;
-
 import static javax.management.openmbean.SimpleType.*;
 
 import com.sun.jmx.remote.util.EnvHelp;
@@ -69,8 +67,6 @@
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.CompositeDataView;
 import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.MXBeanMapping;
-import javax.management.openmbean.MXBeanMappingFactory;
 import javax.management.openmbean.OpenDataException;
 import javax.management.openmbean.OpenType;
 import javax.management.openmbean.SimpleType;
@@ -165,34 +161,29 @@
     private static final class Mappings
         extends WeakHashMap<Type, WeakReference<MXBeanMapping>> {}
 
-    private static final Map<MXBeanMappingFactory, Mappings> factoryMappings =
-            new WeakHashMap<MXBeanMappingFactory, Mappings>();
-
-    private static final Map<Type, MXBeanMapping> permanentMappings = newMap();
+    private static final Mappings mappings = new Mappings();
 
-    private static synchronized MXBeanMapping getMapping(
-            Type type, MXBeanMappingFactory factory) {
-        Mappings mappings = factoryMappings.get(factory);
-        if (mappings == null) {
-            mappings = new Mappings();
-            factoryMappings.put(factory, mappings);
-        }
+    /** Following List simply serves to keep a reference to predefined
+        MXBeanMappings so they don't get garbage collected. */
+    private static final List<MXBeanMapping> permanentMappings = newList();
+
+    private static synchronized MXBeanMapping getMapping(Type type) {
         WeakReference<MXBeanMapping> wr = mappings.get(type);
         return (wr == null) ? null : wr.get();
     }
 
-    private static synchronized void putMapping(
-            Type type, MXBeanMapping mapping, MXBeanMappingFactory factory) {
-        Mappings mappings = factoryMappings.get(factory);
-        if (mappings == null) {
-            mappings = new Mappings();
-            factoryMappings.put(factory, mappings);
-        }
+    private static synchronized void putMapping(Type type, MXBeanMapping mapping) {
         WeakReference<MXBeanMapping> wr =
             new WeakReference<MXBeanMapping>(mapping);
         mappings.put(type, wr);
     }
 
+    private static synchronized void putPermanentMapping(
+            Type type, MXBeanMapping mapping) {
+        putMapping(type, mapping);
+        permanentMappings.add(mapping);
+    }
+
     static {
         /* Set up the mappings for Java types that map to SimpleType.  */
 
@@ -213,7 +204,7 @@
                 throw new Error(e);
             }
             final MXBeanMapping mapping = new IdentityMapping(c, t);
-            permanentMappings.put(c, mapping);
+            putPermanentMapping(c, mapping);
 
             if (c.getName().startsWith("java.lang.")) {
                 try {
@@ -221,7 +212,7 @@
                     final Class<?> primitiveType = (Class<?>) typeField.get(null);
                     final MXBeanMapping primitiveMapping =
                         new IdentityMapping(primitiveType, t);
-                    permanentMappings.put(primitiveType, primitiveMapping);
+                    putPermanentMapping(primitiveType, primitiveMapping);
                     if (primitiveType != void.class) {
                         final Class<?> primitiveArrayType =
                             Array.newInstance(primitiveType, 0).getClass();
@@ -230,8 +221,8 @@
                         final MXBeanMapping primitiveArrayMapping =
                             new IdentityMapping(primitiveArrayType,
                                                 primitiveArrayOpenType);
-                        permanentMappings.put(primitiveArrayType,
-                                              primitiveArrayMapping);
+                        putPermanentMapping(primitiveArrayType,
+                                            primitiveArrayMapping);
                     }
                 } catch (NoSuchFieldException e) {
                     // OK: must not be a primitive wrapper
@@ -255,7 +246,7 @@
 
         MXBeanMapping mapping;
 
-        mapping = getMapping(objType, null);
+        mapping = getMapping(objType);
         if (mapping != null)
             return mapping;
 
@@ -268,7 +259,7 @@
             inProgress.remove(objType);
         }
 
-        putMapping(objType, mapping, factory);
+        putMapping(objType, mapping);
         return mapping;
     }
 
@@ -278,14 +269,6 @@
         /* It's not yet worth formalizing these tests by having for example
            an array of factory classes, each of which says whether it
            recognizes the Type (Chain of Responsibility pattern).  */
-        MXBeanMapping mapping = permanentMappings.get(objType);
-        if (mapping != null)
-            return mapping;
-        Class<?> erasure = erasure(objType);
-        MXBeanMappingClass mappingClass =
-                erasure.getAnnotation(MXBeanMappingClass.class);
-        if (mappingClass != null)
-            return makeAnnotationMapping(mappingClass, objType, factory);
         if (objType instanceof GenericArrayType) {
             Type componentType =
                 ((GenericArrayType) objType).getGenericComponentType();
@@ -313,51 +296,6 @@
             throw new OpenDataException("Cannot map type: " + objType);
     }
 
-    private static MXBeanMapping
-            makeAnnotationMapping(MXBeanMappingClass mappingClass,
-                                  Type objType,
-                                  MXBeanMappingFactory factory)
-    throws OpenDataException {
-        Class<? extends MXBeanMapping> c = mappingClass.value();
-        Constructor<? extends MXBeanMapping> cons;
-        try {
-            cons = c.getConstructor(Type.class);
-        } catch (NoSuchMethodException e) {
-            final String msg =
-                    "Annotation @" + MXBeanMappingClass.class.getName() +
-                    " must name a class with a public constructor that has a " +
-                    "single " + Type.class.getName() + " argument";
-            OpenDataException ode = new OpenDataException(msg);
-            ode.initCause(e);
-            throw ode;
-        }
-        try {
-            return cons.newInstance(objType);
-        } catch (Exception e) {
-            final String msg =
-                    "Could not construct a " + c.getName() + " for @" +
-                    MXBeanMappingClass.class.getName();
-            OpenDataException ode = new OpenDataException(msg);
-            ode.initCause(e);
-            throw ode;
-        }
-    }
-
-    private static Class<?> erasure(Type t) {
-        if (t instanceof Class<?>)
-            return (Class<?>) t;
-        if (t instanceof ParameterizedType)
-            return erasure(((ParameterizedType) t).getRawType());
-        /* Other cases: GenericArrayType, TypeVariable, WildcardType.
-         * Returning the erasure of GenericArrayType is not necessary because
-         * anyway we will be recursing on the element type, and we'll erase
-         * then.  Returning the erasure of the other two would mean returning
-         * the type bound (e.g. Foo in <T extends Foo> or <? extends Foo>)
-         * and since we don't treat this as Foo elsewhere we shouldn't here.
-         */
-        return Object.class;
-    }
-
     private static <T extends Enum<T>> MXBeanMapping
             makeEnumMapping(Class<?> enumClass, Class<T> fake) {
         return new EnumMapping<T>(Util.<Class<T>>cast(enumClass));
--- a/src/share/classes/com/sun/jmx/mbeanserver/DynamicMBean2.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/DynamicMBean2.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
 
 package com.sun.jmx.mbeanserver;
 
-import javax.management.DynamicWrapperMBean;
+import javax.management.DynamicMBean;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
@@ -35,7 +35,17 @@
  *
  * @since 1.6
  */
-public interface DynamicMBean2 extends DynamicWrapperMBean {
+public interface DynamicMBean2 extends DynamicMBean {
+    /**
+     * The resource corresponding to this MBean.  This is the object whose
+     * class name should be reflected by the MBean's
+     * getMBeanInfo().getClassName() for example.  For a "plain"
+     * DynamicMBean it will be "this".  For an MBean that wraps another
+     * object, like javax.management.StandardMBean, it will be the wrapped
+     * object.
+     */
+    public Object getResource();
+
     /**
      * The name of this MBean's class, as used by permission checks.
      * This is typically equal to getResource().getClass().getName().
--- a/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,14 +25,9 @@
 
 package com.sun.jmx.mbeanserver;
 
-import com.sun.jmx.remote.util.EnvHelp;
-import java.beans.BeanInfo;
-import java.beans.PropertyDescriptor;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.Proxy;
@@ -40,39 +35,21 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.logging.Level;
-import javax.management.AttributeNotFoundException;
-import javax.management.Description;
 
 import javax.management.Descriptor;
-import javax.management.DescriptorFields;
 import javax.management.DescriptorKey;
 import javax.management.DynamicMBean;
 import javax.management.ImmutableDescriptor;
-import javax.management.MBean;
 import javax.management.MBeanInfo;
-import javax.management.MXBean;
 import javax.management.NotCompliantMBeanException;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.MXBeanMappingFactory;
 
-import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
-import com.sun.jmx.mbeanserver.Util;
 import com.sun.jmx.remote.util.EnvHelp;
 import java.beans.BeanInfo;
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Array;
 import java.lang.reflect.InvocationTargetException;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 import javax.management.AttributeNotFoundException;
-import javax.management.JMX;
-import javax.management.ObjectName;
-import javax.management.ObjectNameTemplate;
 import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.MXBeanMappingFactory;
 
 /**
  * This class contains the methods for performing all the tests needed to verify
@@ -82,13 +59,7 @@
  */
 public class Introspector {
 
-    /**
-     * Pattern used to extract Attribute Names from ObjectNameTemplate Annotation
-     * For example, in the following example, the Name attribute value is
-     * retrieved : ":type=MyType, name={Name}"
-     */
-    private static Pattern OBJECT_NAME_PATTERN_TEMPLATE =
-            Pattern.compile("(\\{[^\\}]+\\})|(=\"\\{[^\\}]+\\}\")");
+
      /*
      * ------------------------------------------
      *  PRIVATE CONSTRUCTORS
@@ -164,10 +135,6 @@
 
     public static void checkCompliance(Class<?> mbeanClass)
     throws NotCompliantMBeanException {
-
-        // Check that @Resource is used correctly (if it used).
-        MBeanInjector.validate(mbeanClass);
-
         // Is DynamicMBean?
         //
         if (DynamicMBean.class.isAssignableFrom(mbeanClass))
@@ -190,36 +157,16 @@
         } catch (NotCompliantMBeanException e) {
             mxbeanException = e;
         }
-        // Is @MBean or @MXBean class?
-        // In fact we find @MBean or @MXBean as a hacky variant of
-        // getStandardMBeanInterface or getMXBeanInterface.  If we get here
-        // then nothing worked.
         final String msg =
             "MBean class " + mbeanClass.getName() + " does not implement " +
-            "DynamicMBean; does not follow the Standard MBean conventions (" +
-            mbeanException.toString() + "); does not follow the MXBean conventions (" +
-            mxbeanException.toString() + "); and does not have or inherit the @" +
-            MBean.class.getSimpleName() + " or @" + MXBean.class.getSimpleName() +
-            " annotation";
+            "DynamicMBean, and neither follows the Standard MBean conventions (" +
+            mbeanException.toString() + ") nor the MXBean conventions (" +
+            mxbeanException.toString() + ")";
         throw new NotCompliantMBeanException(msg);
     }
 
-    /**
-     * <p>Make a DynamicMBean out of the existing MBean object.  The object
-     * may already be a DynamicMBean, or it may be a Standard MBean or
-     * MXBean, possibly defined using {@code @MBean} or {@code @MXBean}.</p>
-     * @param mbean the object to convert to a DynamicMBean.
-     * @param <T> a type parameter defined for implementation convenience
-     * (which would have to be removed if this method were part of the public
-     * API).
-     * @return the converted DynamicMBean.
-     * @throws NotCompliantMBeanException if {@code mbean} is not a compliant
-     * MBean object, including the case where it is null.
-     */
     public static <T> DynamicMBean makeDynamicMBean(T mbean)
-    throws NotCompliantMBeanException {
-        if (mbean == null)
-            throw new NotCompliantMBeanException("Null MBean object");
+        throws NotCompliantMBeanException {
         if (mbean instanceof DynamicMBean)
             return (DynamicMBean) mbean;
         final Class<?> mbeanClass = mbean.getClass();
@@ -240,18 +187,8 @@
             // to be an MBean or an MXBean. We will call checkCompliance()
             // to generate the appropriate exception.
         }
-        if (c != null) {
-            MXBeanMappingFactory factory;
-            try {
-                factory = MXBeanMappingFactory.forInterface(c);
-            } catch (IllegalArgumentException e) {
-                NotCompliantMBeanException ncmbe =
-                        new NotCompliantMBeanException(e.getMessage());
-                ncmbe.initCause(e);
-                throw ncmbe;
-            }
-            return new MXBeanSupport(mbean, c, factory);
-        }
+        if (c != null)
+            return new MXBeanSupport(mbean, c);
         checkCompliance(mbeanClass);
         throw new NotCompliantMBeanException("Not compliant"); // not reached
     }
@@ -280,10 +217,9 @@
         return testCompliance(baseClass, null);
     }
 
-    public static void testComplianceMXBeanInterface(Class<?> interfaceClass,
-                                                     MXBeanMappingFactory factory)
+    public static void testComplianceMXBeanInterface(Class<?> interfaceClass)
             throws NotCompliantMBeanException {
-        MXBeanIntrospector.getInstance(factory).getAnalyzer(interfaceClass);
+        MXBeanIntrospector.getInstance().getAnalyzer(interfaceClass);
     }
 
     /**
@@ -352,8 +288,6 @@
      */
     public static <T> Class<? super T> getStandardMBeanInterface(Class<T> baseClass)
     throws NotCompliantMBeanException {
-        if (baseClass.isAnnotationPresent(MBean.class))
-            return baseClass;
         Class<? super T> current = baseClass;
         Class<? super T> mbeanInterface = null;
         while (current != null) {
@@ -384,8 +318,6 @@
      */
     public static <T> Class<? super T> getMXBeanInterface(Class<T> baseClass)
         throws NotCompliantMBeanException {
-        if (hasMXBeanAnnotation(baseClass))
-            return baseClass;
         try {
             return MXBeanSupport.findMXBeanInterface(baseClass);
         } catch (Exception e) {
@@ -393,61 +325,12 @@
         }
     }
 
-    public static <T> Class<? super T> getStandardOrMXBeanInterface(
-            Class<T> baseClass, boolean mxbean)
-    throws NotCompliantMBeanException {
-        if (mxbean)
-            return getMXBeanInterface(baseClass);
-        else
-            return getStandardMBeanInterface(baseClass);
-    }
-
-    public static ObjectName templateToObjectName(Descriptor descriptor,
-            DynamicMBean mbean)
-            throws NotCompliantMBeanException {
-        String template = (String)
-            descriptor.getFieldValue(JMX.OBJECT_NAME_TEMPLATE);
-        if(template == null) return null;
-        try {
-            Matcher m = OBJECT_NAME_PATTERN_TEMPLATE.matcher(template);
-            while (m.find()){
-                String grp = m.group();
-                System.out.println("GROUP " + grp);
-                String attributeName = null;
-                boolean quote = false;
-                if(grp.startsWith("=\"{")) {
-                    attributeName = grp.substring(3, grp.length() - 2);
-                    quote = true;
-                } else
-                    attributeName = grp.substring(1, grp.length() - 1);
-
-                Object attributeValue = mbean.getAttribute(attributeName);
-                String validValue = quote ?
-                    "=" + ObjectName.quote(attributeValue.toString()) :
-                    attributeValue.toString();
-                template = template.replace(grp, validValue);
-            }
-            return new ObjectName(template);
-        }catch(Exception ex) {
-            NotCompliantMBeanException ncex = new
-                    NotCompliantMBeanException(ObjectNameTemplate.class.
-                    getSimpleName() + " annotation value [" + template + "] " +
-                    "is invalid. " + ex);
-            ncex.initCause(ex);
-            throw ncex;
-        }
-    }
-
     /*
      * ------------------------------------------
      *  PRIVATE METHODS
      * ------------------------------------------
      */
 
-    static boolean hasMXBeanAnnotation(Class<?> c) {
-        MXBean m = c.getAnnotation(MXBean.class);
-        return (m != null && m.value());
-    }
 
     /**
      * Try to find the MBean interface corresponding to the class aName
@@ -469,77 +352,11 @@
         return null;
     }
 
-    public static String descriptionForElement(AnnotatedElement elmt) {
-        if (elmt == null)
-            return null;
-        Description d = elmt.getAnnotation(Description.class);
-        if (d == null)
-            return null;
-        return d.value();
-    }
-
-    public static String descriptionForParameter(
-            Annotation[] parameterAnnotations) {
-        for (Annotation a : parameterAnnotations) {
-            if (a instanceof Description)
-                return ((Description) a).value();
-        }
-        return null;
-    }
-
-    public static String nameForParameter(
-            Annotation[] parameterAnnotations) {
-        for (Annotation a : parameterAnnotations) {
-            Class<? extends Annotation> ac = a.annotationType();
-            // You'd really have to go out of your way to have more than
-            // one @Name annotation, so we don't check for that.
-            if (ac.getSimpleName().equals("Name")) {
-                try {
-                    Method value = ac.getMethod("value");
-                    if (value.getReturnType() == String.class &&
-                            value.getParameterTypes().length == 0) {
-                        return (String) value.invoke(a);
-                    }
-                } catch (Exception e) {
-                    MBEANSERVER_LOGGER.log(
-                            Level.WARNING,
-                            "Unexpected exception getting @" + ac.getName(),
-                            e);
-                }
-            }
-        }
-        return null;
-    }
-
-    public static Descriptor descriptorForElement(final AnnotatedElement elmt,
-            boolean isSetter) {
+    public static Descriptor descriptorForElement(final AnnotatedElement elmt) {
         if (elmt == null)
             return ImmutableDescriptor.EMPTY_DESCRIPTOR;
         final Annotation[] annots = elmt.getAnnotations();
-        Descriptor descr = descriptorForAnnotations(annots);
-        String[] exceptions = {};
-        if(elmt instanceof Method)
-            exceptions = getAllExceptions(((Method) elmt).getExceptionTypes());
-        else
-            if(elmt instanceof Constructor<?>)
-                exceptions = getAllExceptions(((Constructor<?>) elmt).
-                        getExceptionTypes());
-
-        if(exceptions.length > 0 ) {
-            String fieldName = isSetter ? JMX.SET_EXCEPTIONS_FIELD :
-                JMX.EXCEPTIONS_FIELD;
-
-            String[] fieldNames = {fieldName};
-            Object[] fieldValues = {exceptions};
-            descr = ImmutableDescriptor.union(descr,
-                    new ImmutableDescriptor(fieldNames, fieldValues));
-        }
-
-        return descr;
-    }
-
-    public static Descriptor descriptorForAnnotation(Annotation annot) {
-        return descriptorForAnnotations(new Annotation[] {annot});
+        return descriptorForAnnotations(annots);
     }
 
     public static Descriptor descriptorForAnnotations(Annotation[] annots) {
@@ -547,9 +364,36 @@
             return ImmutableDescriptor.EMPTY_DESCRIPTOR;
         Map<String, Object> descriptorMap = new HashMap<String, Object>();
         for (Annotation a : annots) {
-            if (a instanceof DescriptorFields)
-                addDescriptorFieldsToMap(descriptorMap, (DescriptorFields) a);
-            addAnnotationFieldsToMap(descriptorMap, a);
+            Class<? extends Annotation> c = a.annotationType();
+            Method[] elements = c.getMethods();
+            for (Method element : elements) {
+                DescriptorKey key = element.getAnnotation(DescriptorKey.class);
+                if (key != null) {
+                    String name = key.value();
+                    Object value;
+                    try {
+                        value = element.invoke(a);
+                    } catch (RuntimeException e) {
+                        // we don't expect this - except for possibly
+                        // security exceptions?
+                        // RuntimeExceptions shouldn't be "UndeclaredThrowable".
+                        // anyway...
+                        //
+                        throw e;
+                    } catch (Exception e) {
+                        // we don't expect this
+                        throw new UndeclaredThrowableException(e);
+                    }
+                    value = annotationToField(value);
+                    Object oldValue = descriptorMap.put(name, value);
+                    if (oldValue != null && !equals(oldValue, value)) {
+                        final String msg =
+                            "Inconsistent values for descriptor field " + name +
+                            " from annotations: " + value + " :: " + oldValue;
+                        throw new IllegalArgumentException(msg);
+                    }
+                }
+            }
         }
 
         if (descriptorMap.isEmpty())
@@ -559,76 +403,6 @@
     }
 
     /**
-     * Array of thrown excepions.
-     * @param exceptions can be null;
-     * @return An Array of Exception class names. Size is 0 if method is null.
-     */
-    private static String[] getAllExceptions(Class<?>[] exceptions) {
-        Set<String> set = new LinkedHashSet<String>();
-        for(Class<?>ex : exceptions)
-            set.add(ex.getName());
-
-        String[] arr = new String[set.size()];
-        return set.toArray(arr);
-    }
-
-    private static void addDescriptorFieldsToMap(
-            Map<String, Object> descriptorMap, DescriptorFields df) {
-        for (String field : df.value()) {
-            int eq = field.indexOf('=');
-            if (eq < 0) {
-                throw new IllegalArgumentException(
-                        "@DescriptorFields string must contain '=': " +
-                        field);
-            }
-            String name = field.substring(0, eq);
-            String value = field.substring(eq + 1);
-            addToMap(descriptorMap, name, value);
-        }
-    }
-
-    private static void addAnnotationFieldsToMap(
-            Map<String, Object> descriptorMap, Annotation a) {
-        Class<? extends Annotation> c = a.annotationType();
-        Method[] elements = c.getMethods();
-        for (Method element : elements) {
-            DescriptorKey key = element.getAnnotation(DescriptorKey.class);
-            if (key != null) {
-                String name = key.value();
-                Object value;
-                try {
-                    value = element.invoke(a);
-                } catch (RuntimeException e) {
-                    // we don't expect this - except for possibly
-                    // security exceptions?
-                    // RuntimeExceptions shouldn't be "UndeclaredThrowable".
-                    // anyway...
-                    throw e;
-                } catch (Exception e) {
-                    // we don't expect this
-                    throw new UndeclaredThrowableException(e);
-                }
-                if (!key.omitIfDefault() ||
-                        !equals(value, element.getDefaultValue())) {
-                    value = annotationToField(value);
-                    addToMap(descriptorMap, name, value);
-                }
-            }
-        }
-    }
-
-    private static void addToMap(
-            Map<String, Object> descriptorMap, String name, Object value) {
-        Object oldValue = descriptorMap.put(name, value);
-        if (oldValue != null && !equals(oldValue, value)) {
-            final String msg =
-                "Inconsistent values for descriptor field " + name +
-                " from annotations: " + value + " :: " + oldValue;
-            throw new IllegalArgumentException(msg);
-        }
-    }
-
-    /**
      * Throws a NotCompliantMBeanException or a SecurityException.
      * @param notCompliant the class which was under examination
      * @param cause the raeson why NotCompliantMBeanException should
--- a/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/JmxMBeanServer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,14 +25,14 @@
 
 package com.sun.jmx.mbeanserver;
 
+import com.sun.jmx.interceptor.DefaultMBeanServerInterceptor;
+import com.sun.jmx.interceptor.MBeanServerInterceptor;
 import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
-import com.sun.jmx.interceptor.NamespaceDispatchInterceptor;
 
 import java.io.ObjectInputStream;
 import java.security.AccessController;
 import java.security.Permission;
 import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.logging.Level;
@@ -108,8 +108,6 @@
     /** The MBeanServerDelegate object representing the MBean Server */
     private final MBeanServerDelegate mBeanServerDelegateObject;
 
-    private final String mbeanServerName;
-
     /**
      * <b>Package:</b> Creates an MBeanServer with the
      * specified default domain name, outer interface, and delegate.
@@ -241,10 +239,9 @@
 
         final Repository repository = new Repository(domain);
         this.mbsInterceptor =
-            new NamespaceDispatchInterceptor(outer, delegate, instantiator,
+            new DefaultMBeanServerInterceptor(outer, delegate, instantiator,
                                               repository);
         this.interceptorsEnabled = interceptors;
-        this.mbeanServerName = Util.getMBeanServerSecurityName(delegate);
         initialize();
     }
 
@@ -940,8 +937,7 @@
         throws ReflectionException, MBeanException {
 
         /* Permission check */
-        checkMBeanPermission(mbeanServerName, className, null, null,
-                "instantiate");
+        checkMBeanPermission(className, null, null, "instantiate");
 
         return instantiator.instantiate(className);
     }
@@ -978,8 +974,7 @@
                InstanceNotFoundException {
 
         /* Permission check */
-        checkMBeanPermission(mbeanServerName, className, null,
-                null, "instantiate");
+        checkMBeanPermission(className, null, null, "instantiate");
 
         ClassLoader myLoader = outerShell.getClass().getClassLoader();
         return instantiator.instantiate(className, loaderName, myLoader);
@@ -1017,8 +1012,7 @@
         throws ReflectionException, MBeanException {
 
         /* Permission check */
-        checkMBeanPermission(mbeanServerName, className, null, null,
-                "instantiate");
+        checkMBeanPermission(className, null, null, "instantiate");
 
         ClassLoader myLoader = outerShell.getClass().getClassLoader();
         return instantiator.instantiate(className, params, signature,
@@ -1061,8 +1055,7 @@
                InstanceNotFoundException {
 
         /* Permission check */
-        checkMBeanPermission(mbeanServerName, className, null,
-                null, "instantiate");
+        checkMBeanPermission(className, null, null, "instantiate");
 
         ClassLoader myLoader = outerShell.getClass().getClassLoader();
         return instantiator.instantiate(className,loaderName,params,signature,
@@ -1333,8 +1326,7 @@
      **/
     public ClassLoaderRepository getClassLoaderRepository() {
         /* Permission check */
-        checkMBeanPermission(mbeanServerName, null, null,
-                null, "getClassLoaderRepository");
+        checkMBeanPermission(null, null, null, "getClassLoaderRepository");
         return secureClr;
     }
 
@@ -1487,16 +1479,14 @@
     // SECURITY CHECKS
     //----------------
 
-    private static void checkMBeanPermission(String serverName,
-                                             String classname,
+    private static void checkMBeanPermission(String classname,
                                              String member,
                                              ObjectName objectName,
                                              String actions)
         throws SecurityException {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
-            Permission perm = new MBeanPermission(serverName,
-                                                  classname,
+            Permission perm = new MBeanPermission(classname,
                                                   member,
                                                   objectName,
                                                   actions);
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanAnalyzer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,10 +33,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import javax.management.MBean;
-import javax.management.MXBean;
-import javax.management.ManagedAttribute;
-import javax.management.ManagedOperation;
 import javax.management.NotCompliantMBeanException;
 
 /**
@@ -55,15 +51,15 @@
  */
 class MBeanAnalyzer<M> {
 
-    static interface MBeanVisitor<M, X extends Exception> {
+    static interface MBeanVisitor<M> {
         public void visitAttribute(String attributeName,
                 M getter,
-                M setter) throws X;
+                M setter);
         public void visitOperation(String operationName,
-                M operation) throws X;
+                M operation);
     }
 
-    <X extends Exception> void visit(MBeanVisitor<M, X> visitor) throws X {
+    void visit(MBeanVisitor<M> visitor) {
         // visit attributes
         for (Map.Entry<String, AttrMethods<M>> entry : attrMap.entrySet()) {
             String name = entry.getKey();
@@ -108,7 +104,10 @@
     private MBeanAnalyzer(Class<?> mbeanType,
             MBeanIntrospector<M> introspector)
             throws NotCompliantMBeanException {
-        introspector.checkCompliance(mbeanType);
+        if (!mbeanType.isInterface()) {
+            throw new NotCompliantMBeanException("Not an interface: " +
+                    mbeanType.getName());
+        }
 
         try {
             initMaps(mbeanType, introspector);
@@ -129,26 +128,18 @@
         for (Method m : methods) {
             final String name = m.getName();
             final int nParams = m.getParameterTypes().length;
-            final boolean managedOp = m.isAnnotationPresent(ManagedOperation.class);
-            final boolean managedAttr = m.isAnnotationPresent(ManagedAttribute.class);
-            if (managedOp && managedAttr) {
-                throw new NotCompliantMBeanException("Method " + name +
-                        " has both @ManagedOperation and @ManagedAttribute");
-            }
 
             final M cm = introspector.mFrom(m);
 
             String attrName = "";
-            if (!managedOp) {
-                if (name.startsWith("get"))
-                    attrName = name.substring(3);
-                else if (name.startsWith("is")
-                         && m.getReturnType() == boolean.class)
-                    attrName = name.substring(2);
-            }
+            if (name.startsWith("get"))
+                attrName = name.substring(3);
+            else if (name.startsWith("is")
+            && m.getReturnType() == boolean.class)
+                attrName = name.substring(2);
 
             if (attrName.length() != 0 && nParams == 0
-                    && m.getReturnType() != void.class && !managedOp) {
+                    && m.getReturnType() != void.class) {
                 // It's a getter
                 // Check we don't have both isX and getX
                 AttrMethods<M> am = attrMap.get(attrName);
@@ -165,7 +156,7 @@
                 attrMap.put(attrName, am);
             } else if (name.startsWith("set") && name.length() > 3
                     && nParams == 1 &&
-                    m.getReturnType() == void.class && !managedOp) {
+                    m.getReturnType() == void.class) {
                 // It's a setter
                 attrName = name.substring(3);
                 AttrMethods<M> am = attrMap.get(attrName);
@@ -178,9 +169,6 @@
                 }
                 am.setter = cm;
                 attrMap.put(attrName, am);
-            } else if (managedAttr) {
-                throw new NotCompliantMBeanException("Method " + name +
-                        " has @ManagedAttribute but is not a valid getter or setter");
             } else {
                 // It's an operation
                 List<M> cms = opMap.get(name);
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInjector.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,295 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.mbeanserver;
-
-import java.lang.ref.WeakReference;
-import java.security.PrivilegedAction;
-import java.util.Map;
-import java.util.WeakHashMap;
-import javax.annotation.Resource;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-
-import static com.sun.jmx.mbeanserver.Util.newMap;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.security.AccessController;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import javax.management.SendNotification;
-
-public class MBeanInjector {
-    // There are no instances of this class
-    private MBeanInjector() {
-    }
-
-    private static Class<?>[] injectedClasses = {
-        MBeanServer.class, ObjectName.class, SendNotification.class,
-    };
-
-    public static void inject(Object mbean, MBeanServer mbs, ObjectName name)
-    throws Exception {
-        ClassInjector injector = injectorForClass(mbean.getClass());
-        injector.inject(mbean, MBeanServer.class, mbs);
-        injector.inject(mbean, ObjectName.class, name);
-    }
-
-    public static boolean injectsSendNotification(Object mbean)
-    throws NotCompliantMBeanException {
-        ClassInjector injector = injectorForClass(mbean.getClass());
-        return injector.injects(SendNotification.class);
-    }
-
-    public static void injectSendNotification(Object mbean, SendNotification sn)
-    throws Exception {
-        ClassInjector injector = injectorForClass(mbean.getClass());
-        injector.inject(mbean, SendNotification.class, sn);
-    }
-
-    public static void validate(Class<?> c) throws NotCompliantMBeanException {
-        injectorForClass(c);
-    }
-
-    private static class ClassInjector {
-        private Map<Class<?>, List<Field>> fields;
-        private Map<Class<?>, List<Method>> methods;
-
-        ClassInjector(Class<?> c) throws NotCompliantMBeanException {
-            fields = newMap();
-            methods = newMap();
-
-            Class<?> sup = c.getSuperclass();
-            ClassInjector supInjector;
-            if (sup == null) {
-                supInjector = null;
-            } else {
-                supInjector = injectorForClass(sup);
-                fields.putAll(supInjector.fields);
-                methods.putAll(supInjector.methods);
-            }
-
-            addMembers(c);
-            eliminateOverriddenMethods();
-
-            // If we haven't added any new fields or methods to what we
-            // inherited, then we can share the parent's maps.
-            if (supInjector != null) {
-                if (fields.equals(supInjector.fields))
-                    fields = supInjector.fields;
-                if (methods.equals(supInjector.methods))
-                    methods = supInjector.methods;
-            }
-        }
-
-        boolean injects(Class<?> c) {
-            return (fields.get(c) != null || methods.get(c) != null);
-        }
-
-        <T> void inject(Object instance, Class<T> type, T resource)
-        throws Exception {
-            List<Field> fs = fields.get(type);
-            if (fs != null) {
-                for (Field f : fs)
-                    f.set(instance, resource);
-            }
-            List<Method> ms = methods.get(type);
-            if (ms != null) {
-                for (Method m : ms) {
-                    try {
-                        m.invoke(instance, resource);
-                    } catch (InvocationTargetException e) {
-                        Throwable cause = e.getCause();
-                        if (cause instanceof Error)
-                            throw (Error) cause;
-                        else
-                            throw (Exception) cause;
-                    }
-                }
-            }
-        }
-
-        private void eliminateOverriddenMethods() {
-            /* Covariant overriding is unlikely, but it is possible that the
-             * parent has a @Resource method that we override with another
-             * @Resource method.  We don't want to invoke both methods,
-             * because polymorphism means we would actually invoke the same
-             * method twice.
-             */
-            for (Map.Entry<Class<?>, List<Method>> entry : methods.entrySet()) {
-                List<Method> list = entry.getValue();
-                list = MBeanAnalyzer.eliminateCovariantMethods(list);
-                entry.setValue(list);
-            }
-        }
-
-        /*
-         * Find Fields or Methods within the given Class that we can inject
-         * resource references into.  Suppose we want to know if a Field can get
-         * a reference to an ObjectName.  We'll accept fields like this:
-         *
-         * @Resource
-         * private transient ObjectName name;
-         *
-         * or like this:
-         *
-         * @Resource(type = ObjectName.class)
-         * private transient Object name;
-         *
-         * but not like this:
-         *
-         * @Resource
-         * private transient Object name;
-         *
-         * (Plain @Resource is equivalent to @Resource(type = Object.class).)
-         *
-         * We don't want to inject into everything that might possibly accept
-         * an ObjectName reference, because examples like the last one above
-         * could also accept an MBeanServer reference or any other sort of
-         * reference.
-         *
-         * So we accept a Field if it has a @Resource annotation and either
-         * (a) its type is exactly ObjectName and its @Resource type is
-         * compatible with ObjectName (e.g. it is Object); or
-         * (b) its type is compatible with ObjectName and its @Resource type
-         * is exactly ObjectName.  Fields that meet these criteria will not
-         * meet the same criteria with respect to other types such as MBeanServer.
-         *
-         * The same logic applies mutatis mutandis to Methods such as this:
-         *
-         * @Resource
-         * private void setObjectName1(ObjectName name)
-         * @Resource(type = Object.class)
-         * private void setObjectName2(Object name)
-         */
-        private void addMembers(final Class<?> c)
-        throws NotCompliantMBeanException {
-            AccessibleObject[][] memberArrays =
-                AccessController.doPrivileged(
-                    new PrivilegedAction<AccessibleObject[][]>() {
-                        public AccessibleObject[][] run() {
-                            return new AccessibleObject[][] {
-                                c.getDeclaredFields(), c.getDeclaredMethods()
-                            };
-                        }
-                    });
-            for (AccessibleObject[] members : memberArrays) {
-                for (final AccessibleObject member : members) {
-                    Resource res = member.getAnnotation(Resource.class);
-                    if (res == null)
-                        continue;
-
-                    final Field field;
-                    final Method method;
-                    final Class<?> memberType;
-                    final int modifiers;
-                    if (member instanceof Field) {
-                        field = (Field) member;
-                        memberType = field.getType();
-                        modifiers = field.getModifiers();
-                        method = null;
-                    } else {
-                        field = null;
-                        method = (Method) member;
-                        Class<?>[] paramTypes = method.getParameterTypes();
-                        if (paramTypes.length != 1) {
-                            throw new NotCompliantMBeanException(
-                                    "@Resource method must have exactly 1 " +
-                                    "parameter: " + method);
-                        }
-                        if (method.getReturnType() != void.class) {
-                            throw new NotCompliantMBeanException(
-                                    "@Resource method must return void: " +
-                                    method);
-                        }
-                        memberType = paramTypes[0];
-                        modifiers = method.getModifiers();
-                    }
-
-                    if (Modifier.isStatic(modifiers)) {
-                        throw new NotCompliantMBeanException(
-                                "@Resource method or field cannot be static: " +
-                                member);
-                    }
-
-                    for (Class<?> injectedClass : injectedClasses) {
-                        Class<?>[] types = {memberType, res.type()};
-                        boolean accept = false;
-                        for (int i = 0; i < 2; i++) {
-                            if (types[i] == injectedClass &&
-                                    types[1 - i].isAssignableFrom(injectedClass)) {
-                                accept = true;
-                                break;
-                            }
-                        }
-                        if (accept) {
-                            AccessController.doPrivileged(new PrivilegedAction<Void>() {
-                                public Void run() {
-                                    member.setAccessible(true);
-                                    return null;
-                                }
-                            });
-                            addToMap(fields, injectedClass, field);
-                            addToMap(methods, injectedClass, method);
-                        }
-                    }
-                }
-            }
-        }
-
-        private static <K, V> void addToMap(Map<K, List<V>> map, K key, V value) {
-            if (value == null)
-                return;
-            List<V> list = map.get(key);
-            if (list == null)
-                list = Collections.singletonList(value);
-            else {
-                if (list.size() == 1)
-                    list = new ArrayList<V>(list);
-                list.add(value);
-            }
-            map.put(key, list);
-        }
-    }
-
-    private static synchronized ClassInjector injectorForClass(Class<?> c)
-    throws NotCompliantMBeanException {
-        WeakReference<ClassInjector> wr = injectorMap.get(c);
-        ClassInjector ci = (wr == null) ? null : wr.get();
-        if (ci == null) {
-            ci = new ClassInjector(c);
-            injectorMap.put(c, new WeakReference<ClassInjector>(ci));
-        }
-        return ci;
-    }
-
-    private static Map<Class<?>, WeakReference<ClassInjector>> injectorMap =
-            new WeakHashMap<Class<?>, WeakReference<ClassInjector>>();
-}
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Wed Nov 25 11:08:25 2009 -0800
@@ -614,15 +614,6 @@
     }
 
     /**
-     * Returns the class of a primitive type.
-     * @param name The type for which we the associated class.
-     * @return the class, or null if name is not primitive.
-     */
-    public static Class<?> primitiveType(String name) {
-        return primitiveClasses.get(name);
-    }
-
-    /**
      * Load a class with the specified loader, or with this object
      * class loader if the specified loader is null.
      **/
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanIntrospector.java	Wed Nov 25 11:08:25 2009 -0800
@@ -36,28 +36,20 @@
 import java.lang.reflect.Type;
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 import java.util.WeakHashMap;
-import javax.management.Description;
 
 import javax.management.Descriptor;
 import javax.management.ImmutableDescriptor;
 import javax.management.IntrospectionException;
 import javax.management.InvalidAttributeValueException;
-import javax.management.MBean;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanConstructorInfo;
 import javax.management.MBeanException;
 import javax.management.MBeanInfo;
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanOperationInfo;
-import javax.management.MXBean;
-import javax.management.ManagedAttribute;
-import javax.management.ManagedOperation;
 import javax.management.NotCompliantMBeanException;
 import javax.management.NotificationBroadcaster;
-import javax.management.NotificationInfo;
-import javax.management.NotificationInfos;
 import javax.management.ReflectionException;
 
 /**
@@ -79,7 +71,7 @@
  * ancestor with ConvertingMethod.  But that would mean an extra object
  * for every Method in every Standard MBean interface.
  */
-public abstract class MBeanIntrospector<M> {
+abstract class MBeanIntrospector<M> {
     static final class PerInterfaceMap<M>
             extends WeakHashMap<Class<?>, WeakReference<PerInterface<M>>> {}
 
@@ -159,27 +151,7 @@
      * may be null.
      */
     abstract MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
-            M getter, M setter) throws IntrospectionException;
-
-    final String getAttributeDescription(
-            String attributeName, String defaultDescription,
-            Method getter, Method setter) throws IntrospectionException {
-        String g = Introspector.descriptionForElement(getter);
-        String s = Introspector.descriptionForElement(setter);
-        if (g == null) {
-            if (s == null)
-                return defaultDescription;
-            else
-                return s;
-        } else if (s == null || g.equals(s)) {
-            return g;
-        } else {
-            throw new IntrospectionException(
-                    "Inconsistent @Description on getter and setter for " +
-                    "attribute " + attributeName);
-        }
-    }
-
+            M getter, M setter);
     /**
      * Construct an MBeanOperationInfo for the given operation based on
      * the M it was derived from.
@@ -201,36 +173,10 @@
     abstract Descriptor getMBeanDescriptor(Class<?> resourceClass);
 
     /**
-     * Get any additional Descriptor entries for this introspector instance.
-     * If there is a non-default MXBeanMappingFactory, it will appear in
-     * this Descriptor.
-     * @return Additional Descriptor entries, or an empty Descriptor if none.
-     */
-    Descriptor getSpecificMBeanDescriptor() {
-        return ImmutableDescriptor.EMPTY_DESCRIPTOR;
-    }
-
-    void checkCompliance(Class<?> mbeanType) throws NotCompliantMBeanException {
-        if (!mbeanType.isInterface() &&
-                !mbeanType.isAnnotationPresent(MBean.class) &&
-                !Introspector.hasMXBeanAnnotation(mbeanType)) {
-            throw new NotCompliantMBeanException("Not an interface and " +
-                    "does not have @" + MBean.class.getSimpleName() +
-                    " or @" + MXBean.class.getSimpleName() + " annotation: " +
-                    mbeanType.getName());
-        }
-    }
-
-    /**
      * Get the methods to be analyzed to build the MBean interface.
      */
     List<Method> getMethods(final Class<?> mbeanType) throws Exception {
-        if (mbeanType.isInterface())
-            return Arrays.asList(mbeanType.getMethods());
-
-        final List<Method> methods = newList();
-        getAnnotatedMethods(mbeanType, methods);
-        return methods;
+        return Arrays.asList(mbeanType.getMethods());
     }
 
     final PerInterface<M> getPerInterface(Class<?> mbeanInterface)
@@ -265,14 +211,11 @@
      * the MBeanInfo's Descriptor.
      */
     private MBeanInfo makeInterfaceMBeanInfo(Class<?> mbeanInterface,
-            MBeanAnalyzer<M> analyzer) throws IntrospectionException {
+            MBeanAnalyzer<M> analyzer) {
         final MBeanInfoMaker maker = new MBeanInfoMaker();
         analyzer.visit(maker);
-        final String defaultDescription =
+        final String description =
                 "Information on the management interface of the MBean";
-        String description = Introspector.descriptionForElement(mbeanInterface);
-        if (description == null)
-            description = defaultDescription;
         return maker.makeMBeanInfo(mbeanInterface, description);
     }
 
@@ -370,11 +313,11 @@
 
     /** A visitor that constructs the per-interface MBeanInfo. */
     private class MBeanInfoMaker
-            implements MBeanAnalyzer.MBeanVisitor<M, IntrospectionException> {
+            implements MBeanAnalyzer.MBeanVisitor<M> {
 
         public void visitAttribute(String attributeName,
                 M getter,
-                M setter) throws IntrospectionException {
+                M setter) {
             MBeanAttributeInfo mbai =
                     getMBeanAttributeInfo(attributeName, getter, setter);
 
@@ -403,7 +346,7 @@
                     new ImmutableDescriptor(interfaceClassName);
             final Descriptor mbeanDescriptor = getBasicMBeanDescriptor();
             final Descriptor annotatedDescriptor =
-                    Introspector.descriptorForElement(mbeanInterface, false);
+                    Introspector.descriptorForElement(mbeanInterface);
             final Descriptor descriptor =
                 DescriptorCache.getInstance().union(
                     classNameDescriptor,
@@ -442,32 +385,20 @@
      * Return the MBeanInfo for the given resource, based on the given
      * per-interface data.
      */
-    final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface)
-    throws NotCompliantMBeanException {
+    final MBeanInfo getMBeanInfo(Object resource, PerInterface<M> perInterface) {
         MBeanInfo mbi =
                 getClassMBeanInfo(resource.getClass(), perInterface);
-        MBeanNotificationInfo[] notifs;
-        try {
-            notifs = findNotifications(resource);
-        } catch (RuntimeException e) {
-            NotCompliantMBeanException x =
-                    new NotCompliantMBeanException(e.getMessage());
-            x.initCause(e);
-            throw x;
-        }
-        Descriptor d = getSpecificMBeanDescriptor();
-        boolean anyNotifs = (notifs != null && notifs.length > 0);
-        if (!anyNotifs && ImmutableDescriptor.EMPTY_DESCRIPTOR.equals(d))
+        MBeanNotificationInfo[] notifs = findNotifications(resource);
+        if (notifs == null || notifs.length == 0)
             return mbi;
         else {
-            d = ImmutableDescriptor.union(d, mbi.getDescriptor());
             return new MBeanInfo(mbi.getClassName(),
                     mbi.getDescription(),
                     mbi.getAttributes(),
                     mbi.getConstructors(),
                     mbi.getOperations(),
                     notifs,
-                    d);
+                    mbi.getDescriptor());
         }
     }
 
@@ -507,145 +438,29 @@
         }
     }
 
-    /*
-     * Add to "methods" every public method that has the @ManagedAttribute
-     * or @ManagedOperation annotation, in the given class or any of
-     * its superclasses or superinterfaces.
-     *
-     * We always add superclass or superinterface methods first, so that
-     * the stable sort used by eliminateCovariantMethods will put the
-     * method from the most-derived class last.  This means that we will
-     * see the version of the @ManagedAttribute (or ...Operation) annotation
-     * from that method, which might have a different description or whatever.
-     */
-    public static void getAnnotatedMethods(Class<?> c, List<Method> methods)
-    throws Exception {
-        Class<?> sup = c.getSuperclass();
-        if (sup != null)
-            getAnnotatedMethods(sup, methods);
-        Class<?>[] intfs = c.getInterfaces();
-        for (Class<?> intf : intfs)
-            getAnnotatedMethods(intf, methods);
-        for (Method m : c.getMethods()) {
-            // We are careful not to add m if it is inherited from a parent
-            // class or interface, because duplicate methods lead to nasty
-            // behaviour in eliminateCovariantMethods.
-            if (m.getDeclaringClass() == c &&
-                    (m.isAnnotationPresent(ManagedAttribute.class) ||
-                     m.isAnnotationPresent(ManagedOperation.class)))
-                methods.add(m);
-        }
-    }
-
-    /*
-     * Return the array of MBeanNotificationInfo for the given MBean object.
-     * If the object implements NotificationBroadcaster and its
-     * getNotificationInfo() method returns a non-empty array, then that
-     * is the result.  Otherwise, if the object has a @NotificationInfo
-     * or @NotificationInfos annotation, then its contents form the result.
-     * Otherwise, the result is null.
-     */
     static MBeanNotificationInfo[] findNotifications(Object moi) {
-        if (moi instanceof NotificationBroadcaster) {
-            MBeanNotificationInfo[] mbn =
-                    ((NotificationBroadcaster) moi).getNotificationInfo();
-            if (mbn != null && mbn.length > 0) {
-                MBeanNotificationInfo[] result =
-                        new MBeanNotificationInfo[mbn.length];
-                for (int i = 0; i < mbn.length; i++) {
-                    MBeanNotificationInfo ni = mbn[i];
-                    if (ni.getClass() != MBeanNotificationInfo.class)
-                        ni = (MBeanNotificationInfo) ni.clone();
-                    result[i] = ni;
-                }
-                return result;
-            }
-        } else {
-            try {
-                if (!MBeanInjector.injectsSendNotification(moi))
-                    return null;
-            } catch (NotCompliantMBeanException e) {
-                throw new RuntimeException(e);
-            }
+        if (!(moi instanceof NotificationBroadcaster))
+            return null;
+        MBeanNotificationInfo[] mbn =
+                ((NotificationBroadcaster) moi).getNotificationInfo();
+        if (mbn == null)
+            return null;
+        MBeanNotificationInfo[] result =
+                new MBeanNotificationInfo[mbn.length];
+        for (int i = 0; i < mbn.length; i++) {
+            MBeanNotificationInfo ni = mbn[i];
+            if (ni.getClass() != MBeanNotificationInfo.class)
+                ni = (MBeanNotificationInfo) ni.clone();
+            result[i] = ni;
         }
-        return findNotificationsFromAnnotations(moi.getClass());
-    }
-
-    public static MBeanNotificationInfo[] findNotificationsFromAnnotations(
-            Class<?> mbeanClass) {
-        Class<?> c = getAnnotatedNotificationInfoClass(mbeanClass);
-        if (c == null)
-            return null;
-        NotificationInfo ni = c.getAnnotation(NotificationInfo.class);
-        NotificationInfos nis = c.getAnnotation(NotificationInfos.class);
-        List<NotificationInfo> list = newList();
-        if (ni != null)
-            list.add(ni);
-        if (nis != null)
-            list.addAll(Arrays.asList(nis.value()));
-        if (list.isEmpty())
-            return null;
-        List<MBeanNotificationInfo> mbnis = newList();
-        for (NotificationInfo x : list) {
-            // The Descriptor includes any fields explicitly specified by
-            // x.descriptorFields(), plus any fields from the contained
-            // @Description annotation.
-            Descriptor d = new ImmutableDescriptor(x.descriptorFields());
-            d = ImmutableDescriptor.union(
-                    d, Introspector.descriptorForAnnotation(x.description()));
-            MBeanNotificationInfo mbni = new MBeanNotificationInfo(
-                    x.types(), x.notificationClass().getName(),
-                    x.description().value(), d);
-            mbnis.add(mbni);
-        }
-        return mbnis.toArray(new MBeanNotificationInfo[mbnis.size()]);
-    }
-
-    private static final Map<Class<?>, WeakReference<Class<?>>>
-            annotatedNotificationInfoClasses = newWeakHashMap();
-
-    private static Class<?> getAnnotatedNotificationInfoClass(Class<?> baseClass) {
-        synchronized (annotatedNotificationInfoClasses) {
-            WeakReference<Class<?>> wr =
-                    annotatedNotificationInfoClasses.get(baseClass);
-            if (wr != null)
-                return wr.get();
-            Class<?> c = null;
-            if (baseClass.isAnnotationPresent(NotificationInfo.class) ||
-                    baseClass.isAnnotationPresent(NotificationInfos.class)) {
-                c = baseClass;
-            } else {
-                Class<?>[] intfs = baseClass.getInterfaces();
-                for (Class<?> intf : intfs) {
-                    Class<?> c1 = getAnnotatedNotificationInfoClass(intf);
-                    if (c1 != null) {
-                        if (c != null) {
-                            throw new IllegalArgumentException(
-                                    "Class " + baseClass.getName() + " inherits " +
-                                    "@NotificationInfo(s) from both " +
-                                    c.getName() + " and " + c1.getName());
-                        }
-                        c = c1;
-                    }
-                }
-            }
-            // Record the result of the search.  If no @NotificationInfo(s)
-            // were found, c is null, and we store a WeakReference(null).
-            // This prevents us from having to search again and fail again.
-            annotatedNotificationInfoClasses.put(baseClass,
-                    new WeakReference<Class<?>>(c));
-            return c;
-        }
+        return result;
     }
 
     private static MBeanConstructorInfo[] findConstructors(Class<?> c) {
         Constructor<?>[] cons = c.getConstructors();
         MBeanConstructorInfo[] mbc = new MBeanConstructorInfo[cons.length];
         for (int i = 0; i < cons.length; i++) {
-            String descr = "Public constructor of the MBean";
-            Description d = cons[i].getAnnotation(Description.class);
-            if (d != null)
-                descr = d.value();
+            final String descr = "Public constructor of the MBean";
             mbc[i] = new MBeanConstructorInfo(descr, cons[i]);
         }
         return mbc;
--- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -37,7 +37,7 @@
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
 import javax.management.ReflectionException;
-import javax.management.openmbean.MXBeanMappingFactory;
+import com.sun.jmx.mbeanserver.MXBeanMappingFactory;
 
 /**
  * Base class for MBeans.  There is one instance of this class for
@@ -121,8 +121,7 @@
 public abstract class MBeanSupport<M>
         implements DynamicMBean2, MBeanRegistration {
 
-    <T> MBeanSupport(T resource, Class<T> mbeanInterfaceType,
-                     MXBeanMappingFactory mappingFactory)
+    <T> MBeanSupport(T resource, Class<T> mbeanInterfaceType)
             throws NotCompliantMBeanException {
         if (mbeanInterfaceType == null)
             throw new NotCompliantMBeanException("Null MBean interface");
@@ -133,14 +132,13 @@
             throw new NotCompliantMBeanException(msg);
         }
         this.resource = resource;
-        MBeanIntrospector<M> introspector = getMBeanIntrospector(mappingFactory);
+        MBeanIntrospector<M> introspector = getMBeanIntrospector();
         this.perInterface = introspector.getPerInterface(mbeanInterfaceType);
         this.mbeanInfo = introspector.getMBeanInfo(resource, perInterface);
     }
 
     /** Return the appropriate introspector for this type of MBean. */
-    abstract MBeanIntrospector<M>
-            getMBeanIntrospector(MXBeanMappingFactory mappingFactory);
+    abstract MBeanIntrospector<M> getMBeanIntrospector();
 
     /**
      * Return a cookie for this MBean.  This cookie will be passed to
@@ -262,14 +260,10 @@
         return resource.getClass().getName();
     }
 
-    public final Object getWrappedObject() {
+    public final Object getResource() {
         return resource;
     }
 
-    public final ClassLoader getWrappedClassLoader() {
-        return resource.getClass().getClassLoader();
-    }
-
     public final Class<?> getMBeanInterface() {
         return perInterface.getMBeanInterface();
     }
--- a/src/share/classes/com/sun/jmx/mbeanserver/MXBeanIntrospector.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MXBeanIntrospector.java	Wed Nov 25 11:08:25 2009 -0800
@@ -28,26 +28,18 @@
 import com.sun.jmx.mbeanserver.MBeanIntrospector.MBeanInfoMap;
 import com.sun.jmx.mbeanserver.MBeanIntrospector.PerInterfaceMap;
 import java.lang.annotation.Annotation;
-import java.lang.ref.WeakReference;
 import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
-import java.util.Map;
-import java.util.WeakHashMap;
-import javax.management.Description;
 import javax.management.Descriptor;
 import javax.management.ImmutableDescriptor;
-import javax.management.IntrospectionException;
-import javax.management.JMX;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanException;
 import javax.management.MBeanOperationInfo;
 import javax.management.MBeanParameterInfo;
-import javax.management.ManagedOperation;
 import javax.management.NotCompliantMBeanException;
-import javax.management.openmbean.MXBeanMappingFactory;
 import javax.management.openmbean.OpenMBeanAttributeInfoSupport;
 import javax.management.openmbean.OpenMBeanOperationInfoSupport;
 import javax.management.openmbean.OpenMBeanParameterInfo;
@@ -60,36 +52,10 @@
  * @since 1.6
  */
 class MXBeanIntrospector extends MBeanIntrospector<ConvertingMethod> {
-    /* We keep one MXBeanIntrospector per MXBeanMappingFactory, since the results
-     * of the introspection depend on the factory.  The MXBeanIntrospector
-     * has a reference back to the factory, so we wrap it in a WeakReference.
-     * It will be strongly referenced by any MXBeanSupport instances using it;
-     * if there are none then it is OK to gc it.
-     */
-    private static final
-            Map<MXBeanMappingFactory, WeakReference<MXBeanIntrospector>> map =
-            new WeakHashMap<MXBeanMappingFactory, WeakReference<MXBeanIntrospector>>();
+    private static final MXBeanIntrospector instance = new MXBeanIntrospector();
 
-    static MXBeanIntrospector getInstance(MXBeanMappingFactory factory) {
-        if (factory == null)
-            factory = MXBeanMappingFactory.DEFAULT;
-        synchronized (map) {
-            MXBeanIntrospector intro;
-            WeakReference<MXBeanIntrospector> wr = map.get(factory);
-            if (wr != null) {
-                intro = wr.get();
-                if (intro != null)
-                    return intro;
-            }
-            intro = new MXBeanIntrospector(factory);
-            wr = new WeakReference<MXBeanIntrospector>(intro);
-            map.put(factory, wr);
-            return intro;
-        }
-    }
-
-    private MXBeanIntrospector(MXBeanMappingFactory factory) {
-        this.mappingFactory = factory;
+    static MXBeanIntrospector getInstance() {
+        return instance;
     }
 
     @Override
@@ -115,7 +81,7 @@
 
     @Override
     ConvertingMethod mFrom(Method m) {
-        return ConvertingMethod.from(m, mappingFactory);
+        return ConvertingMethod.from(m);
     }
 
     @Override
@@ -176,17 +142,13 @@
 
     @Override
     MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
-            ConvertingMethod getter, ConvertingMethod setter)
-            throws IntrospectionException {
+            ConvertingMethod getter, ConvertingMethod setter) {
 
         final boolean isReadable = (getter != null);
         final boolean isWritable = (setter != null);
         final boolean isIs = isReadable && getName(getter).startsWith("is");
 
-        final String description = getAttributeDescription(
-                attributeName, attributeName,
-                getter == null ? null : getter.getMethod(),
-                setter == null ? null : setter.getMethod());
+        final String description = attributeName;
 
         final OpenType<?> openType;
         final Type originalType;
@@ -235,17 +197,13 @@
     MBeanOperationInfo getMBeanOperationInfo(String operationName,
             ConvertingMethod operation) {
         final Method method = operation.getMethod();
-        String description = operationName;
+        final String description = operationName;
         /* Ideally this would be an empty string, but
-           OMBOperationInfo constructor forbids that.  */
-        Description d = method.getAnnotation(Description.class);
-        if (d != null)
-            description = d.value();
+           OMBOperationInfo constructor forbids that.  Also, we
+           could consult an annotation to get a useful
+           description.  */
 
-        int impact = MBeanOperationInfo.UNKNOWN;
-        ManagedOperation annot = method.getAnnotation(ManagedOperation.class);
-        if (annot != null)
-            impact = annot.impact().getCode();
+        final int impact = MBeanOperationInfo.UNKNOWN;
 
         final OpenType<?> returnType = operation.getOpenReturnType();
         final Type originalReturnType = operation.getGenericReturnType();
@@ -257,15 +215,8 @@
         boolean openParameterTypes = true;
         Annotation[][] annots = method.getParameterAnnotations();
         for (int i = 0; i < paramTypes.length; i++) {
-            String paramName = Introspector.nameForParameter(annots[i]);
-            if (paramName == null)
-                paramName = "p" + i;
-
-            String paramDescription =
-                    Introspector.descriptionForParameter(annots[i]);
-            if (paramDescription == null)
-                paramDescription = paramName;
-
+            final String paramName = "p" + i;
+            final String paramDescription = paramName;
             final OpenType<?> openType = paramTypes[i];
             final Type originalType = originalParamTypes[i];
             Descriptor descriptor =
@@ -292,7 +243,7 @@
         Descriptor descriptor =
             typeDescriptor(returnType, originalReturnType);
         descriptor = ImmutableDescriptor.union(descriptor,
-                Introspector.descriptorForElement(method, false));
+                Introspector.descriptorForElement(method));
         final MBeanOperationInfo oi;
         if (openReturnType && openParameterTypes) {
             /* If the return value and all the parameters can be faithfully
@@ -343,17 +294,6 @@
         return ImmutableDescriptor.EMPTY_DESCRIPTOR;
     }
 
-    @Override
-    Descriptor getSpecificMBeanDescriptor() {
-        if (mappingFactory == MXBeanMappingFactory.DEFAULT)
-            return ImmutableDescriptor.EMPTY_DESCRIPTOR;
-        else {
-            return new ImmutableDescriptor(
-                    JMX.MXBEAN_MAPPING_FACTORY_CLASS_FIELD + "=" +
-                    mappingFactory.getClass().getName());
-        }
-    }
-
     private static Descriptor typeDescriptor(OpenType<?> openType,
                                              Type originalType) {
         return new ImmutableDescriptor(
@@ -421,7 +361,5 @@
     private final PerInterfaceMap<ConvertingMethod>
         perInterfaceMap = new PerInterfaceMap<ConvertingMethod>();
 
-    private final MBeanInfoMap mbeanInfoMap = new MBeanInfoMap();
-
-    private final MXBeanMappingFactory mappingFactory;
+    private static final MBeanInfoMap mbeanInfoMap = new MBeanInfoMap();
 }
--- a/src/share/classes/com/sun/jmx/mbeanserver/MXBeanLookup.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MXBeanLookup.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,8 +25,6 @@
 
 package com.sun.jmx.mbeanserver;
 
-import com.sun.jmx.remote.util.EnvHelp;
-import java.io.InvalidObjectException;
 import static com.sun.jmx.mbeanserver.Util.*;
 import java.util.Map;
 import java.lang.ref.WeakReference;
@@ -85,181 +83,87 @@
  *
  * From the above, it is clear that the logic for getX on an MXBean is
  * the same as for setX on a proxy, and vice versa.
- *
- * The above describes the logic for "plain" MXBeanLookup, represented
- * by MXBeanLookup.Plain.  When namespaces enter the picture, we see
- * MXBeanLookup.Prefix.  Here, the idea is that the name of the ModuleMXBean
- * might be a//m:m=m.  In this case, we don't accept a reference to
- * an MXBean object, since that would require different namespaces to know
- * each others' objects.  We only accept proxies.  Suppose you have a proxy
- * for a//m:m=m, call it moduleProxy, and you call
- * moduleProxy.setProduct(productProxy).  Then if productProxy is for
- * a//p:p=p we should convert this to just p:p=p.  If productProxy is for
- * a//b//p:p=p we should convert it to b//p:p=p.  Conversely, if getProduct
- * returns an ObjectName like b//p:p=p then we should convert it into a proxy
- * for a//b//p:p=p.
  */
-public abstract class MXBeanLookup {
+public class MXBeanLookup {
     private MXBeanLookup(MBeanServerConnection mbsc) {
         this.mbsc = mbsc;
     }
 
-    static MXBeanLookup lookupFor(MBeanServerConnection mbsc, String prefix) {
-        if (prefix == null)
-            return Plain.lookupFor(mbsc);
-        else
-            return new Prefix(mbsc, prefix);
-    }
-
-    abstract <T> T objectNameToMXBean(ObjectName name, Class<T> type)
-            throws InvalidObjectException;
-
-    abstract ObjectName mxbeanToObjectName(Object mxbean)
-            throws OpenDataException;
-
-    static class Plain extends MXBeanLookup {
-        Plain(MBeanServerConnection mbsc) {
-            super(mbsc);
-        }
-
-        static Plain lookupFor(MBeanServerConnection mbsc) {
-            synchronized (mbscToLookup) {
-                WeakReference<Plain> weakLookup = mbscToLookup.get(mbsc);
-                Plain lookup = (weakLookup == null) ? null : weakLookup.get();
-                if (lookup == null) {
-                    lookup = new Plain(mbsc);
-                    mbscToLookup.put(mbsc, new WeakReference<Plain>(lookup));
-                }
-                return lookup;
-            }
-        }
-
-        @Override
-        synchronized <T> T objectNameToMXBean(ObjectName name, Class<T> type) {
-            WeakReference<Object> wr = objectNameToProxy.get(name);
-            if (wr != null) {
-                Object proxy = wr.get();
-                if (type.isInstance(proxy))
-                    return type.cast(proxy);
-            }
-            T proxy = JMX.newMXBeanProxy(mbsc, name, type);
-            objectNameToProxy.put(name, new WeakReference<Object>(proxy));
-            return proxy;
-        }
-
-        @Override
-        synchronized ObjectName mxbeanToObjectName(Object mxbean)
-        throws OpenDataException {
-            String wrong;
-            if (mxbean instanceof Proxy) {
-                InvocationHandler ih = Proxy.getInvocationHandler(mxbean);
-                if (ih instanceof MBeanServerInvocationHandler) {
-                    MBeanServerInvocationHandler mbsih =
-                            (MBeanServerInvocationHandler) ih;
-                    if (mbsih.getMBeanServerConnection().equals(mbsc))
-                        return mbsih.getObjectName();
-                    else
-                        wrong = "proxy for a different MBeanServer";
-                } else
-                    wrong = "not a JMX proxy";
-            } else {
-                ObjectName name = mxbeanToObjectName.get(mxbean);
-                if (name != null)
-                    return name;
-                wrong = "not an MXBean registered in this MBeanServer";
+    static MXBeanLookup lookupFor(MBeanServerConnection mbsc) {
+        synchronized (mbscToLookup) {
+            WeakReference<MXBeanLookup> weakLookup = mbscToLookup.get(mbsc);
+            MXBeanLookup lookup = (weakLookup == null) ? null : weakLookup.get();
+            if (lookup == null) {
+                lookup = new MXBeanLookup(mbsc);
+                mbscToLookup.put(mbsc, new WeakReference<MXBeanLookup>(lookup));
             }
-            String s = (mxbean == null) ?
-                "null" : "object of type " + mxbean.getClass().getName();
-            throw new OpenDataException(
-                    "Could not convert " + s + " to an ObjectName: " + wrong);
-            // Message will be strange if mxbean is null but it is not
-            // supposed to be.
-        }
-
-        synchronized void addReference(ObjectName name, Object mxbean)
-        throws InstanceAlreadyExistsException {
-            ObjectName existing = mxbeanToObjectName.get(mxbean);
-            if (existing != null) {
-                String multiname = AccessController.doPrivileged(
-                        new GetPropertyAction("jmx.mxbean.multiname"));
-                if (!"true".equalsIgnoreCase(multiname)) {
-                    throw new InstanceAlreadyExistsException(
-                            "MXBean already registered with name " + existing);
-                }
-            }
-            mxbeanToObjectName.put(mxbean, name);
-        }
-
-        synchronized boolean removeReference(ObjectName name, Object mxbean) {
-            if (name.equals(mxbeanToObjectName.get(mxbean))) {
-                mxbeanToObjectName.remove(mxbean);
-                return true;
-            } else
-                return false;
-            /* removeReference can be called when the above condition fails,
-             * notably if you try to register the same MXBean twice.
-             */
-        }
-
-        private final WeakIdentityHashMap<Object, ObjectName>
-            mxbeanToObjectName = WeakIdentityHashMap.make();
-        private final Map<ObjectName, WeakReference<Object>>
-            objectNameToProxy = newMap();
-        private static WeakIdentityHashMap<MBeanServerConnection,
-                                           WeakReference<Plain>>
-            mbscToLookup = WeakIdentityHashMap.make();
-    }
-
-    private static class Prefix extends MXBeanLookup {
-        private final String prefix;
-
-        Prefix(MBeanServerConnection mbsc, String prefix) {
-            super(mbsc);
-            this.prefix = prefix;
-        }
-
-        @Override
-        <T> T objectNameToMXBean(ObjectName name, Class<T> type)
-        throws InvalidObjectException {
-            String domain = prefix + name.getDomain();
-            try {
-                name = name.withDomain(domain);
-            } catch (IllegalArgumentException e) {
-                throw EnvHelp.initCause(
-                        new InvalidObjectException(e.getMessage()), e);
-            }
-            return JMX.newMXBeanProxy(mbsc, name, type);
-        }
-
-        @Override
-        ObjectName mxbeanToObjectName(Object mxbean)
-        throws OpenDataException {
-            ObjectName name = proxyToObjectName(mxbean);
-            String domain = name.getDomain();
-            if (!domain.startsWith(prefix)) {
-                throw new OpenDataException(
-                        "Proxy's name does not start with " +
-                        prefix + ": " + name);
-            }
-            try {
-                name = name.withDomain(domain.substring(prefix.length()));
-            } catch (IllegalArgumentException e) {
-                throw EnvHelp.initCause(
-                        new OpenDataException(e.getMessage()), e);
-            }
-            return name;
+            return lookup;
         }
     }
 
-    ObjectName proxyToObjectName(Object proxy) {
-        InvocationHandler ih = Proxy.getInvocationHandler(proxy);
-        if (ih instanceof MBeanServerInvocationHandler) {
-            MBeanServerInvocationHandler mbsih =
-                    (MBeanServerInvocationHandler) ih;
-            if (mbsih.getMBeanServerConnection().equals(mbsc))
-                return mbsih.getObjectName();
+    synchronized <T> T objectNameToMXBean(ObjectName name, Class<T> type) {
+        WeakReference<Object> wr = objectNameToProxy.get(name);
+        if (wr != null) {
+            Object proxy = wr.get();
+            if (type.isInstance(proxy))
+                return type.cast(proxy);
+        }
+        T proxy = JMX.newMXBeanProxy(mbsc, name, type);
+        objectNameToProxy.put(name, new WeakReference<Object>(proxy));
+        return proxy;
+    }
+
+    synchronized ObjectName mxbeanToObjectName(Object mxbean)
+    throws OpenDataException {
+        String wrong;
+        if (mxbean instanceof Proxy) {
+            InvocationHandler ih = Proxy.getInvocationHandler(mxbean);
+            if (ih instanceof MBeanServerInvocationHandler) {
+                MBeanServerInvocationHandler mbsih =
+                        (MBeanServerInvocationHandler) ih;
+                if (mbsih.getMBeanServerConnection().equals(mbsc))
+                    return mbsih.getObjectName();
+                else
+                    wrong = "proxy for a different MBeanServer";
+            } else
+                wrong = "not a JMX proxy";
+        } else {
+            ObjectName name = mxbeanToObjectName.get(mxbean);
+            if (name != null)
+                return name;
+            wrong = "not an MXBean registered in this MBeanServer";
         }
-        return null;
+        String s = (mxbean == null) ?
+            "null" : "object of type " + mxbean.getClass().getName();
+        throw new OpenDataException(
+                "Could not convert " + s + " to an ObjectName: " + wrong);
+        // Message will be strange if mxbean is null but it is not
+        // supposed to be.
+    }
+
+    synchronized void addReference(ObjectName name, Object mxbean)
+    throws InstanceAlreadyExistsException {
+        ObjectName existing = mxbeanToObjectName.get(mxbean);
+        if (existing != null) {
+            String multiname = AccessController.doPrivileged(
+                    new GetPropertyAction("jmx.mxbean.multiname"));
+            if (!"true".equalsIgnoreCase(multiname)) {
+                throw new InstanceAlreadyExistsException(
+                        "MXBean already registered with name " + existing);
+            }
+        }
+        mxbeanToObjectName.put(mxbean, name);
+    }
+
+    synchronized boolean removeReference(ObjectName name, Object mxbean) {
+        if (name.equals(mxbeanToObjectName.get(mxbean))) {
+            mxbeanToObjectName.remove(mxbean);
+            return true;
+        } else
+            return false;
+        /* removeReference can be called when the above condition fails,
+         * notably if you try to register the same MXBean twice.
+         */
     }
 
     static MXBeanLookup getLookup() {
@@ -273,5 +177,12 @@
     private static final ThreadLocal<MXBeanLookup> currentLookup =
             new ThreadLocal<MXBeanLookup>();
 
-    final MBeanServerConnection mbsc;
+    private final MBeanServerConnection mbsc;
+    private final WeakIdentityHashMap<Object, ObjectName>
+        mxbeanToObjectName = WeakIdentityHashMap.make();
+    private final Map<ObjectName, WeakReference<Object>>
+        objectNameToProxy = newMap();
+    private static final WeakIdentityHashMap<MBeanServerConnection,
+                                             WeakReference<MXBeanLookup>>
+        mbscToLookup = WeakIdentityHashMap.make();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MXBeanMapping.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,210 @@
+/*
+ * 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.
+ */
+
+package com.sun.jmx.mbeanserver;
+
+import java.io.InvalidObjectException;
+import java.lang.reflect.Type;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.OpenType;
+
+/**
+ * <p>A custom mapping between Java types and Open types for use in MXBeans.
+ * To define such a mapping, subclass this class and define at least the
+ * {@link #fromOpenValue fromOpenValue} and {@link #toOpenValue toOpenValue}
+ * methods, and optionally the {@link #checkReconstructible} method.
+ * Then either use an {@link MXBeanMappingClass} annotation on your custom
+ * Java types, or include this MXBeanMapping in an
+ * {@link MXBeanMappingFactory}.</p>
+ *
+ * <p>For example, suppose we have a class {@code MyLinkedList}, which looks
+ * like this:</p>
+ *
+ * <pre>
+ * public class MyLinkedList {
+ *     public MyLinkedList(String name, MyLinkedList next) {...}
+ *     public String getName() {...}
+ *     public MyLinkedList getNext() {...}
+ * }
+ * </pre>
+ *
+ * <p>This is not a valid type for MXBeans, because it contains a
+ * self-referential property "next" defined by the {@code getNext()}
+ * method.  MXBeans do not support recursive types.  So we would like
+ * to specify a mapping for {@code MyLinkedList} explicitly. When an
+ * MXBean interface contains {@code MyLinkedList}, that will be mapped
+ * into a {@code String[]}, which is a valid Open Type.</p>
+ *
+ * <p>To define this mapping, we first subclass {@code MXBeanMapping}:</p>
+ *
+ * <pre>
+ * public class MyLinkedListMapping extends MXBeanMapping {
+ *     public MyLinkedListMapping(Type type) throws OpenDataException {
+ *         super(MyLinkedList.class, ArrayType.getArrayType(SimpleType.STRING));
+ *         if (type != MyLinkedList.class)
+ *             throw new OpenDataException("Mapping only valid for MyLinkedList");
+ *     }
+ *
+ *     {@literal @Override}
+ *     public Object fromOpenValue(Object openValue) throws InvalidObjectException {
+ *         String[] array = (String[]) openValue;
+ *         MyLinkedList list = null;
+ *         for (int i = array.length - 1; i &gt;= 0; i--)
+ *             list = new MyLinkedList(array[i], list);
+ *         return list;
+ *     }
+ *
+ *     {@literal @Override}
+ *     public Object toOpenValue(Object javaValue) throws OpenDataException {
+ *         ArrayList&lt;String&gt; array = new ArrayList&lt;String&gt;();
+ *         for (MyLinkedList list = (MyLinkedList) javaValue; list != null;
+ *              list = list.getNext())
+ *             array.add(list.getName());
+ *         return array.toArray(new String[0]);
+ *     }
+ * }
+ * </pre>
+ *
+ * <p>The call to the superclass constructor specifies what the
+ * original Java type is ({@code MyLinkedList.class}) and what Open
+ * Type it is mapped to ({@code
+ * ArrayType.getArrayType(SimpleType.STRING)}). The {@code
+ * fromOpenValue} method says how we go from the Open Type ({@code
+ * String[]}) to the Java type ({@code MyLinkedList}), and the {@code
+ * toOpenValue} method says how we go from the Java type to the Open
+ * Type.</p>
+ *
+ * <p>With this mapping defined, we can annotate the {@code MyLinkedList}
+ * class appropriately:</p>
+ *
+ * <pre>
+ * {@literal @MXBeanMappingClass}(MyLinkedListMapping.class)
+ * public class MyLinkedList {...}
+ * </pre>
+ *
+ * <p>Now we can use {@code MyLinkedList} in an MXBean interface and it
+ * will work.</p>
+ *
+ * <p>If we are unable to modify the {@code MyLinkedList} class,
+ * we can define an {@link MXBeanMappingFactory}.  See the documentation
+ * of that class for further details.</p>
+ *
+ * @see <a href="../MXBean.html#custom">MXBean specification, section
+ * "Custom MXBean type mappings"</a>
+ */
+public abstract class MXBeanMapping {
+    private final Type javaType;
+    private final OpenType<?> openType;
+    private final Class<?> openClass;
+
+    /**
+     * <p>Construct a mapping between the given Java type and the given
+     * Open Type.</p>
+     *
+     * @param javaType the Java type (for example, {@code MyLinkedList}).
+     * @param openType the Open Type (for example, {@code
+     * ArrayType.getArrayType(SimpleType.STRING)})
+     *
+     * @throws NullPointerException if either argument is null.
+     */
+    protected MXBeanMapping(Type javaType, OpenType<?> openType) {
+        if (javaType == null || openType == null)
+            throw new NullPointerException("Null argument");
+        this.javaType = javaType;
+        this.openType = openType;
+        this.openClass = makeOpenClass(javaType, openType);
+    }
+
+    /**
+     * <p>The Java type that was supplied to the constructor.</p>
+     * @return the Java type that was supplied to the constructor.
+     */
+    public final Type getJavaType() {
+        return javaType;
+    }
+
+    /**
+     * <p>The Open Type that was supplied to the constructor.</p>
+     * @return the Open Type that was supplied to the constructor.
+     */
+    public final OpenType<?> getOpenType() {
+        return openType;
+    }
+
+    /**
+     * <p>The Java class that corresponds to instances of the
+     * {@linkplain #getOpenType() Open Type} for this mapping.</p>
+     * @return the Java class that corresponds to instances of the
+     * Open Type for this mapping.
+     * @see OpenType#getClassName
+     */
+    public final Class<?> getOpenClass() {
+        return openClass;
+    }
+
+    private static Class<?> makeOpenClass(Type javaType, OpenType<?> openType) {
+        if (javaType instanceof Class<?> && ((Class<?>) javaType).isPrimitive())
+            return (Class<?>) javaType;
+        try {
+            String className = openType.getClassName();
+            return Class.forName(className, false, null);
+        } catch (ClassNotFoundException e) {
+            throw new RuntimeException(e);  // should not happen
+        }
+    }
+
+    /**
+     * <p>Convert an instance of the Open Type into the Java type.
+     * @param openValue the value to be converted.
+     * @return the converted value.
+     * @throws InvalidObjectException if the value cannot be converted.
+     */
+    public abstract Object fromOpenValue(Object openValue)
+    throws InvalidObjectException;
+
+    /**
+     * <p>Convert an instance of the Java type into the Open Type.
+     * @param javaValue the value to be converted.
+     * @return the converted value.
+     * @throws OpenDataException if the value cannot be converted.
+     */
+    public abstract Object toOpenValue(Object javaValue)
+    throws OpenDataException;
+
+
+    /**
+     * <p>Throw an appropriate InvalidObjectException if we will not
+     * be able to convert back from the open data to the original Java
+     * object.  The {@link #fromOpenValue fromOpenValue} throws an
+     * exception if a given open data value cannot be converted.  This
+     * method throws an exception if <em>no</em> open data values can
+     * be converted.  The default implementation of this method never
+     * throws an exception.  Subclasses can override it as
+     * appropriate.</p>
+     * @throws InvalidObjectException if {@code fromOpenValue} will throw
+     * an exception no matter what its argument is.
+     */
+    public void checkReconstructible() throws InvalidObjectException {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MXBeanMappingFactory.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+package com.sun.jmx.mbeanserver;
+
+import javax.management.openmbean.*;
+import com.sun.jmx.mbeanserver.MXBeanMapping;
+import com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory;
+import java.lang.reflect.Type;
+
+/**
+ * <p>Defines how types are mapped for a given MXBean or set of MXBeans.
+ * An {@code MXBeanMappingFactory} can be specified either through the
+ * {@link MXBeanMappingFactoryClass} annotation, or through the
+ * {@link javax.management.JMX.MBeanOptions JMX.MBeanOptions} argument to a
+ * {@link javax.management.StandardMBean StandardMBean} constructor or MXBean
+ * proxy.</p>
+ *
+ * <p>An {@code MXBeanMappingFactory} must return an {@code MXBeanMapping}
+ * for any Java type that appears in the MXBeans that the factory is being
+ * used for.  Usually it does that by handling any custom types, and
+ * forwarding everything else to the {@linkplain #DEFAULT default mapping
+ * factory}.</p>
+ *
+ * <p>Consider the {@code MyLinkedList} example from the {@link MXBeanMapping}
+ * documentation.  If we are unable to change the {@code MyLinkedList} class
+ * to add an {@link MXBeanMappingClass} annotation, we could achieve the same
+ * effect by defining {@code MyLinkedListMappingFactory} as follows:</p>
+ *
+ * <pre>
+ * public class MyLinkedListMappingFactory extends MXBeanMappingFactory {
+ *     public MyLinkedListMappingFactory() {}
+ *
+ *     public MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f)
+ *     throws OpenDataException {
+ *         if (t == MyLinkedList.class)
+ *             return new MyLinkedListMapping(t);
+ *         else
+ *             return MXBeanMappingFactory.DEFAULT.mappingForType(t, f);
+ *     }
+ * }
+ * </pre>
+ *
+ * <p>The mapping factory handles only the {@code MyLinkedList} class.
+ * Every other type is forwarded to the default mapping factory.
+ * This includes types such as {@code MyLinkedList[]} and
+ * {@code List<MyLinkedList>}; the default mapping factory will recursively
+ * invoke {@code MyLinkedListMappingFactory} to map the contained
+ * {@code MyLinkedList} type.</p>
+ *
+ * <p>Once we have defined {@code MyLinkedListMappingFactory}, we can use
+ * it in an MXBean interface like this:</p>
+ *
+ * <pre>
+ * {@literal @MXBeanMappingFactoryClass}(MyLinkedListMappingFactory.class)
+ * public interface SomethingMXBean {
+ *     public MyLinkedList getSomething();
+ * }
+ * </pre>
+ *
+ * <p>Alternatively we can annotate the package that {@code SomethingMXBean}
+ * appears in, or we can supply the factory to a {@link
+ * javax.management.StandardMBean StandardMBean} constructor or MXBean
+ * proxy.</p>
+ *
+ * @see <a href="../MXBean.html#custom">MXBean specification, section
+ * "Custom MXBean type mappings"</a>
+ */
+public abstract class MXBeanMappingFactory {
+    /**
+     * <p>Construct an instance of this class.</p>
+     */
+    protected MXBeanMappingFactory() {}
+
+    /**
+     * <p>Mapping factory that applies the default rules for MXBean
+     * mappings, as described in the <a
+     * href="../MXBean.html#MXBean-spec">MXBean specification</a>.</p>
+     */
+    public static final MXBeanMappingFactory DEFAULT =
+            new DefaultMXBeanMappingFactory();
+
+    /**
+     * <p>Return the mapping for the given Java type.  Typically, a
+     * mapping factory will return mappings for types it handles, and
+     * forward other types to another mapping factory, most often
+     * the {@linkplain #DEFAULT default one}.</p>
+     * @param t the Java type to be mapped.
+     * @param f the original mapping factory that was consulted to do
+     * the mapping.  A mapping factory should pass this parameter intact
+     * if it forwards a type to another mapping factory.  In the example,
+     * this is how {@code MyLinkedListMappingFactory} works for types
+     * like {@code MyLinkedList[]} and {@code List<MyLinkedList>}.
+     * @return the mapping for the given type.
+     * @throws OpenDataException if this type cannot be mapped.  This
+     * exception is appropriate if the factory is supposed to handle
+     * all types of this sort (for example, all linked lists), but
+     * cannot handle this particular type.
+     */
+    public abstract MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f)
+    throws OpenDataException;
+}
--- a/src/share/classes/com/sun/jmx/mbeanserver/MXBeanProxy.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MXBeanProxy.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,10 +32,8 @@
 
 import javax.management.Attribute;
 import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
-import javax.management.openmbean.MXBeanMappingFactory;
 
 /**
    <p>Helper class for an {@link InvocationHandler} that forwards methods from an
@@ -47,7 +45,7 @@
    @since 1.6
 */
 public class MXBeanProxy {
-    public MXBeanProxy(Class<?> mxbeanInterface, MXBeanMappingFactory factory) {
+    public MXBeanProxy(Class<?> mxbeanInterface) {
 
         if (mxbeanInterface == null)
             throw new IllegalArgumentException("Null parameter");
@@ -55,7 +53,7 @@
         final MBeanAnalyzer<ConvertingMethod> analyzer;
         try {
             analyzer =
-                MXBeanIntrospector.getInstance(factory).getAnalyzer(mxbeanInterface);
+                MXBeanIntrospector.getInstance().getAnalyzer(mxbeanInterface);
         } catch (NotCompliantMBeanException e) {
             throw new IllegalArgumentException(e);
         }
@@ -63,7 +61,7 @@
     }
 
     private class Visitor
-            implements MBeanAnalyzer.MBeanVisitor<ConvertingMethod, RuntimeException> {
+            implements MBeanAnalyzer.MBeanVisitor<ConvertingMethod> {
         public void visitAttribute(String attributeName,
                                    ConvertingMethod getter,
                                    ConvertingMethod setter) {
@@ -161,8 +159,7 @@
 
         Handler handler = handlerMap.get(method);
         ConvertingMethod cm = handler.getConvertingMethod();
-        String prefix = extractPrefix(name);
-        MXBeanLookup lookup = MXBeanLookup.lookupFor(mbsc, prefix);
+        MXBeanLookup lookup = MXBeanLookup.lookupFor(mbsc);
         MXBeanLookup oldLookup = MXBeanLookup.getLookup();
         try {
             MXBeanLookup.setLookup(lookup);
@@ -174,17 +171,5 @@
         }
     }
 
-    private static String extractPrefix(ObjectName name)
-            throws MalformedObjectNameException {
-        String domain = name.getDomain();
-        int slashslash = domain.lastIndexOf("//");
-        if (slashslash > 0 && domain.charAt(slashslash - 1) == '/')
-            slashslash--;
-        if (slashslash >= 0)
-            return domain.substring(0, slashslash + 2);
-        else
-            return null;
-    }
-
     private final Map<Method, Handler> handlerMap = newMap();
 }
--- a/src/share/classes/com/sun/jmx/mbeanserver/MXBeanSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/MXBeanSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -35,7 +35,6 @@
 import javax.management.MBeanServer;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
-import javax.management.openmbean.MXBeanMappingFactory;
 
 /**
  * Base class for MXBeans.
@@ -62,16 +61,14 @@
        if it does not implement the class {@code mxbeanInterface} or if
        that class is not a valid MXBean interface.
     */
-    public <T> MXBeanSupport(T resource, Class<T> mxbeanInterface,
-                             MXBeanMappingFactory mappingFactory)
+    public <T> MXBeanSupport(T resource, Class<T> mxbeanInterface)
             throws NotCompliantMBeanException {
-        super(resource, mxbeanInterface, mappingFactory);
+        super(resource, mxbeanInterface);
     }
 
     @Override
-    MBeanIntrospector<ConvertingMethod>
-            getMBeanIntrospector(MXBeanMappingFactory mappingFactory) {
-        return MXBeanIntrospector.getInstance(mappingFactory);
+    MBeanIntrospector<ConvertingMethod> getMBeanIntrospector() {
+        return MXBeanIntrospector.getInstance();
     }
 
     @Override
@@ -159,8 +156,8 @@
         // eventually we could have some logic to supply a default name
 
         synchronized (lock) {
-            this.mxbeanLookup = MXBeanLookup.Plain.lookupFor(server);
-            this.mxbeanLookup.addReference(name, getWrappedObject());
+            this.mxbeanLookup = MXBeanLookup.lookupFor(server);
+            this.mxbeanLookup.addReference(name, getResource());
             this.objectName = name;
         }
     }
@@ -169,19 +166,13 @@
     public void unregister() {
         synchronized (lock) {
             if (mxbeanLookup != null) {
-                if (mxbeanLookup.removeReference(objectName, getWrappedObject()))
+                if (mxbeanLookup.removeReference(objectName, getResource()))
                     objectName = null;
             }
-            // XXX: need to revisit the whole register/unregister logic in
-            // the face of wrapping.  The mxbeanLookup!=null test is a hack.
-            // If you wrap an MXBean in a MyWrapperMBean and register it,
-            // the lookup table should contain the wrapped object.  But that
-            // implies that MyWrapperMBean calls register, which today it
-            // can't within the public API.
         }
     }
     private final Object lock = new Object(); // for mxbeanLookup and objectName
 
-    private MXBeanLookup.Plain mxbeanLookup;
+    private MXBeanLookup mxbeanLookup;
     private ObjectName objectName;
 }
--- a/src/share/classes/com/sun/jmx/mbeanserver/NotificationMBeanSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.mbeanserver;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.openmbean.MXBeanMappingFactory;
-
-/**
- * <p>A variant of {@code StandardMBeanSupport} where the only
- * methods included are public getters.  This is used by
- * {@code QueryNotificationFilter} to pretend that a Notification is
- * an MBean so it can have a query evaluated on it.  Standard queries
- * never set attributes or invoke methods but custom queries could and
- * we don't want to allow that.  Also we don't want to fail if a
- * Notification happens to have inconsistent types in a pair of getX and
- * setX methods, and we want to include the Object.getClass() method.
- */
-public class NotificationMBeanSupport extends StandardMBeanSupport {
-    public <T extends Notification> NotificationMBeanSupport(T n)
-            throws NotCompliantMBeanException {
-        super(n, Util.<Class<T>>cast(n.getClass()));
-    }
-
-    @Override
-    MBeanIntrospector<Method> getMBeanIntrospector(MXBeanMappingFactory ignored) {
-        return introspector;
-    }
-
-    private static class Introspector extends StandardMBeanIntrospector {
-        @Override
-        void checkCompliance(Class<?> mbeanType) {}
-
-        @Override
-        List<Method> getMethods(final Class<?> mbeanType)
-                throws Exception {
-            List<Method> methods = new ArrayList<Method>();
-            for (Method m : mbeanType.getMethods()) {
-                String name = m.getName();
-                Class<?> ret = m.getReturnType();
-                if (m.getParameterTypes().length == 0) {
-                    if ((name.startsWith("is") && name.length() > 2 &&
-                            ret == boolean.class) ||
-                        (name.startsWith("get") && name.length() > 3 &&
-                            ret != void.class)) {
-                        methods.add(m);
-                    }
-                }
-            }
-            return methods;
-        }
-
-    }
-    private static final MBeanIntrospector<Method> introspector =
-            new Introspector();
-}
--- a/src/share/classes/com/sun/jmx/mbeanserver/NotifySupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.mbeanserver;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.DynamicWrapperMBean;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-/**
- * Create wrappers for DynamicMBean that implement NotificationEmitter
- * and SendNotification.
- */
-public class NotifySupport
-        implements DynamicMBean2, NotificationEmitter, MBeanRegistration {
-
-    private final DynamicMBean mbean;
-    private final NotificationBroadcasterSupport nbs;
-
-    public static DynamicMBean wrap(
-            DynamicMBean mbean, NotificationBroadcasterSupport nbs) {
-        return new NotifySupport(mbean, nbs);
-    }
-
-    private NotifySupport(DynamicMBean mbean, NotificationBroadcasterSupport nbs) {
-        this.mbean = mbean;
-        this.nbs = nbs;
-    }
-
-    public static NotificationBroadcasterSupport getNB(DynamicMBean mbean) {
-        if (mbean instanceof NotifySupport)
-            return ((NotifySupport) mbean).nbs;
-        else
-            return null;
-    }
-
-    public String getClassName() {
-        if (mbean instanceof DynamicMBean2)
-            return ((DynamicMBean2) mbean).getClassName();
-        Object w = mbean;
-        if (w instanceof DynamicWrapperMBean)
-            w = ((DynamicWrapperMBean) w).getWrappedObject();
-        return w.getClass().getName();
-    }
-
-    public void preRegister2(MBeanServer mbs, ObjectName name) throws Exception {
-        if (mbean instanceof DynamicMBean2)
-            ((DynamicMBean2) mbean).preRegister2(mbs, name);
-    }
-
-    public void registerFailed() {
-        if (mbean instanceof DynamicMBean2)
-            ((DynamicMBean2) mbean).registerFailed();
-    }
-
-    public Object getWrappedObject() {
-        if (mbean instanceof DynamicWrapperMBean)
-            return ((DynamicWrapperMBean) mbean).getWrappedObject();
-        else
-            return mbean;
-    }
-
-    public ClassLoader getWrappedClassLoader() {
-        if (mbean instanceof DynamicWrapperMBean)
-            return ((DynamicWrapperMBean) mbean).getWrappedClassLoader();
-        else
-            return mbean.getClass().getClassLoader();
-    }
-
-    public Object getAttribute(String attribute) throws AttributeNotFoundException,
-                                                        MBeanException,
-                                                        ReflectionException {
-        return mbean.getAttribute(attribute);
-    }
-
-    public void setAttribute(Attribute attribute) throws AttributeNotFoundException,
-                                                         InvalidAttributeValueException,
-                                                         MBeanException,
-                                                         ReflectionException {
-        mbean.setAttribute(attribute);
-    }
-
-    public AttributeList setAttributes(AttributeList attributes) {
-        return mbean.setAttributes(attributes);
-    }
-
-    public Object invoke(String actionName, Object[] params, String[] signature)
-            throws MBeanException, ReflectionException {
-        return mbean.invoke(actionName, params, signature);
-    }
-
-    public MBeanInfo getMBeanInfo() {
-        return mbean.getMBeanInfo();
-    }
-
-    public AttributeList getAttributes(String[] attributes) {
-        return mbean.getAttributes(attributes);
-    }
-
-    public void removeNotificationListener(NotificationListener listener,
-                                           NotificationFilter filter,
-                                           Object handback) throws ListenerNotFoundException {
-        nbs.removeNotificationListener(listener, filter, handback);
-    }
-
-    public void removeNotificationListener(NotificationListener listener)
-            throws ListenerNotFoundException {
-        nbs.removeNotificationListener(listener);
-    }
-
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return nbs.getNotificationInfo();
-    }
-
-    public void addNotificationListener(NotificationListener listener,
-                                        NotificationFilter filter,
-                                        Object handback) {
-        nbs.addNotificationListener(listener, filter, handback);
-    }
-
-    public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
-        if (mbr() != null)
-            return mbr().preRegister(server, name);
-        else
-            return name;
-    }
-
-    public void postRegister(Boolean registrationDone) {
-        if (mbr() != null)
-            mbr().postRegister(registrationDone);
-    }
-
-    public void preDeregister() throws Exception {
-        if (mbr() != null)
-            mbr().preDeregister();
-    }
-
-    public void postDeregister() {
-        if (mbr() != null)
-            mbr().postDeregister();
-    }
-
-    private MBeanRegistration mbr() {
-        if (mbean instanceof MBeanRegistration)
-            return (MBeanRegistration) mbean;
-        else
-            return null;
-    }
-}
--- a/src/share/classes/com/sun/jmx/mbeanserver/PerInterface.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/PerInterface.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * 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
@@ -231,7 +231,7 @@
     /**
      * Visitor that sets up the method maps (operations, getters, setters).
      */
-    private class InitMaps implements MBeanAnalyzer.MBeanVisitor<M, RuntimeException> {
+    private class InitMaps implements MBeanAnalyzer.MBeanVisitor<M> {
         public void visitAttribute(String attributeName,
                                    M getter,
                                    M setter) {
--- a/src/share/classes/com/sun/jmx/mbeanserver/PerThreadGroupPool.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package com.sun.jmx.mbeanserver;
-
-import java.lang.ref.WeakReference;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * <p>A factory for ThreadPoolExecutor objects that allows the same object to
- * be shared by all users of the factory that are in the same ThreadGroup.</p>
- */
-// We return a ThreadPoolExecutor rather than the more general ExecutorService
-// because we need to be able to call allowCoreThreadTimeout so that threads in
-// the pool will eventually be destroyed when the pool is no longer in use.
-// Otherwise these threads would keep the ThreadGroup alive forever.
-public class PerThreadGroupPool<T extends ThreadPoolExecutor> {
-    private final WeakIdentityHashMap<ThreadGroup, WeakReference<T>> map =
-            WeakIdentityHashMap.make();
-
-    public static interface Create<T extends ThreadPoolExecutor> {
-        public T createThreadPool(ThreadGroup group);
-    }
-
-    private PerThreadGroupPool() {}
-
-    public static <T extends ThreadPoolExecutor> PerThreadGroupPool<T> make() {
-        return new PerThreadGroupPool<T>();
-    }
-
-    public synchronized T getThreadPoolExecutor(Create<T> create) {
-        // Find out if there's already an existing executor for the calling
-        // thread and reuse it. Otherwise, create a new one and store it in
-        // the executors map. If there is a SecurityManager, the group of
-        // System.getSecurityManager() is used, else the group of the calling
-        // thread.
-        SecurityManager s = System.getSecurityManager();
-        ThreadGroup group = (s != null) ? s.getThreadGroup() :
-            Thread.currentThread().getThreadGroup();
-        WeakReference<T> wr = map.get(group);
-        T executor = (wr == null) ? null : wr.get();
-        if (executor == null) {
-            executor = create.createThreadPool(group);
-            executor.allowCoreThreadTimeOut(true);
-            map.put(group, new WeakReference<T>(executor));
-        }
-        return executor;
-    }
-}
--- a/src/share/classes/com/sun/jmx/mbeanserver/Repository.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/Repository.java	Wed Nov 25 11:08:25 2009 -0800
@@ -396,7 +396,7 @@
 
         // Set domain to default if domain is empty and not already set
         if (dom.length() == 0)
-            name = ObjectName.valueOf(domain + name.toString());
+            name = Util.newObjectName(domain + name.toString());
 
         // Do we have default domain ?
         if (dom == domain) {  // ES: OK (dom & domain are interned)
@@ -573,7 +573,7 @@
             // Pattern matching in the domain name (*, ?)
             final String dom2Match = name.getDomain();
             for (String dom : domainTb.keySet()) {
-                if (Util.wildpathmatch(dom, dom2Match)) {
+                if (Util.wildmatch(dom, dom2Match)) {
                     final Map<String,NamedObject> moiTb = domainTb.get(dom);
                     if (allNames)
                         result.addAll(moiTb.values());
--- a/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanIntrospector.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanException;
 import javax.management.MBeanOperationInfo;
-import javax.management.ManagedOperation;
 import javax.management.NotCompliantMBeanException;
 import javax.management.NotificationBroadcaster;
 import javax.management.NotificationBroadcasterSupport;
@@ -119,32 +118,22 @@
 
     @Override
     MBeanAttributeInfo getMBeanAttributeInfo(String attributeName,
-            Method getter, Method setter) throws IntrospectionException {
+            Method getter, Method setter) {
 
-        String description = getAttributeDescription(
-                attributeName, "Attribute exposed for management",
-                getter, setter);
-        return new MBeanAttributeInfo(attributeName, description,
-                                      getter, setter);
+        final String description = "Attribute exposed for management";
+        try {
+            return new MBeanAttributeInfo(attributeName, description,
+                                          getter, setter);
+        } catch (IntrospectionException e) {
+            throw new RuntimeException(e); // should not happen
+        }
     }
 
     @Override
     MBeanOperationInfo getMBeanOperationInfo(String operationName,
             Method operation) {
-        final String defaultDescription = "Operation exposed for management";
-        String description = Introspector.descriptionForElement(operation);
-        if (description == null)
-            description = defaultDescription;
-
-        int impact = MBeanOperationInfo.UNKNOWN;
-        ManagedOperation annot = operation.getAnnotation(ManagedOperation.class);
-        if (annot != null)
-            impact = annot.impact().getCode();
-
-        MBeanOperationInfo mboi = new MBeanOperationInfo(description, operation);
-        return new MBeanOperationInfo(
-                mboi.getName(), mboi.getDescription(), mboi.getSignature(),
-                mboi.getReturnType(), impact, mboi.getDescriptor());
+        final String description = "Operation exposed for management";
+        return new MBeanOperationInfo(description, operation);
     }
 
     @Override
--- a/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/StandardMBeanSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -31,7 +31,6 @@
 import javax.management.MBeanServer;
 import javax.management.NotCompliantMBeanException;
 import javax.management.ObjectName;
-import javax.management.openmbean.MXBeanMappingFactory;
 
 /**
  * Base class for Standard MBeans.
@@ -58,11 +57,11 @@
      */
     public <T> StandardMBeanSupport(T resource, Class<T> mbeanInterfaceType)
             throws NotCompliantMBeanException {
-        super(resource, mbeanInterfaceType, (MXBeanMappingFactory) null);
+        super(resource, mbeanInterfaceType);
     }
 
     @Override
-    MBeanIntrospector<Method> getMBeanIntrospector(MXBeanMappingFactory ignored) {
+    MBeanIntrospector<Method> getMBeanIntrospector() {
         return StandardMBeanIntrospector.getInstance();
     }
 
@@ -84,14 +83,13 @@
     @Override
     public MBeanInfo getMBeanInfo() {
         MBeanInfo mbi = super.getMBeanInfo();
-        Class<?> resourceClass = getWrappedObject().getClass();
-        if (!getMBeanInterface().isInterface() ||
-                StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass))
+        Class<?> resourceClass = getResource().getClass();
+        if (StandardMBeanIntrospector.isDefinitelyImmutableInfo(resourceClass))
             return mbi;
         return new MBeanInfo(mbi.getClassName(), mbi.getDescription(),
                 mbi.getAttributes(), mbi.getConstructors(),
                 mbi.getOperations(),
-                MBeanIntrospector.findNotifications(getWrappedObject()),
+                MBeanIntrospector.findNotifications(getResource()),
                 mbi.getDescriptor());
     }
 }
--- a/src/share/classes/com/sun/jmx/mbeanserver/Util.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/mbeanserver/Util.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,8 +25,6 @@
 
 package com.sun.jmx.mbeanserver;
 
-import com.sun.jmx.defaults.JmxProperties;
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -40,25 +38,18 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.SortedMap;
-import java.util.SortedSet;
 import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.WeakHashMap;
-import java.util.logging.Level;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectInstance;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
-import javax.management.loading.ClassLoaderRepository;
-import static javax.management.namespace.JMXNamespaces.NAMESPACE_SEPARATOR;
 
 public class Util {
-    private final static int NAMESPACE_SEPARATOR_LENGTH =
-            NAMESPACE_SEPARATOR.length();
-    public final static char[] ILLEGAL_MBEANSERVER_NAME_CHARS=";:*?".
-            toCharArray();
-
+    public static ObjectName newObjectName(String string) {
+        try {
+            return new ObjectName(string);
+        } catch (MalformedObjectNameException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
 
     static <K, V> Map<K, V> newMap() {
         return new HashMap<K, V>();
@@ -89,10 +80,6 @@
         return new LinkedHashMap<K, V>();
     }
 
-    static <K, V> WeakHashMap<K, V> newWeakHashMap() {
-        return new WeakHashMap<K, V>();
-    }
-
     static <E> Set<E> newSet() {
         return new HashSet<E>();
     }
@@ -251,451 +238,4 @@
     public static boolean wildmatch(String str, String pat) {
         return wildmatch(str,pat,0,str.length(),0,pat.length());
     }
-
-    /**
-     * Matches a string against a pattern, as a name space path.
-     * This is a special matching where * and ?? don't match //.
-     * The string is split in sub-strings separated by //, and the
-     * pattern is split in sub-patterns separated by //. Each sub-string
-     * is matched against its corresponding sub-pattern.
-     * so <elt-1>//<elt2>//...//<elt-n> matches <pat-1>//<pat-2>//...//<pat-q>
-     * only if n==q and for ( i = 1 => n) elt-i matches pat-i.
-     *
-     * In addition, if we encounter a pattern element which is exactly
-     * **, it can match any number of path-elements - but it must match at
-     * least one element.
-     * When we encounter such a meta-wildcard, we remember its position
-     * and the position in the string path, and we advance both the pattern
-     * and the string. Later, if we encounter a mismatch in pattern & string,
-     * we rewind the position in pattern to just after the meta-wildcard,
-     * and we backtrack the string to i+1 element after the position
-     * we had when we first encountered the meta-wildcard, i being the
-     * position when we last backtracked the string.
-     *
-     * The backtracking logic is an adaptation of the logic in wildmatch
-     * above.
-     * See test/javax/mangement/ObjectName/ApplyWildcardTest.java
-     *
-     * Note: this thing is called 'wild' - and that's for a reason ;-)
-     **/
-    public static boolean wildpathmatch(String str, String pat) {
-        final int strlen = str.length();
-        final int patlen = pat.length();
-        int stri = 0;
-        int pati = 0;
-
-        int starstri; // index for backtrack if "**" attempt fails
-        int starpati; // index for backtrack if "**" attempt fails
-
-        starstri = starpati = -1;
-
-        while (true) {
-            // System.out.println("pati="+pati+", stri="+stri);
-            final int strend = str.indexOf(NAMESPACE_SEPARATOR, stri);
-            final int patend = pat.indexOf(NAMESPACE_SEPARATOR, pati);
-
-            // no // remaining in either string or pattern: simple wildmatch
-            // until end of string.
-            if (strend == -1 && patend == -1) {
-                // System.out.println("last sub pattern, last sub element...");
-                // System.out.println("wildmatch("+str.substring(stri,strlen)+
-                //    ","+pat.substring(pati,patlen)+")");
-                return wildmatch(str,pat,stri,strlen,pati,patlen);
-            }
-
-            // no // remaining in string, but at least one remaining in
-            // pattern
-            // => no match
-            if (strend == -1) {
-                // System.out.println("pattern has more // than string...");
-                return false;
-            }
-
-            // strend is != -1, but patend might.
-            // detect wildcard **
-            if (patend == pati+2 && pat.charAt(pati)=='*' &&
-                    pat.charAt(pati+1)=='*') {
-                // if we reach here we know that neither strend nor patend are
-                // equals to -1.
-                stri     = strend + NAMESPACE_SEPARATOR_LENGTH;
-                pati     = patend + NAMESPACE_SEPARATOR_LENGTH;
-                starpati = pati; // position just after **// in pattern
-                starstri = stri; // we eat 1 element in string, and remember
-                                 // the position for backtracking and eating
-                                 // one more element if needed.
-                // System.out.println("starpati="+pati);
-                continue;
-            }
-
-            // This is a bit hacky: * can match // when // is at the end
-            // of the string, so we include the // delimiter in the pattern
-            // matching. Either we're in the middle of the path, so including
-            // // both at the end of the pattern and at the end of the string
-            // has no effect - match(*//,dfsd//) is equivalent to match(*,dfsd)
-            // or we're at the end of the pattern path, in which case
-            // including // at the end of the string will have the desired
-            // effect (provided that we detect the end of matching correctly,
-            // see further on).
-            //
-            final int endpat =
-                    ((patend > -1)?patend+NAMESPACE_SEPARATOR_LENGTH:patlen);
-            final int endstr =
-                    ((strend > -1)?strend+NAMESPACE_SEPARATOR_LENGTH:strlen);
-
-            // if we reach the end of the pattern, or if elt-i & pat-i
-            // don't match, we have a mismatch.
-
-            // Note: we know that strend != -1, therefore patend==-1
-            //       indicates a mismatch unless pattern can match
-            //       a // at the end, and strend+2=strlen.
-            // System.out.println("wildmatch("+str.substring(stri,endstr)+","+
-            //        pat.substring(pati,endpat)+")");
-            if (!wildmatch(str,pat,stri,endstr,pati,endpat)) {
-
-                // System.out.println("nomatch");
-                // if we have a mismatch and didn't encounter any meta-wildcard,
-                // we return false. String & pattern don't match.
-                if (starpati < 0) return false;
-
-                // If we reach here, we had a meta-wildcard.
-                // We need to backtrack to the wildcard, and make it eat an
-                // additional string element.
-                //
-                stri = str.indexOf(NAMESPACE_SEPARATOR, starstri);
-                // System.out.println("eating one additional element? "+stri);
-
-                // If there's no more elements to eat, string and pattern
-                // don't match => return false.
-                if (stri == -1) return false;
-
-                // Backtrack to where we were when we last matched against
-                // the meta-wildcard, make it eat an additional path element,
-                // remember the new positions, and continue from there...
-                //
-                stri = stri + NAMESPACE_SEPARATOR_LENGTH;
-                starstri = stri;
-                pati = starpati;
-                // System.out.println("skiping to stri="+stri);
-                continue;
-            }
-
-            // Here we know that strend > -1 but we can have patend == -1.
-            //
-            // So if we reach here, we know pat-i+//? has matched
-            // elt-i+//
-            //
-            // If patend==-1, we know that there was no delimiter
-            // at the end of the pattern, that we are at the last pattern,
-            // and therefore that pat-i has matched elt-i+//
-            //
-            // In that case we can consider that we have a match only if
-            // elt-i is also the last path element in the string, which is
-            // equivalent to saying that strend+2==strlen.
-            //
-            if (patend == -1 && starpati == -1)
-                return (strend+NAMESPACE_SEPARATOR_LENGTH==strlen);
-
-            // patend != -1, or starpati > -1 so there remains something
-            // to match.
-
-            // go to next pair: elt-(i+1) pat-(i+1);
-            stri = strend + NAMESPACE_SEPARATOR_LENGTH;
-            pati = (patend==-1)?pati:(patend + NAMESPACE_SEPARATOR_LENGTH);
-        }
-    }
-
-    /**
-     * Returns true if the ObjectName's {@code domain} is selected by the
-     * given {@code pattern}.
-     */
-    public static boolean isDomainSelected(String domain, String pattern) {
-        if  (domain == null || pattern == null)
-            throw new IllegalArgumentException("null");
-        return Util.wildpathmatch(domain,pattern);
-    }
-
-    /**
-     * Filters a set of ObjectName according to a given pattern.
-     *
-     * @param pattern the pattern that the returned names must match.
-     * @param all     the set of names to filter.
-     * @return a set of ObjectName from which non matching names
-     *         have been removed.
-     */
-    public static Set<ObjectName> filterMatchingNames(ObjectName pattern,
-                                        Set<ObjectName> all) {
-        // If no pattern, just return all names
-        if (pattern == null
-                || all.isEmpty()
-                || ObjectName.WILDCARD.equals(pattern))
-            return all;
-
-        // If there's a pattern, do the matching.
-        final Set<ObjectName> res = equivalentEmptySet(all);
-        for (ObjectName n : all) if (pattern.apply(n)) res.add(n);
-        return res;
-    }
-
-
-    /**
-     * Filters a set of ObjectInstance according to a given pattern.
-     *
-     * @param pattern the pattern that the returned names must match.
-     * @param all     the set of instances to filter.
-     * @return a set of ObjectInstance from which non matching instances
-     *         have been removed.
-     */
-    public static Set<ObjectInstance>
-            filterMatchingInstances(ObjectName pattern,
-                                        Set<ObjectInstance> all) {
-        // If no pattern, just return all names
-        if (pattern == null
-                || all.isEmpty()
-                || ObjectName.WILDCARD.equals(pattern))
-            return all;
-
-        // If there's a pattern, do the matching.
-        final Set<ObjectInstance> res = equivalentEmptySet(all);
-        for (ObjectInstance n : all) {
-            if (n == null) continue;
-            if (pattern.apply(n.getObjectName()))
-                res.add(n);
-        }
-        return res;
-    }
-
-    /**
-     * An abstract ClassLoaderRepository that contains a single class loader.
-     **/
-    private final static class SingleClassLoaderRepository
-            implements ClassLoaderRepository {
-        private final ClassLoader singleLoader;
-
-        SingleClassLoaderRepository(ClassLoader loader) {
-            this.singleLoader = loader;
-        }
-
-        ClassLoader getSingleClassLoader() {
-           return singleLoader;
-        }
-
-        private Class<?> loadClass(String className, ClassLoader loader)
-                throws ClassNotFoundException {
-            return Class.forName(className, false, loader);
-        }
-
-        public Class<?> loadClass(String className)
-                throws ClassNotFoundException {
-            return loadClass(className, getSingleClassLoader());
-        }
-
-        public Class<?> loadClassWithout(ClassLoader exclude,
-                String className) throws ClassNotFoundException {
-            final ClassLoader loader = getSingleClassLoader();
-            if (exclude != null && exclude.equals(loader))
-                throw new ClassNotFoundException(className);
-            return loadClass(className, loader);
-        }
-
-        public Class<?> loadClassBefore(ClassLoader stop, String className)
-                throws ClassNotFoundException {
-            return loadClassWithout(stop, className);
-        }
-    }
-
-    /**
-     * Returns a ClassLoaderRepository that contains a single class loader.
-     * @param loader the class loader contained in the returned repository.
-     * @return a ClassLoaderRepository that contains the single loader.
-     */
-    public static ClassLoaderRepository getSingleClassLoaderRepository(
-            final ClassLoader loader) {
-        return new SingleClassLoaderRepository(loader);
-    }
-
-    /**
-     * Returns the name of the given MBeanServer that should be put in a
-     * permission you need.
-     * This corresponds to the
-     * {@code *[;mbeanServerName=<mbeanServerName>[;*]]} property
-     * embedded in the MBeanServerId attribute of the
-     * server's {@link MBeanServerDelegate}.
-     *
-     * @param server The MBean server
-     * @return the name of the MBeanServer, or "*" if the name couldn't be
-     *         obtained, or {@value MBeanServerFactory#DEFAULT_MBEANSERVER_NAME}
-     *         if there was no name.
-     */
-    public static String getMBeanServerSecurityName(MBeanServer server) {
-        final String notfound = "*";
-        try {
-            final String mbeanServerId = (String)
-                    server.getAttribute(MBeanServerDelegate.DELEGATE_NAME,
-                    "MBeanServerId");
-            final String found = extractMBeanServerName(mbeanServerId);
-            if (found.length()==0)
-                return MBeanServerFactory.DEFAULT_MBEANSERVER_NAME;
-            return found;
-        } catch (Exception x) {
-            logshort("Failed to retrieve MBeanServerName for server, " +
-                    "using \"*\"",x);
-            return notfound;
-        }
-    }
-
-    /**
-     * Returns the name of the MBeanServer embedded in the given
-     * mbeanServerId. If the given mbeanServerId doesn't contain any name,
-     * an empty String is returned.
-     * The MBeanServerId is expected to be of the form:
-     * {@code *[;mbeanServerName=<mbeanServerName>[;*]]}
-     * @param mbeanServerId The MBean server ID
-     * @return the name of the MBeanServer if found, or "" if the name was
-     *         not present in the mbeanServerId.
-     */
-    public static String extractMBeanServerName(String mbeanServerId) {
-        if (mbeanServerId==null) return "";
-        final String beginMarker=";mbeanServerName=";
-        final String endMarker=";";
-        final int found = mbeanServerId.indexOf(beginMarker);
-        if (found < 0) return "";
-        final int start = found + beginMarker.length();
-        final int stop = mbeanServerId.indexOf(endMarker, start);
-        return mbeanServerId.substring(start,
-                (stop < 0 ? mbeanServerId.length() : stop));
-    }
-
-    /**
-     * Insert the given mbeanServerName into the given mbeanServerId.
-     * If mbeanServerName is null, empty, or equals to "-", the returned
-     * mbeanServerId will not contain any mbeanServerName.
-     * @param mbeanServerId    The mbeanServerId in which to insert
-     *                         mbeanServerName
-     * @param mbeanServerName  The mbeanServerName
-     * @return an mbeanServerId containing the given mbeanServerName
-     * @throws IllegalArgumentException if mbeanServerId already contains
-     *         a different name, or if the given mbeanServerName is not valid.
-     */
-    public static String insertMBeanServerName(String mbeanServerId,
-            String mbeanServerName) {
-        final String found = extractMBeanServerName(mbeanServerId);
-        if (found.length() > 0 &&
-                found.equals(checkServerName(mbeanServerName)))
-            return mbeanServerId;
-        if (found.length() > 0 && !isMBeanServerNameUndefined(found))
-            throw new IllegalArgumentException(
-                    "MBeanServerName already defined");
-        if (isMBeanServerNameUndefined(mbeanServerName))
-            return mbeanServerId;
-        final String beginMarker=";mbeanServerName=";
-        return mbeanServerId+beginMarker+checkServerName(mbeanServerName);
-    }
-
-    /**
-     * Returns true if the given mbeanServerName corresponds to an
-     * undefined MBeanServerName.
-     * The mbeanServerName is considered undefined if it is one of:
-     * {@code null} or {@value MBeanServerFactory#DEFAULT_MBEANSERVER_NAME}.
-     * @param mbeanServerName The mbeanServerName, as returned by
-     *        {@link #extractMBeanServerName(String)}.
-     * @return true if the given name corresponds to one of the forms that
-     *         denotes an undefined MBeanServerName.
-     */
-    public static boolean isMBeanServerNameUndefined(String mbeanServerName) {
-        return mbeanServerName == null ||
-           MBeanServerFactory.DEFAULT_MBEANSERVER_NAME.equals(mbeanServerName);
-    }
-    /**
-     * Check that the provided mbeanServername is syntactically valid.
-     * @param mbeanServerName An mbeanServerName, or {@code null}.
-     * @return mbeanServerName, or {@value
-     * MBeanServerFactory#DEFAULT_MBEANSERVER_NAME} if {@code mbeanServerName}
-     * is {@code null}.
-     * @throws IllegalArgumentException if mbeanServerName contains illegal
-     *         characters, or is empty, or is {@code "-"}.
-     *         Illegal characters are {@link #ILLEGAL_MBEANSERVER_NAME_CHARS}.
-     */
-    public static String checkServerName(String mbeanServerName) {
-        if ("".equals(mbeanServerName))
-            throw new IllegalArgumentException(
-                    "\"\" is not a valid MBean server name");
-        if ("-".equals(mbeanServerName))
-            throw new IllegalArgumentException(
-                    "\"-\" is not a valid MBean server name");
-        if (isMBeanServerNameUndefined(mbeanServerName))
-            return MBeanServerFactory.DEFAULT_MBEANSERVER_NAME;
-        for (char c : ILLEGAL_MBEANSERVER_NAME_CHARS) {
-            if (mbeanServerName.indexOf(c) >= 0)
-                throw new IllegalArgumentException(
-                        "invalid character in MBeanServer name: "+c);
-        }
-        return mbeanServerName;
-    }
-
-    /**
-     * Get the MBeanServer name that should be put in a permission you need.
-     *
-     * @param delegate The MBeanServerDelegate
-     * @return The MBeanServer name - or {@value
-     * MBeanServerFactory#DEFAULT_MBEANSERVER_NAME} if there was no name.
-     */
-    public static String getMBeanServerSecurityName(
-            MBeanServerDelegate delegate) {
-        try {
-            final String serverName = delegate.getMBeanServerName();
-            if (isMBeanServerNameUndefined(serverName))
-                return MBeanServerFactory.DEFAULT_MBEANSERVER_NAME;
-            return serverName;
-        } catch (Exception x) {
-            logshort("Failed to retrieve MBeanServerName from delegate, " +
-                    "using \"*\"",x);
-            return "*";
-        }
-    }
-
-    // Log the exception and its causes without logging the stack trace.
-    // Use with care - it is usually preferable to log the whole stack trace!
-    // We don't want to log the whole stack trace here: logshort() is
-    // called in those cases where the exception might not be abnormal.
-    private static void logshort(String msg, Throwable t) {
-        if (JmxProperties.MISC_LOGGER.isLoggable(Level.FINE)) {
-            StringBuilder toprint = new StringBuilder(msg);
-            do {
-                toprint.append("\nCaused By: ").append(String.valueOf(t));
-            } while ((t=t.getCause())!=null);
-            JmxProperties.MISC_LOGGER.fine(toprint.toString());
-       }
-    }
-
-    public static <T> Set<T> cloneSet(Set<T> set) {
-        if (set instanceof SortedSet<?>) {
-            @SuppressWarnings("unchecked")
-            SortedSet<T> sset = (SortedSet<T>) set;
-            set = new TreeSet<T>(sset.comparator());
-            set.addAll(sset);
-        } else
-            set = new HashSet<T>(set);
-        return set;
-    }
-
-    public static <T> Set<T> equivalentEmptySet(Set<T> set) {
-        if (set instanceof SortedSet<?>) {
-            @SuppressWarnings("unchecked")
-            SortedSet<T> sset = (SortedSet<T>) set;
-            set = new TreeSet<T>(sset.comparator());
-        } else
-            set = new HashSet<T>();
-        return set;
-    }
-
-    // This exception is used when wrapping a class that throws IOException
-    // in a class that doesn't.
-    // The typical example for this are JMXNamespaces, when the sub
-    // MBeanServer can be remote.
-    //
-    public static RuntimeException newRuntimeIOException(IOException io) {
-        final String msg = "Communication failed with underlying resource: "+
-                io.getMessage();
-        return new RuntimeException(msg,io);
-    }
 }
--- a/src/share/classes/com/sun/jmx/namespace/DomainInterceptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,463 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.mbeanserver.Util;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanPermission;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerNotification;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.namespace.JMXDomain;
-
-/**
- * A DomainInterceptor wraps a JMXDomain.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public class DomainInterceptor extends HandlerInterceptor<JMXDomain> {
-
-    // TODO: Ideally DomainInterceptor should be replaced by
-    //       something at Repository level.
-    //       The problem there will be that we may need to
-    //       reinstantiate the 'queryPerformedByRepos' boolean
-    //       [or we will need to wrap the repository in
-    //        a 'RepositoryInterceptor'?]
-    //       Also there's no real need for a DomainInterceptor to
-    //       extend RewritingMBeanServerConnection.
-
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    private final String           domainName;
-    private volatile ObjectName    ALL;
-    private final String           serverName;
-    private volatile NotificationListener mbsListener;
-
-    private static class PatternNotificationFilter
-            implements NotificationFilter {
-
-        final ObjectName pattern;
-        public PatternNotificationFilter(ObjectName pattern) {
-            this.pattern = pattern==null?ObjectName.WILDCARD:pattern;
-        }
-
-        public boolean isNotificationEnabled(Notification notification) {
-            if (!(notification instanceof MBeanServerNotification))
-                return false;
-            final MBeanServerNotification mbsn =
-                    (MBeanServerNotification) notification;
-            if (pattern.apply(mbsn.getMBeanName()))
-                return true;
-            return false;
-        }
-
-        static final long serialVersionUID = 7409950927025262111L;
-    }
-
-    /**
-     * Creates a new instance of NamespaceInterceptor
-     */
-    public DomainInterceptor(String serverName,
-                             JMXDomain handler,
-                             String domainName) {
-        super(handler);
-        this.domainName = domainName;
-        this.serverName = serverName;
-        ALL = ObjectName.valueOf(domainName+":*");
-    }
-
-    @Override
-    public String toString() {
-        return this.getClass().getName()+"(parent="+serverName+
-                ", domain="+this.domainName+")";
-    }
-
-    final void connectDelegate(final MBeanServerDelegate delegate)
-            throws InstanceNotFoundException {
-        final NotificationFilter filter =
-                new PatternNotificationFilter(getPatternFor(null));
-        synchronized (this) {
-            if (mbsListener == null) {
-                mbsListener = new NotificationListener() {
-                    public void handleNotification(Notification notification,
-                        Object handback) {
-                        if (filter.isNotificationEnabled(notification))
-                            delegate.sendNotification(notification);
-                    }
-                };
-            }
-        }
-
-        getHandlerInterceptorMBean().
-                addMBeanServerNotificationListener(mbsListener, filter);
-    }
-
-    final void disconnectDelegate()
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        final NotificationListener l;
-        synchronized (this) {
-            l = mbsListener;
-            if (l == null) return;
-            mbsListener = null;
-        }
-        getHandlerInterceptorMBean().removeMBeanServerNotificationListener(l);
-    }
-
-    public final void addPostRegisterTask(Queue<Runnable> queue,
-            final MBeanServerDelegate delegate) {
-        if (queue == null)
-            throw new IllegalArgumentException("task queue must not be null");
-        final Runnable task1 = new Runnable() {
-            public void run() {
-                try {
-                    connectDelegate(delegate);
-                } catch (Exception x) {
-                    throw new UnsupportedOperationException(
-                            "notification forwarding",x);
-                }
-            }
-        };
-        queue.add(task1);
-    }
-
-    public final void addPostDeregisterTask(Queue<Runnable> queue,
-            final MBeanServerDelegate delegate) {
-        if (queue == null)
-            throw new IllegalArgumentException("task queue must not be null");
-        final Runnable task1 = new Runnable() {
-            public void run() {
-                try {
-                    disconnectDelegate();
-                } catch (Exception x) {
-                    throw new UnsupportedOperationException(
-                            "notification forwarding",x);
-                }
-            }
-        };
-        queue.add(task1);
-    }
-
-    // No name conversion for JMXDomains...
-    // Throws IllegalArgumentException if targetName.getDomain() is not
-    // in the domain handled.
-    //
-    @Override
-    protected ObjectName toSource(ObjectName targetName) {
-        if (targetName == null) return null;
-        if (targetName.isDomainPattern()) return targetName;
-        final String targetDomain = targetName.getDomain();
-
-        // TODO: revisit this. RuntimeOperationsException may be better?
-        //
-        if (!targetDomain.equals(domainName))
-            throw new IllegalArgumentException(targetName.toString());
-        return targetName;
-    }
-
-    // No name conversion for JMXDomains...
-    @Override
-    protected ObjectName toTarget(ObjectName sourceName) {
-        return sourceName;
-    }
-
-
-
-    /**
-     * No rewriting: always return sources - stripping instances for which
-     * the caller doesn't have permissions.
-     **/
-    @Override
-    Set<ObjectInstance> processOutputInstances(Set<ObjectInstance> sources) {
-        if (sources == null || sources.isEmpty() || !checkOn())
-            return sources;
-        final Set<ObjectInstance> res = Util.equivalentEmptySet(sources);
-        for (ObjectInstance o : sources) {
-            if (checkQuery(o.getObjectName(), "queryMBeans"))
-                res.add(o);
-        }
-        return res;
-    }
-
-
-    /**
-     * No rewriting: always return sourceNames - stripping names for which
-     * the caller doesn't have permissions.
-     **/
-    @Override
-    Set<ObjectName> processOutputNames(Set<ObjectName> sourceNames) {
-        if (sourceNames == null || sourceNames.isEmpty() || !checkOn())
-            return sourceNames;
-        final Set<ObjectName> res = Util.equivalentEmptySet(sourceNames);
-        for (ObjectName o : sourceNames) {
-            if (checkQuery(o, "queryNames"))
-                res.add(o);
-        }
-        return res;
-    }
-
-    /** No rewriting: always return source **/
-    @Override
-    ObjectInstance processOutputInstance(ObjectInstance source) {
-        return source;
-    }
-
-    @Override
-    public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-        try {
-            // We don't trust the wrapped JMXDomain...
-            final ObjectName pattern = getPatternFor(name);
-            final Set<ObjectName> res = super.queryNames(pattern,query);
-            return Util.filterMatchingNames(pattern,res);
-        } catch (Exception x) {
-            if (LOG.isLoggable(Level.FINE))
-                LOG.fine("Unexpected exception raised in queryNames: "+x);
-            LOG.log(Level.FINEST,"Unexpected exception raised in queryNames",x);
-            return Collections.emptySet();
-        }
-    }
-
-    // Compute a new pattern which is a sub pattern of 'name' but only selects
-    // the MBeans in domain 'domainName'
-    // When we reach here, it has been verified that 'name' matches our domain
-    // name (done by DomainDispatchInterceptor)
-    private ObjectName getPatternFor(final ObjectName name) {
-        if (name == null) return ALL;
-        if (name.getDomain().equals(domainName)) return name;
-        return name.withDomain(domainName);
-   }
-
-    @Override
-    public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
-        try {
-            // We don't trust the wrapped JMXDomain...
-            final ObjectName pattern = getPatternFor(name);
-            final Set<ObjectInstance> res = super.queryMBeans(pattern,query);
-            return Util.filterMatchingInstances(pattern,res);
-        } catch (Exception x) {
-            if (LOG.isLoggable(Level.FINE))
-                LOG.fine("Unexpected exception raised in queryNames: "+x);
-            LOG.log(Level.FINEST,"Unexpected exception raised in queryNames",x);
-            return Collections.emptySet();
-        }
-    }
-
-    @Override
-    public String getDefaultDomain() {
-        return domainName;
-    }
-
-    @Override
-    public String[] getDomains() {
-        return new String[] {domainName};
-    }
-
-    // We call getMBeanCount() on the namespace rather than on the
-    // source server in order to avoid counting MBeans which are not
-    // in the domain.
-    @Override
-    public Integer getMBeanCount() {
-        return getHandlerInterceptorMBean().getMBeanCount();
-    }
-
-    private boolean checkOn() {
-        final SecurityManager sm = System.getSecurityManager();
-        return (sm != null);
-    }
-
-    //
-    // Implements permission checks.
-    //
-    @Override
-    void check(ObjectName routingName, String member, String action) {
-        if (!checkOn()) return;
-        final String act = (action==null)?"-":action;
-        if("queryMBeans".equals(act) || "queryNames".equals(act)) {
-            // This is tricky. check with 3 parameters is called
-            // by queryNames/queryMBeans before performing the query.
-            // At this point we must check with no class name.
-            // Therefore we pass a className of "-".
-            // The filtering will be done later - processOutputNames and
-            // processOutputInstance will call checkQuery.
-            //
-            check(routingName, "-", "-", act);
-        } else {
-            // This is also tricky:
-            // passing null here will cause check to retrieve the classname,
-            // if needed.
-            check(routingName, null, member, act);
-        }
-    }
-
-    //
-    // Implements permission checks.
-    //
-    @Override
-    void checkCreate(ObjectName routingName, String className, String action) {
-        if (!checkOn()) return;
-        check(routingName,className,"-",action);
-    }
-
-    //
-    // Implements permission checks.
-    //
-    void check(ObjectName routingName, String className, String member,
-            String action) {
-        if (!checkOn()) return;
-        final MBeanPermission perm;
-
-        final String act = (action==null)?"-":action;
-        if ("getDomains".equals(act)) { // ES: OK
-            perm = new  MBeanPermission(serverName,"-",member,
-                    routingName,act);
-        } else {
-            final String clazz =
-                    (className==null)?getClassName(routingName):className;
-            perm = new  MBeanPermission(serverName,clazz,member,
-                    routingName,act);
-        }
-        final SecurityManager sm = System.getSecurityManager();
-        if (sm != null)
-            sm.checkPermission(perm);
-    }
-
-    String getClassName(ObjectName routingName) {
-        if (routingName == null || routingName.isPattern()) return "-";
-        try {
-            return getHandlerInterceptorMBean().getSourceServer().
-                    getObjectInstance(routingName).getClassName();
-        } catch (InstanceNotFoundException ex) {
-            LOG.finest("Can't get class name for "+routingName+
-                    ", using \"-\". Cause is: "+ex);
-            return "-";
-        }
-    }
-
-    //
-    // Implements permission filters for attributes...
-    //
-    @Override
-    AttributeList checkAttributes(ObjectName routingName,
-            AttributeList attributes, String action) {
-        if (!checkOn()) return attributes;
-        final String className = getClassName(routingName);
-        check(routingName,className,"-",action);
-        if (attributes == null || attributes.isEmpty()) return attributes;
-        final AttributeList res = new AttributeList();
-        for (Attribute at : attributes.asList()) {
-            try {
-                check(routingName,className,at.getName(),action);
-                res.add(at);
-            } catch (SecurityException x) { // DLS: OK
-                continue;
-            }
-        }
-        return res;
-    }
-
-    //
-    // Implements permission filters for attributes...
-    //
-    @Override
-    String[] checkAttributes(ObjectName routingName, String[] attributes,
-            String action) {
-        if (!checkOn()) return attributes;
-        final String className = getClassName(routingName);
-        check(routingName,className,"-",action);
-        if (attributes == null || attributes.length==0) return attributes;
-        final List<String> res = new ArrayList<String>(attributes.length);
-        for (String at : attributes) {
-            try {
-                check(routingName,className,at,action);
-                res.add(at);
-            } catch (SecurityException x) { // DLS: OK
-                continue;
-            }
-        }
-        return res.toArray(new String[res.size()]);
-    }
-
-    //
-    // Implements permission filters for domains...
-    //
-    @Override
-    String[] checkDomains(String[] domains, String action) {
-         if (domains == null || domains.length==0 || !checkOn())
-             return domains;
-         int count=0;
-         for (int i=0;i<domains.length;i++) {
-             try {
-                 check(ObjectName.valueOf(domains[i]+":x=x"),"-",
-                         "-","getDomains");
-             } catch (SecurityException x) { // DLS: OK
-                 count++;
-                 domains[i]=null;
-             }
-         }
-         if (count == 0) return domains;
-         final String[] res = new String[domains.length-count];
-         count = 0;
-         for (int i=0;i<domains.length;i++)
-             if (domains[i]!=null) res[count++]=domains[i];
-         return res;
-    }
-
-    //
-    // Implements permission filters for queries...
-    //
-    @Override
-    boolean checkQuery(ObjectName routingName, String action) {
-        try {
-            final String className = getClassName(routingName);
-            check(routingName,className,"-",action);
-            return true;
-        } catch (SecurityException x) { // DLS: OK
-            return false;
-        }
-    }
-}
--- a/src/share/classes/com/sun/jmx/namespace/HandlerInterceptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,734 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.interceptor.MBeanServerInterceptor;
-
-import com.sun.jmx.mbeanserver.Util;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.OperationsException;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import javax.management.loading.ClassLoaderRepository;
-import javax.management.namespace.JMXNamespace;
-
-/**
- * This interceptor wraps a JMXNamespace, and performs
- * {@code ObjectName} rewriting. {@code HandlerInterceptor} are
- * created and managed by a {@link NamespaceDispatchInterceptor} or a
- * {@link DomainDispatchInterceptor}.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public abstract class HandlerInterceptor<T extends JMXNamespace>
-        extends RoutingMBeanServerConnection<MBeanServer>
-        implements MBeanServerInterceptor {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    // The wrapped JMXNamespace
-    private final T handler;
-
-    /**
-     * Creates a new instance of HandlerInterceptor
-     */
-    public HandlerInterceptor(T handler) {
-        if (handler == null) throw new IllegalArgumentException("null");
-        this.handler = handler;
-    }
-
-    //
-    // The {@code source} connection is a connection to the MBeanServer
-    // that contains the actual MBeans.
-    // In the case of cascading, that would be a connection to the sub
-    // agent. Practically, this is JMXNamespace.getSourceServer();
-    //
-    @Override
-    protected MBeanServer source() {
-         return handler.getSourceServer();
-    }
-
-    // The MBeanServer on which getClassLoader / getClassLoaderFor
-    // will be called.
-    // The NamespaceInterceptor overrides this method - so that it
-    // getClassLoader / getClassLoaderFor don't trigger the loop
-    // detection mechanism.
-    //
-    MBeanServer getServerForLoading() {
-         return source();
-    }
-
-    // The namespace or domain handler - this either a JMXNamespace or a
-    // a JMXDomain
-    T getHandlerInterceptorMBean() {
-        return handler;
-    }
-
-    // If the underlying JMXNamespace throws an IO, the IO will be
-    // wrapped in a RuntimeOperationsException.
-    RuntimeException handleIOException(IOException x,String fromMethodName,
-            Object... params) {
-            // Must do something here?
-        if (LOG.isLoggable(Level.FINEST)) {
-            LOG.finest("IO Exception in "+fromMethodName+": "+x+
-                    " - "+" rethrowing as RuntimeOperationsException.");
-        }
-        throw new RuntimeOperationsException(
-                    Util.newRuntimeIOException(x));
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public AttributeList getAttributes(ObjectName name, String[] attributes)
-        throws InstanceNotFoundException, ReflectionException {
-        try {
-            final String[] authorized =
-                    checkAttributes(name,attributes,"getAttribute");
-            final AttributeList attrList =
-                    super.getAttributes(name,authorized);
-            return attrList;
-        } catch (IOException ex) {
-            throw handleIOException(ex,"getAttributes",name,attributes);
-        }
-    }
-
-    // From MBeanServer
-    public ClassLoader getClassLoaderFor(ObjectName mbeanName)
-        throws InstanceNotFoundException {
-        final ObjectName sourceName = toSourceOrRuntime(mbeanName);
-        try {
-            check(mbeanName,null,"getClassLoaderFor");
-            return getServerForLoading().getClassLoaderFor(sourceName);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-
-    // From MBeanServer
-    public ClassLoader getClassLoader(ObjectName loaderName)
-        throws InstanceNotFoundException {
-        final ObjectName sourceName = toSourceOrRuntime(loaderName);
-        try {
-            check(loaderName,null,"getClassLoader");
-            return getServerForLoading().getClassLoader(sourceName);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // From MBeanServer
-    public ObjectInstance registerMBean(Object object, ObjectName name)
-        throws InstanceAlreadyExistsException, MBeanRegistrationException,
-            NotCompliantMBeanException {
-        final ObjectName sourceName = newSourceMBeanName(name);
-        try {
-            checkCreate(name,object.getClass().getName(),"registerMBean");
-            return processOutputInstance(
-                    source().registerMBean(object,sourceName));
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void removeNotificationListener(ObjectName name, ObjectName listener)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            check(name,null,"removeNotificationListener");
-            super.removeNotificationListener(name,listener);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"removeNotificationListener",name,listener);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public String getDefaultDomain() {
-        try {
-            return super.getDefaultDomain();
-        } catch (IOException ex) {
-            throw handleIOException(ex,"getDefaultDomain");
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public String[] getDomains() {
-        try {
-            check(null,null,"getDomains");
-            final String[] domains = super.getDomains();
-            return checkDomains(domains,"getDomains");
-        } catch (IOException ex) {
-            throw handleIOException(ex,"getDomains");
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public Integer getMBeanCount() {
-        try {
-            return super.getMBeanCount();
-        } catch (IOException ex) {
-            throw handleIOException(ex,"getMBeanCount");
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void setAttribute(ObjectName name, Attribute attribute)
-        throws InstanceNotFoundException, AttributeNotFoundException,
-            InvalidAttributeValueException, MBeanException,
-            ReflectionException {
-        try {
-            check(name,
-                  (attribute==null?null:attribute.getName()),
-                  "setAttribute");
-            super.setAttribute(name,attribute);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"setAttribute",name, attribute);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-        if (name == null) name=ObjectName.WILDCARD;
-        try {
-            checkPattern(name,null,"queryNames");
-            return super.queryNames(name,query);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"queryNames",name, query);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
-        if (name == null) name=ObjectName.WILDCARD;
-        try {
-            checkPattern(name,null,"queryMBeans");
-            return super.queryMBeans(name,query);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"queryMBeans",name, query);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public boolean isInstanceOf(ObjectName name, String className)
-        throws InstanceNotFoundException {
-        try {
-            check(name, null, "isInstanceOf");
-            return super.isInstanceOf(name, className);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"isInstanceOf",name, className);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name)
-        throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException {
-        try {
-            checkCreate(name, className, "instantiate");
-            checkCreate(name, className, "registerMBean");
-            return super.createMBean(className, name);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"createMBean",className, name);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name,
-                        ObjectName loaderName)
-        throws ReflectionException, InstanceAlreadyExistsException,
-                MBeanRegistrationException, MBeanException,
-                NotCompliantMBeanException, InstanceNotFoundException {
-        try {
-            checkCreate(name, className, "instantiate");
-            checkCreate(name, className, "registerMBean");
-            return super.createMBean(className, name, loaderName);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"createMBean",className, name, loaderName);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public Object getAttribute(ObjectName name, String attribute)
-        throws MBeanException, AttributeNotFoundException,
-            InstanceNotFoundException, ReflectionException {
-        try {
-            check(name, attribute, "getAttribute");
-            return super.getAttribute(name, attribute);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"getAttribute",name, attribute);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void removeNotificationListener(ObjectName name, ObjectName listener,
-                            NotificationFilter filter, Object handback)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            check(name,null,"removeNotificationListener");
-            super.removeNotificationListener(name, listener, filter, handback);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"removeNotificationListener",name,
-                    listener, filter, handback);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                      NotificationListener listener, NotificationFilter filter,
-                      Object handback)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            check(name,null,"removeNotificationListener");
-            super.removeNotificationListener(name, listener, filter, handback);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"removeNotificationListener",name,
-                    listener, filter, handback);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                NotificationListener listener)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            check(name,null,"removeNotificationListener");
-            super.removeNotificationListener(name, listener);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"removeNotificationListener",name,
-                    listener);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void addNotificationListener(ObjectName name,
-                    NotificationListener listener, NotificationFilter filter,
-                    Object handback) throws InstanceNotFoundException {
-        try {
-            check(name,null,"addNotificationListener");
-            super.addNotificationListener(name, listener, filter, handback);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"addNotificationListener",name,
-                    listener, filter, handback);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void addNotificationListener(ObjectName name, ObjectName listener,
-                NotificationFilter filter, Object handback)
-        throws InstanceNotFoundException {
-        try {
-            check(name,null,"addNotificationListener");
-            super.addNotificationListener(name, listener, filter, handback);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"addNotificationListener",name,
-                    listener, filter, handback);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public boolean isRegistered(ObjectName name) {
-        try {
-            return super.isRegistered(name);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"isRegistered",name);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public void unregisterMBean(ObjectName name)
-        throws InstanceNotFoundException, MBeanRegistrationException {
-        try {
-            check(name, null, "unregisterMBean");
-            super.unregisterMBean(name);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"unregisterMBean",name);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public MBeanInfo getMBeanInfo(ObjectName name)
-        throws InstanceNotFoundException, IntrospectionException,
-            ReflectionException {
-        try {
-            check(name, null, "getMBeanInfo");
-            return super.getMBeanInfo(name);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"getMBeanInfo",name);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public ObjectInstance getObjectInstance(ObjectName name)
-        throws InstanceNotFoundException {
-        try {
-            check(name, null, "getObjectInstance");
-            return super.getObjectInstance(name);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"getObjectInstance",name);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name,
-                Object[] params, String[] signature)
-        throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException {
-        try {
-            checkCreate(name, className, "instantiate");
-            checkCreate(name, className, "registerMBean");
-            return super.createMBean(className, name, params, signature);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"createMBean",className, name,
-                    params, signature);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name,
-                ObjectName loaderName, Object[] params, String[] signature)
-        throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, InstanceNotFoundException {
-        try {
-            checkCreate(name, className, "instantiate");
-            checkCreate(name, className, "registerMBean");
-            return super.createMBean(className, name, loaderName, params,
-                    signature);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"createMBean",className, name,loaderName,
-                    params, signature);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public AttributeList setAttributes(ObjectName name,AttributeList attributes)
-    throws InstanceNotFoundException, ReflectionException {
-        try {
-            final AttributeList authorized =
-                    checkAttributes(name, attributes, "setAttribute");
-            return super.setAttributes(name, authorized);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"setAttributes",name, attributes);
-        }
-    }
-
-    // From MBeanServerConnection: catch & handles IOException
-    @Override
-    public Object invoke(ObjectName name, String operationName, Object[] params,
-                String[] signature)
-        throws InstanceNotFoundException, MBeanException, ReflectionException {
-        try {
-            check(name, operationName, "invoke");
-            return super.invoke(name, operationName, params, signature);
-        } catch (IOException ex) {
-            throw handleIOException(ex,"invoke",name, operationName,
-                    params, signature);
-        }
-    }
-
-    //
-    //  These methods are inherited from MBeanServer....
-    //
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className)
-            throws ReflectionException, MBeanException {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported instantiate method: " +
-                    "trowing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className, ObjectName loaderName)
-            throws ReflectionException, MBeanException,
-            InstanceNotFoundException {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported method: instantiate(...) -" +
-                    "throwing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className, Object[] params,
-            String[] signature) throws ReflectionException, MBeanException {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported method: instantiate(...) -" +
-                    "throwing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public Object instantiate(String className, ObjectName loaderName,
-            Object[] params, String[] signature)
-            throws ReflectionException, MBeanException,
-            InstanceNotFoundException {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported method: instantiate(...) -" +
-                    "throwing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(ObjectName name, byte[] data)
-            throws InstanceNotFoundException, OperationsException {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported method: deserialize(...) -" +
-                    "throwing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className, byte[] data)
-            throws OperationsException, ReflectionException {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported method: deserialize(...) -" +
-                    "throwing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className,
-            ObjectName loaderName, byte[] data)
-            throws InstanceNotFoundException, OperationsException,
-            ReflectionException {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported method: deserialize(...) -" +
-                    "throwing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * This method should never be called.
-     * Throws UnsupportedOperationException.
-     */
-    public ClassLoaderRepository getClassLoaderRepository() {
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("call to unsupported method: getClassLoaderRepository() -" +
-                    "throwing UnsupportedOperationException");
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    static RuntimeException newUnsupportedException(String namespace) {
-        return new RuntimeOperationsException(
-            new UnsupportedOperationException(
-                "Not supported in this namespace: "+namespace));
-    }
-
-    /**
-     * A result might be excluded for security reasons.
-     */
-    @Override
-    boolean excludesFromResult(ObjectName targetName, String queryMethod) {
-        return !checkQuery(targetName, queryMethod);
-    }
-
-
-    //----------------------------------------------------------------------
-    // Hooks for checking permissions
-    //----------------------------------------------------------------------
-
-   /**
-     * This method is a hook to implement permission checking in subclasses.
-     * A subclass may override this method and throw a {@link
-     * SecurityException} if the permission is denied.
-     *
-     * @param routingName The name of the MBean in the enclosing context.
-     *        This is of the form {@code <namespace>//<ObjectName>}.
-     * @param member The {@link
-     *  javax.management.namespace.JMXNamespacePermission#getMember member}
-     *  name.
-     * @param action The {@link
-     *  javax.management.namespace.JMXNamespacePermission#getActions action}
-     *  name.
-     * @throws SecurityException if the caller doesn't have the permission
-     *         to perform the given action on the MBean pointed to
-     *         by routingName.
-     */
-    abstract void check(ObjectName routingName,
-                        String member, String action);
-
-    // called in createMBean and registerMBean
-    abstract void checkCreate(ObjectName routingName, String className,
-                                String action);
-
-    /**
-     * This is a hook to implement permission checking in subclasses.
-     *
-     * Checks that the caller has sufficient permission for returning
-     * information about {@code sourceName} in {@code action}.
-     *
-     * Subclass may override this method and return false if the caller
-     * doesn't have sufficient permissions.
-     *
-     * @param routingName The name of the MBean to include or exclude from
-     *        the query, expressed in the enclosing context.
-     *        This is of the form {@code <namespace>//<ObjectName>}.
-     * @param action one of "queryNames" or "queryMBeans"
-     * @return true if {@code sourceName} can be returned.
-     */
-    abstract boolean checkQuery(ObjectName routingName, String action);
-
-    /**
-     * This method is a hook to implement permission checking in subclasses.
-     *
-     * @param routingName The name of the MBean in the enclosing context.
-     *        This is of the form {@code <namespace>//<ObjectName>}.
-     * @param attributes  The list of attributes to check permission for.
-     * @param action one of "getAttribute" or "setAttribute"
-     * @return The list of attributes for which the callers has the
-     *         appropriate {@link
-     *         javax.management.namespace.JMXNamespacePermission}.
-     * @throws SecurityException if the caller doesn't have the permission
-     *         to perform {@code action} on the MBean pointed to by routingName.
-     */
-    abstract String[] checkAttributes(ObjectName routingName,
-            String[] attributes, String action);
-
-    /**
-     * This method is a hook to implement permission checking in subclasses.
-     *
-     * @param routingName The name of the MBean in the enclosing context.
-     *        This is of the form {@code <namespace>//<ObjectName>}.
-     * @param attributes The list of attributes to check permission for.
-     * @param action one of "getAttribute" or "setAttribute"
-     * @return The list of attributes for which the callers has the
-     *         appropriate {@link
-     *         javax.management.namespace.JMXNamespacePermission}.
-     * @throws SecurityException if the caller doesn't have the permission
-     *         to perform {@code action} on the MBean pointed to by routingName.
-     */
-    abstract AttributeList checkAttributes(ObjectName routingName,
-            AttributeList attributes, String action);
-
-    /**
-     * This method is a hook to implement permission checking in subclasses.
-     * Checks that the caller as the necessary permissions to view the
-     * given domain. If not remove the domains for which the caller doesn't
-     * have permission from the list.
-     * <p>
-     * By default, this method always returns {@code domains}
-     *
-     * @param domains The domains to return.
-     * @param action  "getDomains"
-     * @return a filtered list of domains.
-     */
-    String[] checkDomains(String[] domains, String action) {
-        return domains;
-    }
-
-    // A priori check for queryNames/queryMBeans/
-    void checkPattern(ObjectName routingPattern,
-               String member, String action) {
-        // pattern is checked only at posteriori by checkQuery.
-        // checking it a priori usually doesn't work, because ObjectName.apply
-        // does not work between two patterns.
-        // We only check that we have the permission requested for 'action'.
-        check(null,null,action);
-    }
-
-
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/NamespaceInterceptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespacePermission;
-
-/**
- * A NamespaceInterceptor wraps a JMXNamespace, performing
- * ObjectName rewriting.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public class NamespaceInterceptor extends HandlerInterceptor<JMXNamespace> {
-
-
-    // The target name space in which the NamepsaceHandler is mounted.
-    private final String           targetNs;
-
-    private final String           serverName;
-
-    private final ObjectNameRouter proc;
-
-    /**
-     * Creates a new instance of NamespaceInterceptor
-     */
-    public NamespaceInterceptor(
-            String serverName,
-            JMXNamespace handler,
-            String targetNamespace) {
-        super(handler);
-        this.serverName = serverName;
-        this.targetNs =
-                ObjectNameRouter.normalizeNamespacePath(targetNamespace,
-                true, true, false);
-        proc = new ObjectNameRouter(targetNamespace, "");
-    }
-
-    @Override
-    public String toString() {
-        return this.getClass().getName()+"(parent="+serverName+
-                ", namespace="+this.targetNs+")";
-    }
-
-    /**
-     * This method will send a probe to detect self-linking name spaces.
-     * A self linking namespace is a namespace that links back directly
-     * on itslef. Calling a method on such a name space always results
-     * in an infinite loop going through:
-     * [1]MBeanServer -> [2]NamespaceDispatcher -> [3]NamespaceInterceptor
-     * [4]JMXNamespace -> { network // or cd // or ... } -> [5]MBeanServer
-     * with exactly the same request than [1]...
-     *
-     * The namespace interceptor [2] tries to detect such condition the
-     * *first time* that the connection is used. It does so by setting
-     * a flag, and sending a queryNames() through the name space. If the
-     * queryNames comes back, it knows that there's a loop.
-     *
-     * The DynamicProbe interface can also be used by a Sun JMXNamespace
-     * implementation to request the emission of a probe at any time
-     * (see JMXRemoteNamespace implementation).
-     */
-    private MBeanServer connection() {
-        final MBeanServer c = super.source();
-        if (c != null) return c;
-        // should not come here
-        throw new NullPointerException("getMBeanServerConnection");
-    }
-
-
-    @Override
-    protected MBeanServer source() {
-        return connection();
-    }
-
-    @Override
-    protected MBeanServer getServerForLoading() {
-        // don't want to send probe on getClassLoader/getClassLoaderFor
-        return super.source();
-    }
-
-    @Override
-    protected ObjectName toSource(ObjectName targetName) {
-        return proc.toSourceContext(targetName, true);
-    }
-
-    @Override
-    protected ObjectName toTarget(ObjectName sourceName) {
-        return proc.toTargetContext(sourceName, false);
-    }
-
-    //
-    // Implements permission checks.
-    //
-    @Override
-    void check(ObjectName routingName, String member, String action) {
-        final SecurityManager sm = System.getSecurityManager();
-        if (sm == null) return;
-        if ("getDomains".equals(action)) return;
-        final JMXNamespacePermission perm =
-                new  JMXNamespacePermission(serverName,member,
-                routingName,action);
-        sm.checkPermission(perm);
-    }
-
-    @Override
-    void checkCreate(ObjectName routingName, String className, String action) {
-        final SecurityManager sm = System.getSecurityManager();
-        if (sm == null) return;
-        final JMXNamespacePermission perm =
-                new  JMXNamespacePermission(serverName,className,
-                routingName,action);
-        sm.checkPermission(perm);
-    }
-
-    //
-    // Implements permission filters for attributes...
-    //
-    @Override
-    AttributeList checkAttributes(ObjectName routingName,
-            AttributeList attributes, String action) {
-        check(routingName,null,action);
-        if (attributes == null || attributes.isEmpty()) return attributes;
-        final SecurityManager sm = System.getSecurityManager();
-        if (sm == null) return attributes;
-        final AttributeList res = new AttributeList();
-        for (Attribute at : attributes.asList()) {
-            try {
-                check(routingName,at.getName(),action);
-                res.add(at);
-            } catch (SecurityException x) { // DLS: OK
-                continue;
-            }
-        }
-        return res;
-    }
-
-    //
-    // Implements permission filters for attributes...
-    //
-    @Override
-    String[] checkAttributes(ObjectName routingName, String[] attributes,
-            String action) {
-        check(routingName,null,action);
-        if (attributes == null || attributes.length==0) return attributes;
-        final SecurityManager sm = System.getSecurityManager();
-        if (sm == null) return attributes;
-        final List<String> res = new ArrayList<String>(attributes.length);
-        for (String at : attributes) {
-            try {
-                check(routingName,at,action);
-                res.add(at);
-            } catch (SecurityException x) { // DLS: OK
-                continue;
-            }
-        }
-        return res.toArray(new String[res.size()]);
-    }
-
-    //
-    // Implements permission filters for domains...
-    //
-    @Override
-    String[] checkDomains(String[] domains, String action) {
-        // in principle, this method is never called because
-        // getDomains() will never be called - since there's
-        // no way that MBeanServer.getDomains() can be routed
-        // to a NamespaceInterceptor.
-        //
-        // This is also why there's no getDomains() in a
-        // JMXNamespacePermission...
-        //
-        return super.checkDomains(domains, action);
-    }
-
-    //
-    // Implements permission filters for queries...
-    //
-    @Override
-    boolean checkQuery(ObjectName routingName, String action) {
-        try {
-            check(routingName,null,action);
-            return true;
-        } catch (SecurityException x) { // DLS: OK
-            return false;
-        }
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/ObjectNameRouter.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-import static javax.management.namespace.JMXNamespaces.NAMESPACE_SEPARATOR;
-
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-/**
- * The ObjectNameRouter is used to rewrite routing object names.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public class ObjectNameRouter {
-
-    private static final int NAMESPACE_SEPARATOR_LENGTH =
-            NAMESPACE_SEPARATOR.length();
-
-    final String targetPrefix;
-    final String sourcePrefix;
-    final int slen;
-    final int tlen;
-    final boolean identity;
-
-    /** Creates a new instance of ObjectNameRouter */
-    public ObjectNameRouter(final String remove, final String add) {
-        this.targetPrefix = (remove==null?"":remove);
-        this.sourcePrefix = (add==null?"":add);
-        tlen = targetPrefix.length();
-        slen = sourcePrefix.length();
-        identity = targetPrefix.equals(sourcePrefix);
-    }
-
-    public final ObjectName toTargetContext(ObjectName sourceName,
-            boolean removeLeadingSeparators) {
-        if (sourceName == null) return null;
-        if (identity) return sourceName;
-        String srcDomain = sourceName.getDomain();
-
-        // if the ObjectName starts with // and removeLeadingSeparators is
-        // true, then recursively strip leading //.
-        // Otherwise, do not rewrite ObjectName.
-        //
-        if (srcDomain.startsWith(NAMESPACE_SEPARATOR)) {
-            if (!removeLeadingSeparators) return sourceName;
-            else srcDomain = normalizeDomain(srcDomain,true);
-        }
-        if (slen != 0) {
-            if (!srcDomain.startsWith(sourcePrefix) ||
-                    !srcDomain.startsWith(NAMESPACE_SEPARATOR,slen))
-                throw new IllegalArgumentException(
-                        "ObjectName does not start with expected prefix "
-                        + sourcePrefix + ": " +
-                        String.valueOf(sourceName));
-            srcDomain = srcDomain.substring(slen+NAMESPACE_SEPARATOR_LENGTH);
-        }
-        final String targetDomain =
-                (tlen>0?targetPrefix+NAMESPACE_SEPARATOR+srcDomain:srcDomain);
-        return sourceName.withDomain(targetDomain);
-    }
-
-    public final ObjectName toSourceContext(ObjectName targetName,
-            boolean removeLeadingSeparators) {
-        if (targetName == null) return null;
-        if (identity) return targetName;
-        String targetDomain = targetName.getDomain();
-        if (targetDomain.startsWith(NAMESPACE_SEPARATOR)) {
-            if (!removeLeadingSeparators) return targetName;
-            else targetDomain =
-                    normalizeDomain(targetDomain,true);
-        }
-        if (tlen != 0) {
-            if (!targetDomain.startsWith(targetPrefix) ||
-                    !targetDomain.startsWith(NAMESPACE_SEPARATOR,tlen))
-                throw new IllegalArgumentException(
-                        "ObjectName does not start with expected prefix "
-                        + targetPrefix + ": " +
-                        String.valueOf(targetName));
-            targetDomain = targetDomain.
-                    substring(tlen+NAMESPACE_SEPARATOR_LENGTH);
-        }
-        final String sourceDomain =
-                (slen>0?sourcePrefix+NAMESPACE_SEPARATOR+targetDomain:
-                    targetDomain);
-        return targetName.withDomain(sourceDomain);
-    }
-
-    public final ObjectInstance toTargetContext(ObjectInstance sourceMoi,
-            boolean removeLeadingSeparators) {
-        if (sourceMoi == null) return null;
-        if (identity) return sourceMoi;
-        return new ObjectInstance(
-                toTargetContext(sourceMoi.getObjectName(),
-                    removeLeadingSeparators),
-                    sourceMoi.getClassName());
-    }
-
-    /**
-     * Removes leading, trailing, or duplicate // in a name space path.
-     **/
-    public static String normalizeDomain(String domain,
-                                         boolean removeLeadingSep) {
-        return normalizeNamespacePath(domain,removeLeadingSep,false,true);
-    }
-
-    /**
-     * Removes leading, trailing, or duplicate // in a name space path.
-     **/
-    public static String normalizeNamespacePath(String namespacePath,
-                                            boolean removeLeadingSep,
-                                            boolean removeTrailingSep,
-                                            boolean endsWithDomain) {
-        if (namespacePath.equals(""))
-            return "";
-        final String[] components = namespacePath.split(NAMESPACE_SEPARATOR);
-        final StringBuilder b =
-                new StringBuilder(namespacePath.length()+NAMESPACE_SEPARATOR_LENGTH);
-        String sep = null;
-        if (!removeLeadingSep && namespacePath.startsWith(NAMESPACE_SEPARATOR))
-            b.append(NAMESPACE_SEPARATOR);
-        int count = 0;
-        for (int i=0; i<components.length; i++) {
-            final String n=components[i];
-            if (n.equals("")) continue;
-            if (n.startsWith("/")||n.endsWith("/")) {
-                // throw exception unless we're looking at the last domain
-                // part of the ObjectName
-                if (! (endsWithDomain && i==(components.length-1))) {
-                    throw new IllegalArgumentException(n+
-                        " is not a valid name space identifier");
-                } else {
-                    // There's a dirty little corner case when the domain
-                    // part (last item) is exactly '/' - in that case we must
-                    // not append '//'
-                    //
-                    removeTrailingSep = removeTrailingSep || n.equals("/");
-                }
-            }
-            if (sep != null) b.append(sep);
-            b.append(n);
-            sep = NAMESPACE_SEPARATOR;
-            count++;
-        }
-        if (!removeTrailingSep && namespacePath.endsWith(NAMESPACE_SEPARATOR)
-            && count > 0)
-            b.append(NAMESPACE_SEPARATOR);
-        return b.toString();
-    }
-}
--- a/src/share/classes/com/sun/jmx/namespace/RoutingConnectionProxy.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-
-import com.sun.jmx.defaults.JmxProperties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.MBeanServerConnection;
-
-
-/**
- * A RoutingConnectionProxy is an MBeanServerConnection proxy that proxies a
- * source name space in a source MBeanServerConnection.
- * It wraps a source MBeanServerConnection, and rewrites routing
- * ObjectNames. It is used to implement
- * {@code JMXNamespaces.narrowToNamespace(MBeanServerConnection)}.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-// See class hierarchy and detailled explanations in RoutingProxy in this
-// package.
-//
-public class RoutingConnectionProxy
-        extends RoutingProxy<MBeanServerConnection> {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-
-    /**
-     * Creates a new instance of RoutingConnectionProxy
-     */
-    public RoutingConnectionProxy(MBeanServerConnection source,
-                               String sourceDir,
-                               String targetDir,
-                               boolean probe) {
-        super(source, sourceDir, targetDir, probe);
-
-        if (LOG.isLoggable(Level.FINER))
-            LOG.finer("RoutingConnectionProxy for " + getSourceNamespace() +
-                      " created");
-    }
-
-    @Override
-    public String toString() {
-        final String targetNs = getTargetNamespace();
-        final String sourceNs = getSourceNamespace();
-        String wrapped = String.valueOf(source());
-        if ("".equals(targetNs)) {
-            return "JMXNamespaces.narrowToNamespace("+
-                    wrapped+", \""+
-                    sourceNs+"\")";
-        }
-        return this.getClass().getSimpleName()+"("+wrapped+", \""+
-               sourceNs+"\", \""+
-               targetNs+"\")";
-    }
-
-    static final RoutingProxyFactory
-            <MBeanServerConnection,RoutingConnectionProxy>
-        FACTORY = new RoutingProxyFactory
-        <MBeanServerConnection,RoutingConnectionProxy>() {
-
-        public RoutingConnectionProxy newInstance(MBeanServerConnection source,
-                String sourcePath, String targetPath, boolean probe) {
-            return new RoutingConnectionProxy(source,sourcePath,
-                    targetPath, probe);
-        }
-    };
-
-    public static MBeanServerConnection cd(
-            MBeanServerConnection source, String sourcePath, boolean probe) {
-        return RoutingProxy.cd(RoutingConnectionProxy.class, FACTORY,
-                source, sourcePath, probe);
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/RoutingMBeanServerConnection.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,556 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.mbeanserver.Util;
-import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMRuntimeException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServerConnection;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.RuntimeMBeanException;
-import javax.management.RuntimeOperationsException;
-
-/**
- * A RoutingMBeanServerConnection wraps a MBeanServerConnection, defining
- * abstract methods that can be implemented by subclasses to rewrite
- * routing ObjectNames. It is used to implement
- * HandlerInterceptors (wrapping JMXNamespace instances) and routing
- * proxies (used to implement cd operations).
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public abstract class RoutingMBeanServerConnection<T extends MBeanServerConnection>
-        implements MBeanServerConnection {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    /**
-     * Creates a new instance of RoutingMBeanServerConnection
-     */
-    public RoutingMBeanServerConnection() {
-    }
-
-    /**
-     * Returns the wrapped source connection. The {@code source} connection
-     * is a connection to the MBeanServer that contains the actual MBean.
-     * In the case of cascading, that would be a connection to the sub
-     * agent.
-     **/
-    protected abstract T source() throws IOException;
-
-    /**
-     * Converts a target ObjectName to a source ObjectName.
-     * The target ObjectName is the name of the MBean in the mount point
-     * target. In the case of cascading, that would be the name of the
-     * MBean in the master agent. So if a subagent S containing an MBean
-     * named "X" is mounted in the target namespace "foo//" of a master agent M,
-     * the source is S, the target is "foo//" in M, the source name is "X", and
-     * the target name is "foo//X".
-     * In the case of cascading - such as in NamespaceInterceptor, this method
-     * will convert "foo//X" (the targetName) into "X", the source name.
-     * @throws IllegalArgumentException if the name cannot be converted.
-     **/
-    protected abstract ObjectName toSource(ObjectName targetName);
-    /**
-     * Converts a source ObjectName to a target ObjectName.
-     * (see description of toSource above for explanations)
-     * In the case of cascading - such as in NamespaceInterceptor, this method
-     * will convert "X" (the sourceName) into "foo//X", the target name.
-     * @throws IllegalArgumentException if the name cannot be converted.
-     **/
-    protected abstract ObjectName toTarget(ObjectName sourceName);
-
-    /**
-     * Can be overridden by subclasses to check the validity of a new
-     * ObjectName used in createMBean or registerMBean.
-     * This method is typically used by subclasses which might require
-     * special handling for "null";
-     **/
-    protected ObjectName newSourceMBeanName(ObjectName targetName)
-        throws MBeanRegistrationException {
-        try {
-            return toSource(targetName);
-        } catch (Exception x) {
-            throw new MBeanRegistrationException(x,"Illegal MBean Name");
-        }
-    }
-
-    // Calls toSource(), Wraps IllegalArgumentException.
-    ObjectName toSourceOrRuntime(ObjectName targetName) {
-        try {
-            return toSource(targetName);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-
-    // Wraps given exception if needed.
-    RuntimeException makeCompliantRuntimeException(Exception x) {
-        if (x instanceof SecurityException)  return (SecurityException)x;
-        if (x instanceof JMRuntimeException) return (JMRuntimeException)x;
-        if (x instanceof RuntimeException)
-            return new RuntimeOperationsException((RuntimeException)x);
-        if (x instanceof IOException)
-            return Util.newRuntimeIOException((IOException)x);
-        // shouldn't come here...
-        final RuntimeException x2 = new UndeclaredThrowableException(x);
-        return new RuntimeOperationsException(x2);
-    }
-
-    // from MBeanServerConnection
-    public AttributeList getAttributes(ObjectName name, String[] attributes)
-        throws InstanceNotFoundException, ReflectionException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return source().getAttributes(sourceName, attributes);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public Object invoke(ObjectName name, String operationName, Object[] params,
-                         String[] signature)
-        throws InstanceNotFoundException, MBeanException, ReflectionException,
-            IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            final Object result =
-                    source().invoke(sourceName,operationName,params,
-                                   signature);
-            return result;
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public void unregisterMBean(ObjectName name)
-        throws InstanceNotFoundException, MBeanRegistrationException,
-            IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            source().unregisterMBean(sourceName);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public MBeanInfo getMBeanInfo(ObjectName name)
-        throws InstanceNotFoundException, IntrospectionException,
-            ReflectionException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return source().getMBeanInfo(sourceName);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public ObjectInstance getObjectInstance(ObjectName name)
-        throws InstanceNotFoundException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return processOutputInstance(
-                    source().getObjectInstance(sourceName));
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public boolean isRegistered(ObjectName name) throws IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return source().isRegistered(sourceName);
-        } catch (RuntimeMBeanException x) {
-            throw new RuntimeOperationsException(x.getTargetException());
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    // from MBeanServerConnection
-    public void setAttribute(ObjectName name, Attribute attribute)
-        throws InstanceNotFoundException, AttributeNotFoundException,
-            InvalidAttributeValueException, MBeanException,
-            ReflectionException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            source().setAttribute(sourceName,attribute);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public ObjectInstance createMBean(String className,
-            ObjectName name, ObjectName loaderName,
-            Object[] params, String[] signature)
-        throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, InstanceNotFoundException, IOException {
-        final ObjectName sourceName = newSourceMBeanName(name);
-        // Loader Name is already a sourceLoaderName.
-        final ObjectName sourceLoaderName = loaderName;
-        try {
-            final ObjectInstance instance =
-                    source().createMBean(className,sourceName,
-                                         sourceLoaderName,
-                                         params,signature);
-            return processOutputInstance(instance);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public ObjectInstance createMBean(String className, ObjectName name,
-            Object[] params, String[] signature)
-            throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, IOException {
-        final ObjectName sourceName = newSourceMBeanName(name);
-        try {
-            return processOutputInstance(source().createMBean(className,
-                    sourceName,params,signature));
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public ObjectInstance createMBean(String className, ObjectName name,
-            ObjectName loaderName)
-            throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, InstanceNotFoundException, IOException {
-        final ObjectName sourceName = newSourceMBeanName(name);
-        // Loader Name is already a source Loader Name.
-        final ObjectName sourceLoaderName = loaderName;
-        try {
-            return processOutputInstance(source().createMBean(className,
-                    sourceName,sourceLoaderName));
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public ObjectInstance createMBean(String className, ObjectName name)
-        throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, IOException {
-        final ObjectName sourceName = newSourceMBeanName(name);
-        try {
-            return processOutputInstance(source().
-                    createMBean(className,sourceName));
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-     }
-
-    // from MBeanServerConnection
-    public Object getAttribute(ObjectName name, String attribute)
-        throws MBeanException, AttributeNotFoundException,
-            InstanceNotFoundException, ReflectionException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return source().getAttribute(sourceName,attribute);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public boolean isInstanceOf(ObjectName name, String className)
-        throws InstanceNotFoundException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return source().isInstanceOf(sourceName,className);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public AttributeList setAttributes(ObjectName name, AttributeList attributes)
-        throws InstanceNotFoundException, ReflectionException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return source().
-                    setAttributes(sourceName,attributes);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // Return names in the target's context.
-    Set<ObjectInstance> processOutputInstances(Set<ObjectInstance> sources) {
-
-        final Set<ObjectInstance> result = Util.equivalentEmptySet(sources);
-        for (ObjectInstance i : sources) {
-            try {
-                final ObjectInstance target = processOutputInstance(i);
-                if (excludesFromResult(target.getObjectName(), "queryMBeans"))
-                    continue;
-                result.add(target);
-            } catch (Exception x) {
-                if (LOG.isLoggable(Level.FINE)) {
-                    LOG.fine("Skiping returned item: " +
-                             "Unexpected exception while processing " +
-                             "ObjectInstance: " + x);
-                }
-                continue;
-            }
-        }
-        return result;
-    }
-
-
-    // Return names in the target's context.
-    ObjectInstance processOutputInstance(ObjectInstance source) {
-        if (source == null) return null;
-        final ObjectName sourceName = source.getObjectName();
-        try {
-            final ObjectName targetName = toTarget(sourceName);
-            return new ObjectInstance(targetName,source.getClassName());
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    // Returns names in the target's context.
-    Set<ObjectName> processOutputNames(Set<ObjectName> sourceNames) {
-
-        final Set<ObjectName> names = Util.equivalentEmptySet(sourceNames);
-        for (ObjectName n : sourceNames) {
-            try {
-                final ObjectName targetName = toTarget(n);
-                if (excludesFromResult(targetName, "queryNames")) continue;
-                names.add(targetName);
-            } catch (Exception x) {
-                if (LOG.isLoggable(Level.FINE)) {
-                    LOG.fine("Skiping returned item: " +
-                             "Unexpected exception while processing " +
-                             "ObjectInstance: " + x);
-                }
-                continue;
-            }
-        }
-        return names;
-    }
-
-    // from MBeanServerConnection
-    public Set<ObjectInstance> queryMBeans(ObjectName name,
-            QueryExp query) throws IOException {
-        if (name == null) name=ObjectName.WILDCARD;
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return processOutputInstances(
-                    source().queryMBeans(sourceName,query));
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-
-    public Set<ObjectName> queryNames(ObjectName name, QueryExp query)
-        throws IOException {
-        if (name == null) name=ObjectName.WILDCARD;
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            final Set<ObjectName> tmp = source().queryNames(sourceName,query);
-            final Set<ObjectName> out = processOutputNames(tmp);
-            //System.err.println("queryNames: out: "+out);
-            return out;
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener)
-        throws InstanceNotFoundException,
-        ListenerNotFoundException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            source().removeNotificationListener(sourceName,listener);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public void addNotificationListener(ObjectName name, ObjectName listener,
-            NotificationFilter filter, Object handback)
-            throws InstanceNotFoundException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        // Listener name is already a source listener name.
-        try {
-            source().addNotificationListener(sourceName,listener,
-                    filter,handback);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public void addNotificationListener(ObjectName name,
-                NotificationListener listener, NotificationFilter filter,
-                Object handback) throws InstanceNotFoundException, IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            source().addNotificationListener(sourceName, listener, filter,
-                    handback);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-
-    // from MBeanServerConnection
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener, NotificationFilter filter,
-            Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException,
-                IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            source().removeNotificationListener(sourceName,listener,filter,
-                    handback);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public void removeNotificationListener(ObjectName name, ObjectName listener,
-            NotificationFilter filter, Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException,
-            IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            source().removeNotificationListener(sourceName,listener,
-                    filter,handback);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public void removeNotificationListener(ObjectName name, ObjectName listener)
-        throws InstanceNotFoundException, ListenerNotFoundException,
-               IOException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        // listener name is already a source name...
-        final ObjectName sourceListener = listener;
-        try {
-            source().removeNotificationListener(sourceName,sourceListener);
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public Integer getMBeanCount() throws IOException {
-        try {
-            return source().getMBeanCount();
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public String[] getDomains() throws IOException {
-        try {
-            return source().getDomains();
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // from MBeanServerConnection
-    public String getDefaultDomain() throws IOException {
-        try {
-            return source().getDefaultDomain();
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    /**
-     * Returns true if the given targetName must be excluded from the
-     * query result.
-     * In this base class, always return {@code false}.
-     * By default all object names returned by the sources are
-     * transmitted to the caller - there is no filtering.
-     *
-     * @param name         A target object name expressed in the caller's
-     *                     context. In the case of cascading, where the source
-     *                     is a sub agent mounted on e.g. namespace "foo",
-     *                     that would be a name prefixed by "foo//"...
-     * @param queryMethod  either "queryNames" or "queryMBeans".
-     * @return true if the name must be excluded.
-     */
-    boolean excludesFromResult(ObjectName targetName, String queryMethod) {
-        return false;
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/RoutingProxy.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-import com.sun.jmx.defaults.JmxProperties;
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanRegistrationException;
-
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespaces;
-
-
-/**
- * A RoutingProxy narrows on a given name space in a
- * source object implementing MBeanServerConnection.
- * It is used to implement
- * {@code JMXNamespaces.narrowToNamespace(...)}.
- * This abstract class has two concrete subclasses:
- * <p>{@link RoutingConnectionProxy}: to narrow down into an
- *    MBeanServerConnection.</p>
- * <p>{@link RoutingServerProxy}: to narrow down into an MBeanServer.</p>
- *
- * <p>This class can also be used to "broaden" from a namespace.  The same
- * class is used for both purposes because in both cases all that happens
- * is that ObjectNames are rewritten in one way on the way in (e.g. the
- * parameter of getMBeanInfo) and another way on the way out (e.g. the
- * return value of queryNames).</p>
- *
- * <p>Specifically, if you narrow into "a//" then you want to add the
- * "a//" prefix to ObjectNames on the way in and subtract it on the way
- * out.  But ClientContext uses this class to subtract the
- * "jmx.context//foo=bar//" prefix on the way in and add it back on the
- * way out.</p>
- *
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-//
-// RoutingProxies are client side objects which are used to narrow down
-// into a namespace. They are used to perform ObjectName translation,
-// adding the namespace to the routing ObjectName before sending it over
-// to the source connection, and removing that prefix from results of
-// queries, createMBean, registerMBean, and getObjectInstance.
-// This translation is the opposite to that which is performed by
-// NamespaceInterceptors.
-//
-// There is however a special case where routing proxies are used on the
-// 'server' side to remove a namespace - rather than to add it:
-// This the case of ClientContext.
-// When an ObjectName like "jmx.context//c1=v1,c2=v2//D:k=v" reaches the
-// jmx.context namespace, a routing proxy is used to remove the prefix
-// c1=v1,c2=v2// from the routing objectname.
-//
-// For a RoutingProxy used in a narrowDownToNamespace operation, we have:
-//     targetNs="" // targetNS is the namespace 'to remove'
-//     sourceNS=<namespace-we-narrow-down-to> // namespace 'to add'
-//
-// For a RoutingProxy used in a ClientContext operation, we have:
-//     targetNs=<encoded-context> // context must be removed from object name
-//     sourceNs="" // nothing to add...
-//
-// Finally, in order to avoid too many layers of wrapping,
-// RoutingConnectionProxy and RoutingServerProxy can be created through a
-// factory method that can concatenate namespace paths in order to
-// return a single RoutingProxy - rather than wrapping a RoutingProxy inside
-// another RoutingProxy. See RoutingConnectionProxy.cd and
-// RoutingServerProxy.cd
-//
-// The class hierarchy is as follows:
-//
-//                           RoutingMBeanServerConnection
-//                   [abstract class for all routing interceptors,
-//                    such as RoutingProxies and HandlerInterceptors]
-//                            /                          \
-//                           /                            \
-//                    RoutingProxy                HandlerInterceptor
-//          [base class for                   [base class for server side
-//           client-side objects used          objects, created by
-//           in narrowDownTo]                  DispatchInterceptors]
-//           /                  \                   |          \
-//  RoutingConnectionProxy       \                  |      NamespaceInterceptor
-//  [wraps MBeanServerConnection  \                 |     [used to remove
-//   objects]                      \                |      namespace prefix and
-//                        RoutingServerProxy        |      wrap  JMXNamespace]
-//                        [wraps MBeanServer        |
-//                         Objects]                 |
-//                                            DomainInterceptor
-//                                            [used to wrap JMXDomain]
-//
-// RoutingProxies also differ from HandlerInterceptors in that they transform
-// calls to MBeanServerConnection operations that do not have any parameters
-// into a call to the underlying JMXNamespace MBean.
-// So for instance a call to:
-//    JMXNamespaces.narrowDownToNamespace(conn,"foo").getDomains()
-// is transformed into
-//    conn.getAttribute("foo//type=JMXNamespace","Domains");
-//
-public abstract class RoutingProxy<T extends MBeanServerConnection>
-        extends RoutingMBeanServerConnection<T> {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    // The source MBeanServerConnection
-    private final T source;
-
-    // The name space we're narrowing to (usually some name space in
-    // the source MBeanServerConnection), e.g. "a" for the namespace
-    // "a//".  This is empty in the case of ClientContext described above.
-    private final String                sourceNs;
-
-    // The name space we pretend to be mounted in.  This is empty except
-    // in the case of ClientContext described above (where it will be
-    // something like "jmx.context//foo=bar".
-    private final String                targetNs;
-
-    // The name of the JMXNamespace that handles the source name space
-    private final ObjectName            handlerName;
-    private final ObjectNameRouter      router;
-    private volatile String             defaultDomain = null;
-
-    /**
-     * Creates a new instance of RoutingProxy
-     */
-    protected RoutingProxy(T source,
-                           String sourceNs,
-                           String targetNs,
-                           boolean probe) {
-        if (source == null) throw new IllegalArgumentException("null");
-        this.sourceNs = JMXNamespaces.normalizeNamespaceName(sourceNs);
-
-        // Usually sourceNs is not null, except when implementing
-        // Client Contexts
-        //
-        if (sourceNs.equals("")) {
-            this.handlerName = null;
-        } else {
-            // System.err.println("sourceNs: "+sourceNs);
-            this.handlerName =
-                JMXNamespaces.getNamespaceObjectName(this.sourceNs);
-            if (probe) {
-                try {
-                    if (!source.isRegistered(handlerName)) {
-                        InstanceNotFoundException infe =
-                                new InstanceNotFoundException(handlerName);
-                        throw new IllegalArgumentException(sourceNs +
-                                ": no such name space", infe);
-                    }
-                } catch (IOException x) {
-                    throw new IllegalArgumentException("source stale: "+x,x);
-                }
-            }
-        }
-        this.source = source;
-        this.targetNs = (targetNs==null?"":
-            JMXNamespaces.normalizeNamespaceName(targetNs));
-        this.router =
-                new ObjectNameRouter(this.targetNs,this.sourceNs);
-
-        if (LOG.isLoggable(Level.FINER))
-            LOG.finer("RoutingProxy for " + this.sourceNs + " created");
-    }
-
-    @Override
-    public T source() { return source; }
-
-    @Override
-    public ObjectName toSource(ObjectName targetName) {
-        if (targetName == null) return null;
-        if (targetName.getDomain().equals("") && targetNs.equals("")) {
-            try {
-                if (defaultDomain == null)
-                    defaultDomain = getDefaultDomain();
-            } catch(Exception x) {
-                LOG.log(Level.FINEST,"Failed to get default domain",x);
-            }
-            if (defaultDomain != null)
-                targetName = targetName.withDomain(defaultDomain);
-        }
-        return router.toSourceContext(targetName,true);
-    }
-
-    @Override
-    protected ObjectName newSourceMBeanName(ObjectName targetName)
-        throws MBeanRegistrationException {
-        if (targetName != null) return super.newSourceMBeanName(targetName);
-
-        // OK => we can accept null if sourceNs is empty.
-        if (sourceNs.equals("")) return null;
-
-        throw new MBeanRegistrationException(
-                new IllegalArgumentException(
-                "Can't use null ObjectName with namespaces"));
-    }
-
-    @Override
-    public ObjectName toTarget(ObjectName sourceName) {
-        if (sourceName == null) return null;
-        return router.toTargetContext(sourceName,false);
-    }
-
-    private Object getAttributeFromHandler(String attributeName)
-            throws IOException {
-
-        try {
-            return source().getAttribute(handlerName,attributeName);
-         } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-         } catch (IOException x) {
-             throw x;
-         } catch (MBeanException ex) {
-             throw new IOException("Failed to get "+attributeName+": "+
-                     ex.getCause(),
-                     ex.getCause());
-         } catch (Exception ex) {
-             throw new IOException("Failed to get "+attributeName+": "+
-                     ex,ex);
-         }
-    }
-
-    // We cannot call getMBeanCount() on the underlying
-    // MBeanServerConnection, because it would return the number of
-    // 'top-level' MBeans, not the number of MBeans in the name space
-    // we are narrowing to. Instead we're calling getMBeanCount() on
-    // the JMXNamespace that handles the source name space.
-    //
-    // There is however one particular case when the sourceNs is empty.
-    // In that case, there's no handler - and the 'source' is the top
-    // level namespace. In that particular case, handlerName will be null,
-    // and we directly invoke the top level source().
-    // This later complex case is only used when implementing ClientContexts.
-    //
-    @Override
-    public Integer getMBeanCount() throws IOException {
-        try {
-            if (handlerName == null) return source().getMBeanCount();
-            return (Integer) getAttributeFromHandler("MBeanCount");
-         } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-         }
-    }
-
-    // We cannot call getDomains() on the underlying
-    // MBeanServerConnection, because it would return the domains of
-    // 'top-level' MBeans, not the domains of MBeans in the name space
-    // we are narrowing to. Instead we're calling getDomains() on
-    // the JMXNamespace that handles the source name space.
-    //
-    // There is however one particular case when the sourceNs is empty.
-    // In that case, there's no handler - and the 'source' is the top
-    // level namespace. In that particular case, handlerName will be null,
-    // and we directly invoke the top level source().
-    // This later complex case is only used when implementing ClientContexts.
-    //
-    @Override
-    public String[] getDomains() throws IOException {
-        try {
-            if (handlerName == null) return source().getDomains();
-            return (String[]) getAttributeFromHandler("Domains");
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    // We cannot call getDefaultDomain() on the underlying
-    // MBeanServerConnection, because it would return the default domain of
-    // 'top-level' namespace, not the default domain in the name space
-    // we are narrowing to. Instead we're calling getDefaultDomain() on
-    // the JMXNamespace that handles the source name space.
-    //
-    // There is however one particular case when the sourceNs is empty.
-    // In that case, there's no handler - and the 'source' is the top
-    // level namespace. In that particular case, handlerName will be null,
-    // and we directly invoke the top level source().
-    // This later complex case is only used when implementing ClientContexts.
-    //
-    @Override
-    public String getDefaultDomain() throws IOException {
-        try {
-            if (handlerName == null) {
-                defaultDomain = source().getDefaultDomain();
-            } else {
-                defaultDomain =(String)
-                        getAttributeFromHandler("DefaultDomain");
-            }
-            return defaultDomain;
-        } catch (RuntimeException ex) {
-            throw makeCompliantRuntimeException(ex);
-        }
-    }
-
-    public String getSourceNamespace() {
-        return sourceNs;
-    }
-
-    public String getTargetNamespace() {
-        return targetNs;
-    }
-
-    @Override
-    public String toString() {
-        return super.toString()+", sourceNs="+
-                sourceNs + (targetNs.equals("")?"":
-                    (" mounted on targetNs="+targetNs));
-    }
-
-    // Creates an instance of a subclass 'R' of RoutingProxy<T>
-    // RoutingServerProxy and RoutingConnectionProxy have their own factory
-    // instance.
-    static interface RoutingProxyFactory<T extends MBeanServerConnection,
-            R extends RoutingProxy<T>> {
-            public R newInstance(
-                    T source, String sourcePath, String targetPath, boolean probe);
-    }
-
-    // Performs a narrowDownToNamespace operation.
-    // This method will attempt to merge two RoutingProxies in a single
-    // one if they are of the same class.
-    //
-    // This method is never called directly - it should be called only by
-    // subclasses of RoutingProxy.
-    //
-    // As for now it is called by:
-    // RoutingServerProxy.cd and RoutingConnectionProxy.cd.
-    //
-    static <T extends MBeanServerConnection, R extends RoutingProxy<T>>
-           R cd(Class<R> routingProxyClass,
-              RoutingProxyFactory<T,R> factory,
-              T source, String sourcePath, boolean probe) {
-        if (source == null) throw new IllegalArgumentException("null");
-        if (source.getClass().equals(routingProxyClass)) {
-            // cast is OK here, but findbugs complains unless we use class.cast
-            final R other = routingProxyClass.cast(source);
-            final String target = other.getTargetNamespace();
-
-            // Avoid multiple layers of serialization.
-            //
-            // We construct a new proxy from the original source instead of
-            // stacking a new proxy on top of the old one.
-            // - that is we replace
-            //      cd ( cd ( x, dir1), dir2);
-            // by
-            //      cd (x, dir1//dir2);
-            //
-            // We can do this only when the source class is exactly
-            //    RoutingServerProxy.
-            //
-            if (target == null || target.equals("")) {
-                final String path =
-                    JMXNamespaces.concat(other.getSourceNamespace(),
-                    sourcePath);
-                return factory.newInstance(other.source(), path, "", probe);
-            }
-            // Note: we could do possibly something here - but it would involve
-            //       removing part of targetDir, and possibly adding
-            //       something to sourcePath.
-            //       Too complex to bother! => simply default to stacking...
-        }
-        return factory.newInstance(source, sourcePath, "", probe);
-    }
-}
--- a/src/share/classes/com/sun/jmx/namespace/RoutingServerProxy.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,576 +0,0 @@
-/*
- * 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.jmx.namespace;
-
-
-import com.sun.jmx.mbeanserver.Util;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.util.Collections;
-import java.util.Set;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.OperationsException;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.loading.ClassLoaderRepository;
-
-/**
- * A RoutingServerProxy is an MBeanServer proxy that proxies a
- * source name space in a source MBeanServer.
- * It wraps a source MBeanServer, and rewrites routing ObjectNames.
- * It is typically use for implementing 'cd' operations, and
- * will add the source name space to routing ObjectNames at input,
- * and remove it at output.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- *
- * @since 1.7
- */
-// See class hierarchy and detailled explanations in RoutingProxy in this
-// package.
-//
-public class RoutingServerProxy
-        extends RoutingProxy<MBeanServer>
-        implements MBeanServer {
-
-    public RoutingServerProxy(MBeanServer source,
-                                String sourceNs,
-                                String targetNs,
-                                boolean probe) {
-        super(source, sourceNs, targetNs, probe);
-    }
-
-    /**
-     * This method is called each time an IOException is raised when
-     * trying to forward an operation to the underlying
-     * MBeanServerConnection, as a result of calling
-     * {@link #getMBeanServerConnection()} or as a result of invoking the
-     * operation on the returned connection.
-     * Subclasses may redefine this method if they need to perform any
-     * specific handling of IOException (logging etc...).
-     * @param x The raised IOException.
-     * @param method The name of the method in which the exception was
-     *        raised. This is one of the methods of the MBeanServer
-     *        interface.
-     * @return A RuntimeException that should be thrown by the caller.
-     *         In this default implementation, this is an
-     *         {@link UndeclaredThrowableException} wrapping <var>x</var>.
-     **/
-    protected RuntimeException handleIOException(IOException x,
-                                                 String method) {
-        return Util.newRuntimeIOException(x);
-    }
-
-
-    //--------------------------------------------
-    //--------------------------------------------
-    //
-    // Implementation of the MBeanServer interface
-    //
-    //--------------------------------------------
-    //--------------------------------------------
-    @Override
-    public void addNotificationListener(ObjectName name,
-                                        NotificationListener listener,
-                                        NotificationFilter filter,
-                                        Object handback)
-        throws InstanceNotFoundException {
-        try {
-            super.addNotificationListener(name, listener,
-                                                 filter, handback);
-        } catch (IOException x) {
-            throw handleIOException(x,"addNotificationListener");
-        }
-    }
-
-    @Override
-    public void addNotificationListener(ObjectName name,
-                                        ObjectName listener,
-                                        NotificationFilter filter,
-                                        Object handback)
-        throws InstanceNotFoundException {
-        try {
-            super.addNotificationListener(name, listener,
-                                                 filter, handback);
-        } catch (IOException x) {
-            throw handleIOException(x,"addNotificationListener");
-        }
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name)
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException {
-        try {
-            return super.createMBean(className, name);
-        } catch (IOException x) {
-            throw handleIOException(x,"createMBean");
-        }
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                      Object params[], String signature[])
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException {
-        try {
-            return super.createMBean(className, name,
-                                     params, signature);
-        } catch (IOException x) {
-            throw handleIOException(x,"createMBean");
-        }
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className,
-                                      ObjectName name,
-                                      ObjectName loaderName)
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException,
-        InstanceNotFoundException {
-        try {
-            return super.createMBean(className, name, loaderName);
-        } catch (IOException x) {
-            throw handleIOException(x,"createMBean");
-        }
-    }
-
-    @Override
-    public ObjectInstance createMBean(String className,
-                                      ObjectName name,
-                                      ObjectName loaderName,
-                                      Object params[],
-                                      String signature[])
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException,
-        InstanceNotFoundException {
-        try {
-            return super.createMBean(className, name, loaderName,
-                                            params, signature);
-        } catch (IOException x) {
-            throw handleIOException(x,"createMBean");
-        }
-    }
-
-    /**
-     * @deprecated see {@link MBeanServer#deserialize(ObjectName,byte[])
-     *                 MBeanServer}
-     **/
-    @Deprecated
-    public ObjectInputStream deserialize(ObjectName name, byte[] data)
-        throws InstanceNotFoundException, OperationsException {
-        final ObjectName sourceName = toSourceOrRuntime(name);
-        try {
-            return source().deserialize(sourceName,data);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    /**
-     * @deprecated see {@link MBeanServer#deserialize(String,byte[])
-     *                 MBeanServer}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className, byte[] data)
-        throws OperationsException, ReflectionException {
-        try {
-            return source().deserialize(className,data);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    /**
-     * @deprecated see {@link MBeanServer#deserialize(String,ObjectName,byte[])
-     *                 MBeanServer}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className,
-                                         ObjectName loaderName,
-                                         byte[] data)
-        throws
-        InstanceNotFoundException,
-        OperationsException,
-        ReflectionException {
-        try {
-            return source().deserialize(className,loaderName,data);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    @Override
-    public Object getAttribute(ObjectName name, String attribute)
-        throws
-        MBeanException,
-        AttributeNotFoundException,
-        InstanceNotFoundException,
-        ReflectionException {
-        try {
-            return super.getAttribute(name, attribute);
-        } catch (IOException x) {
-            throw handleIOException(x,"getAttribute");
-        }
-    }
-
-    @Override
-    public AttributeList getAttributes(ObjectName name, String[] attributes)
-        throws InstanceNotFoundException, ReflectionException {
-        try {
-            return super.getAttributes(name, attributes);
-        } catch (IOException x) {
-            throw handleIOException(x,"getAttributes");
-        }
-    }
-
-    public ClassLoader getClassLoader(ObjectName loaderName)
-        throws InstanceNotFoundException {
-        final ObjectName sourceName = toSourceOrRuntime(loaderName);
-        try {
-            return source().getClassLoader(sourceName);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    public ClassLoader getClassLoaderFor(ObjectName mbeanName)
-        throws InstanceNotFoundException {
-        final ObjectName sourceName = toSourceOrRuntime(mbeanName);
-        try {
-            return source().getClassLoaderFor(sourceName);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    public ClassLoaderRepository getClassLoaderRepository() {
-        try {
-            return source().getClassLoaderRepository();
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    @Override
-    public String getDefaultDomain() {
-        try {
-            return super.getDefaultDomain();
-        } catch (IOException x) {
-            throw handleIOException(x,"getDefaultDomain");
-        }
-    }
-
-    @Override
-    public String[] getDomains() {
-        try {
-            return super.getDomains();
-        } catch (IOException x) {
-            throw handleIOException(x,"getDomains");
-        }
-    }
-
-    @Override
-    public Integer getMBeanCount() {
-        try {
-            return super.getMBeanCount();
-        } catch (IOException x) {
-            throw handleIOException(x,"getMBeanCount");
-        }
-    }
-
-    @Override
-    public MBeanInfo getMBeanInfo(ObjectName name)
-        throws
-        InstanceNotFoundException,
-        IntrospectionException,
-        ReflectionException {
-        try {
-            return super.getMBeanInfo(name);
-        } catch (IOException x) {
-            throw handleIOException(x,"getMBeanInfo");
-        }
-    }
-
-    @Override
-    public ObjectInstance getObjectInstance(ObjectName name)
-        throws InstanceNotFoundException {
-        try {
-            return super.getObjectInstance(name);
-        } catch (IOException x) {
-            throw handleIOException(x,"getObjectInstance");
-        }
-    }
-
-    public Object instantiate(String className)
-        throws ReflectionException, MBeanException {
-        try {
-            return source().instantiate(className);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    public Object instantiate(String className,
-                              Object params[],
-                              String signature[])
-        throws ReflectionException, MBeanException {
-        try {
-            return source().instantiate(className,
-                    params,signature);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    public Object instantiate(String className, ObjectName loaderName)
-        throws ReflectionException, MBeanException,
-               InstanceNotFoundException {
-        final ObjectName srcLoaderName = toSourceOrRuntime(loaderName);
-        try {
-            return source().instantiate(className,srcLoaderName);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    public Object instantiate(String className, ObjectName loaderName,
-                              Object params[], String signature[])
-        throws ReflectionException, MBeanException,
-               InstanceNotFoundException {
-        final ObjectName srcLoaderName = toSourceOrRuntime(loaderName);
-        try {
-            return source().instantiate(className,srcLoaderName,
-                    params,signature);
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    @Override
-    public Object invoke(ObjectName name, String operationName,
-                         Object params[], String signature[])
-        throws
-        InstanceNotFoundException,
-        MBeanException,
-        ReflectionException {
-        try {
-            return super.invoke(name,operationName,params,signature);
-        } catch (IOException x) {
-            throw handleIOException(x,"invoke");
-        }
-    }
-
-    @Override
-    public boolean isInstanceOf(ObjectName name, String className)
-        throws InstanceNotFoundException {
-        try {
-            return super.isInstanceOf(name, className);
-        } catch (IOException x) {
-            throw handleIOException(x,"isInstanceOf");
-        }
-    }
-
-    @Override
-    public boolean isRegistered(ObjectName name) {
-        try {
-            return super.isRegistered(name);
-        } catch (IOException x) {
-            throw handleIOException(x,"isRegistered");
-        }
-    }
-
-    @Override
-    public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
-        try {
-            return super.queryMBeans(name, query);
-        } catch (IOException x) {
-            handleIOException(x,"queryMBeans");
-            return Collections.emptySet();
-        }
-    }
-
-    @Override
-    public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-        try {
-            return super.queryNames(name, query);
-        } catch (IOException x) {
-            handleIOException(x,"queryNames");
-            return Collections.emptySet();
-        }
-    }
-
-    public ObjectInstance registerMBean(Object object, ObjectName name)
-        throws
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        NotCompliantMBeanException {
-        final ObjectName sourceName = newSourceMBeanName(name);
-        try {
-            return processOutputInstance(
-                    source().registerMBean(object,sourceName));
-        } catch (RuntimeException x) {
-            throw makeCompliantRuntimeException(x);
-        }
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                                           NotificationListener listener)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            super.removeNotificationListener(name, listener);
-        } catch (IOException x) {
-            throw handleIOException(x,"removeNotificationListener");
-        }
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                                           NotificationListener listener,
-                                           NotificationFilter filter,
-                                           Object handback)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            super.removeNotificationListener(name, listener,
-                                                    filter, handback);
-        } catch (IOException x) {
-            throw handleIOException(x,"removeNotificationListener");
-        }
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                                           ObjectName listener)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            super.removeNotificationListener(name, listener);
-        } catch (IOException x) {
-            throw handleIOException(x,"removeNotificationListener");
-        }
-    }
-
-    @Override
-    public void removeNotificationListener(ObjectName name,
-                                           ObjectName listener,
-                                           NotificationFilter filter,
-                                           Object handback)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            super.removeNotificationListener(name, listener,
-                                                    filter, handback);
-        } catch (IOException x) {
-            throw handleIOException(x,"removeNotificationListener");
-        }
-    }
-
-    @Override
-    public void setAttribute(ObjectName name, Attribute attribute)
-        throws
-        InstanceNotFoundException,
-        AttributeNotFoundException,
-        InvalidAttributeValueException,
-        MBeanException,
-        ReflectionException {
-        try {
-            super.setAttribute(name, attribute);
-        } catch (IOException x) {
-            throw handleIOException(x,"setAttribute");
-        }
-    }
-
-    @Override
-    public AttributeList setAttributes(ObjectName name,
-                                       AttributeList attributes)
-        throws InstanceNotFoundException, ReflectionException {
-        try {
-            return super.setAttributes(name, attributes);
-        } catch (IOException x) {
-            throw handleIOException(x,"setAttributes");
-        }
-    }
-
-    @Override
-    public void unregisterMBean(ObjectName name)
-        throws InstanceNotFoundException, MBeanRegistrationException {
-        try {
-           super.unregisterMBean(name);
-        } catch (IOException x) {
-            throw handleIOException(x,"unregisterMBean");
-        }
-    }
-
-    static final RoutingProxyFactory<MBeanServer,RoutingServerProxy>
-        FACTORY = new RoutingProxyFactory<MBeanServer,RoutingServerProxy>() {
-
-        public RoutingServerProxy newInstance(MBeanServer source,
-                String sourcePath, String targetPath, boolean probe) {
-            return new RoutingServerProxy(
-                    source, sourcePath, targetPath, probe);
-        }
-    };
-
-    public static MBeanServer cd(
-            MBeanServer source, String sourcePath, boolean probe) {
-        return RoutingProxy.cd(RoutingServerProxy.class, FACTORY,
-                source, sourcePath, probe);
-    }
-}
--- a/src/share/classes/com/sun/jmx/namespace/package.html	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-  <head>
-    <title>The <code>com.sun.jmx.namespace</code> package</title>
-<!--
-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.
--->
-  </head>
-    <body bgcolor="white">
-        <p>The <code>com.sun.jmx.namespace</code> package contains
-            sun specific implementation classes used to implement the
-            JMX namespaces. 
-        </p>
-        <p><b>DO NOT USE THESE CLASSES DIRECTLY</b></p>
-        <p><b>
-        This API is a Sun internal API and is subject to changes without notice.
-        </b></p>
-        <p>The public API through wich these proprietary classes can be 
-           invoked is located in <code>javax.management.namespace</code>
-           package.
-        </p>
-    </body>
-</html>
--- a/src/share/classes/com/sun/jmx/namespace/serial/DefaultRewritingProcessor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/*
- * 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.jmx.namespace.serial;
-
-
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-/**
- * Class DefaultRewritingProcessor. Rewrite ObjectName in input & output
- * parameters.
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-// We know that rewriting using serialization is costly.
-// This object tries to determine whether an object needs rewriting prior
-// to rewriting, and rewrites by creating a new object in those cases
-// where we know how to recreate a new object (e.g. a Notification).
-// Rewriting is however usually not used - so this object is just a
-// skeleton that eventually uses serialization...
-//
-class DefaultRewritingProcessor extends RewritingProcessor {
-
-
-    private static enum RewriteMode {
-        INPUT,  // Input from target to source  (parameters)
-        OUTPUT  // Output from source to target (results)
-    };
-
-    private final boolean identity;
-
-    public DefaultRewritingProcessor(String targetDirName) {
-        this(targetDirName,null);
-    }
-
-    /** Creates a new instance of SerialParamProcessor */
-    public DefaultRewritingProcessor(final String remove, final String add) {
-        super(new SerialRewritingProcessor(remove, add));
-        identity = remove.equals(add);
-    }
-
-    private ObjectName rewriteObjectName(RewriteMode mode,
-            ObjectName name) {
-        return changeContext(mode, name);
-    }
-
-    private ObjectInstance rewriteObjectInstance(RewriteMode mode,
-            ObjectInstance moi) {
-        final ObjectName srcName = moi.getObjectName();
-        final ObjectName targetName = changeContext(mode,srcName);
-        if (targetName == srcName) return moi;
-        return new ObjectInstance(targetName,moi.getClassName());
-    }
-
-
-    private Object processObject(RewriteMode mode, Object obj) {
-        if (obj == null) return null;
-
-        // Some things which will always needs rewriting:
-        // ObjectName, ObjectInstance, and Notifications.
-        // Take care of those we can handle here...
-        //
-        if (obj instanceof ObjectName)
-            return rewriteObjectName(mode,(ObjectName) obj);
-        else if (obj instanceof ObjectInstance)
-            return rewriteObjectInstance(mode,(ObjectInstance) obj);
-
-        // TODO: add other standard JMX classes - like e.g. MBeanInfo...
-        //
-
-        // Well, the object may contain an ObjectName => pass it to
-        // our serial rewriting delegate...
-        //
-        return processAnyObject(mode,obj);
-    }
-
-
-    private Object processAnyObject(RewriteMode mode, Object obj) {
-        switch (mode) {
-            case INPUT:
-                return super.rewriteInput(obj);
-            case OUTPUT:
-                return super.rewriteOutput(obj);
-            default: // can't happen.
-                throw new AssertionError();
-        }
-    }
-
-    private ObjectName changeContext(RewriteMode mode, ObjectName name) {
-        switch (mode) {
-            case INPUT:
-                return toSourceContext(name);
-            case OUTPUT:
-                return toTargetContext(name);
-            default: // can't happen.
-                throw new AssertionError();
-        }
-    }
-
-    @Override
-    public ObjectName toTargetContext(ObjectName srcName) {
-        if (identity) return srcName;
-        return super.toTargetContext(srcName);
-    }
-
-    @Override
-    public ObjectName toSourceContext(ObjectName targetName) {
-        if (identity) return targetName;
-        return super.toSourceContext(targetName);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T> T rewriteInput(T input) {
-        if (identity) return input;
-        return (T) processObject(RewriteMode.INPUT,input);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T> T rewriteOutput(T result) {
-        if (identity) return result;
-        return (T) processObject(RewriteMode.OUTPUT,result);
-    }
-}
--- a/src/share/classes/com/sun/jmx/namespace/serial/IdentityProcessor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * 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.jmx.namespace.serial;
-
-
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-/**
- * Class RoutingOnlyProcessor. A RewritingProcessor that uses
- * Java Serialization to rewrite ObjectNames contained in
- * input & results...
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- *
- * @since 1.7
- */
-class IdentityProcessor extends RewritingProcessor {
-
-
-    /** Creates a new instance of SerialRewritingProcessor */
-    public IdentityProcessor() {
-    }
-
-    @Override
-    public <T> T rewriteOutput(T result) {
-        return result;
-    }
-
-    @Override
-    public <T> T rewriteInput(T input) {
-        return input;
-    }
-
-    @Override
-    public final ObjectName toTargetContext(ObjectName sourceName) {
-        return sourceName;
-    }
-
-    @Override
-    public final ObjectInstance toTargetContext(ObjectInstance sourceMoi) {
-        return sourceMoi;
-    }
-
-    @Override
-    public final ObjectName toSourceContext(ObjectName targetName) {
-        return targetName;
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/serial/JMXNamespaceContext.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * 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.jmx.namespace.serial;
-
-import com.sun.jmx.defaults.JmxProperties;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * The JMXNamespaceContext class is used to implement a thread local
- * serialization / deserialization context for namespaces.
- * <p>
- * This class is consulted by {@link javax.management.ObjectName} at
- * serialization / deserialization time.
- * The serialization or deserialization context is established by
- * by the {@link SerialRewritingProcessor} defined in this package.
- * <p>
- * These classes are Sun proprietary APIs, subject to change without
- * notice. Do not use these classes directly.
- * The public API to rewrite ObjectNames embedded in parameters is
- * defined in {@link javax.management.namespace.JMXNamespaces}.
- *
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public class JMXNamespaceContext {
-
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    public final String prefixToRemove;
-    public final String prefixToAdd;
-
-    private JMXNamespaceContext(String add, String remove) {
-        prefixToRemove = (remove==null?"":remove);
-        prefixToAdd    = (add==null?"":add);
-    }
-
-    private final static class SerialContext {
-        private JMXNamespaceContext serializationContext;
-        private JMXNamespaceContext deserializationContext;
-        public SerialContext(){
-            serializationContext = new JMXNamespaceContext("","");
-            deserializationContext = new JMXNamespaceContext("","");
-        }
-    }
-
-    private final static ThreadLocal<SerialContext> prefix =
-            new ThreadLocal<SerialContext>() {
-        @Override
-        protected SerialContext initialValue() {
-            return new SerialContext();
-        }
-    };
-
-    public static JMXNamespaceContext getSerializationContext() {
-        return prefix.get().serializationContext;
-    }
-
-    public static JMXNamespaceContext getDeserializationContext() {
-        return prefix.get().deserializationContext;
-    }
-
-    private static String[] setSerializationContext(String oldPrefix,
-            String newPrefix) {
-        final SerialContext c = prefix.get();
-        JMXNamespaceContext dc = c.serializationContext;
-        String[] old = {dc.prefixToRemove, dc.prefixToAdd};
-        c.serializationContext = new JMXNamespaceContext(newPrefix,oldPrefix);
-        return old;
-    }
-
-    private static String[] setDeserializationContext(String oldPrefix,
-            String newPrefix) {
-        final SerialContext c = prefix.get();
-        JMXNamespaceContext dc = c.deserializationContext;
-        String[] old = {dc.prefixToRemove, dc.prefixToAdd};
-        c.deserializationContext = new JMXNamespaceContext(newPrefix,oldPrefix);
-        return old;
-    }
-
-    static void serialize(ObjectOutputStream stream, Object obj,
-            String prefixToRemove, String prefixToAdd)
-            throws IOException {
-        final String[] old =
-                setSerializationContext(prefixToRemove,prefixToAdd);
-        try {
-            stream.writeObject(obj);
-        } finally {
-            try {
-                setSerializationContext(old[0],old[1]);
-            } catch (Exception x) {
-                LOG.log(Level.FINEST,
-                        "failed to restore serialization context",x);
-            }
-        }
-    }
-
-    static Object deserialize(ObjectInputStream stream,
-            String prefixToRemove,
-            String prefixToAdd)
-            throws IOException, ClassNotFoundException {
-        final String[] old =
-                setDeserializationContext(prefixToRemove,prefixToAdd);
-        try {
-            return stream.readObject();
-        } finally {
-            try {
-                setDeserializationContext(old[0],old[1]);
-            } catch (Exception x) {
-                LOG.log(Level.FINEST,
-                        "failed to restore serialization context",x);
-            }
-        }
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/serial/RewritingProcessor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,362 +0,0 @@
-/*
- * 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.jmx.namespace.serial;
-
-
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-/**
- * An object that can rewrite ObjectNames contained in input/output
- * parameters when entering/leaving a {@link javax.management.namespace
- * namespace}.
- * <p>When entering a {@link javax.management.namespace
- *    namespace}, the {@code namespace} prefix is stripped from
- *    ObjectNames contained in input parameters. When leaving a
- *    {@code namespace},
- *    the {@code namespace} prefix is prepended to the ObjectNames contained in
- *    the result parameters returned from that {@code namespace}.
- * </p>
- * <p>Objects that need to perform these operations usually use a
- *    {@code RewritingProcessor} for that purpose.<br>
- *    The {@code RewritingProcessor} allows a somewhat larger
- *    transformation in which part of a prefix {@link #newRewritingProcessor
- *    remove} can be replaced by another prefix {@link #newRewritingProcessor
- *    add}. The transformation described above correspond to the case where
- *    {@code remove} is the stripped {@link javax.management.namespace
- *    namespace} prefix (removed when entering the {@code namespace}) and
- *    {@code add} is the empty String {@code ""}.
- *    <br>
- *    It is interesting to note that {@link
- *    javax.management.JMXNamespaces#narrowToNamespace narrowToNamespace}
- *    operations use the inverse transformation (that is, {@code remove} is
- *    the empty String {@code ""} and {@code add} is the {@link
- *    javax.management.namespace namespace} prefix).
- *    <br>
- *    On a more general scale, {@link #rewriteInput rewriteInput} removes
- *    {@link #newRewritingProcessor remove} and the prepend {@link
- *     #newRewritingProcessor add}, and {@link #rewriteOutput rewriteOutput}
- *    does the opposite, removing {@link #newRewritingProcessor add}, and
- *    then adding {@link #newRewritingProcessor remove}.
- *    <br>
- *    An implementation of {@code RewritingProcessor} should make sure that
- *    <code>rewriteInput(rewriteOutput(x,clp),clp)</code> and
- *    <code>rewriteOutput(rewriteInput(x,clp),clp)</code> always return
- *    {@code x} or an exact clone of {@code x}.
- * </p>
- * <p>A default implementation of {@code RewritingProcessor} based on
- * Java Object Serialization can be
- * obtained from {@link #newRewritingProcessor newRewritingProcessor}.
- * </p>
- * <p>
- * By default, the instances of {@code RewritingProcessor} returned by
- * {@link #newRewritingProcessor newRewritingProcessor} will rewrite
- * ObjectNames contained in instances of classes they don't know about by
- * serializing and then deserializing such object instances. This will
- * happen even if such instances don't - or can't contain ObjectNames,
- * because the default implementation of {@code RewritingProcessor} will
- * not be able to determine whether instances of such classes can/do contain
- * instance of ObjectNames before serializing/deserializing them.
- * </p>
- * <p>If you are using custom classes that the default implementation of
- * {@code RewritingProcessor} don't know about, it can be interesting to
- * prevent an instance of {@code RewritingProcessor} to serialize/deserialize
- * instances of such classes for nothing. In that case, you could customize
- * the behavior of such a {@code RewritingProcessor} by wrapping it in a
- * custom subclass of {@code RewritingProcessor} as shown below:
- * <pre>
- * public class MyRewritingProcessor extends RewritingProcessor {
- *      MyRewritingProcessor(String remove, String add) {
- *          this(RewritingProcessor.newRewritingProcessor(remove,add));
- *      }
- *      MyRewritingProcessor(RewritingProcessor delegate) {
- *          super(delegate);
- *      }
- *
- *  <T> T rewriteInput(T input) {
- *          if (input == null) return null;
- *          if (MyClass.equals(input.getClass())) {
- *              // I know that MyClass doesn't contain any ObjectName
- *              return (T) input;
- *          }
- *          return super.rewriteInput(input);
- *      }
- *  <T> T rewriteOutput(T result) {
- *          if (result == null) return null;
- *          if (MyClass.equals(result.getClass())) {
- *              // I know that MyClass doesn't contain any ObjectName
- *              return (T) result;
- *          }
- *          return super.rewriteOutput(result);
- *      }
- * }
- * </pre>
- * </p>
- * <p>Such a subclass may also provide an alternate way of rewriting
- *    custom subclasses for which rewriting is needed - for instance:
- * <pre>
- * public class MyRewritingProcessor extends RewritingProcessor {
- *      MyRewritingProcessor(String remove, String add) {
- *          this(RewritingProcessor.newRewritingProcessor(remove,add));
- *      }
- *      MyRewritingProcessor(RewritingProcessor delegate) {
- *          super(delegate);
- *      }
- *
- *  <T> T rewriteInput(T input) {
- *          if (input == null) return null;
- *          if (MyClass.equals(input.getClass())) {
- *              // I know that MyClass doesn't contain any ObjectName
- *              return (T) input;
- *          } else if (MyOtherClass.equals(input.getClass())) {
- *              // Returns a new instance in which ObjectNames have been
- *              // replaced.
- *              final ObjectName aname = ((MyOtherClass)input).getName();
- *              return (T) (new MyOtherClass(super.rewriteInput(aname)));
- *          }
- *          return super.rewriteInput(input,clp);
- *      }
- *  <T> T rewriteOutput(T result) {
- *          if (result == null) return null;
- *          if (MyClass.equals(result.getClass())) {
- *              // I know that MyClass doesn't contain any ObjectName
- *              return (T) result;
- *          } else if (MyOtherClass.equals(result.getClass())) {
- *              // Returns a new instance in which ObjectNames have been
- *              // replaced.
- *              final ObjectName aname = ((MyOtherClass)result).getName();
- *              return (T) (new MyOtherClass(super.rewriteOutput(aname)));
- *          }
- *          return super.rewriteOutput(result,clp);
- *      }
- * }
- * </pre>
- * </p>
- * <p>If your application only uses {@link javax.management.MXBean MXBeans},
- * or MBeans using simple types, and doesn't define any custom subclass of
- * {@link javax.management.Notification}, you should never write such
- * such {@code RewitingProcessor} implementations.
- * </p>
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-public abstract class RewritingProcessor {
-    /**
-     * A logger for this class.
-     **/
-    private final RewritingProcessor delegate;
-
-    /**
-     * Creates a new instance of RewritingProcessor.
-     * <p>This is equivalent to calling {@link
-     * #RewritingProcessor(RewritingProcessor) RewritingProcessor(null)}.
-     * </p>
-     **/
-    protected RewritingProcessor() {
-        this(null);
-    }
-
-    /**
-     * Creates a new instance of RewritingProcessor, with a delegate.
-     * @param delegate a {@code RewritingProcessor} to which all the
-     *        calls will be delegated. When implementing a subclass
-     *        of  {@code RewritingProcessor}, calling {@link
-     *        #rewriteInput super.rewriteInput} will invoke
-     *        {@code delegate.rewriteInput} and calling {@link
-     *        #rewriteOutput super.rewriteOutput} will invoke
-     *        {@code delegate.rewriteOutput}.
-     *
-     **/
-    protected RewritingProcessor(RewritingProcessor delegate) {
-        this.delegate = delegate;
-    }
-
-    /**
-     * Rewrites ObjectNames when {@link RewritingProcessor leaving} a {@link
-     * javax.management.namespace namespace}.
-     * <p>
-     * Returns {@code obj}, if it is known that {@code obj} doesn't contain
-     * any ObjectName, or a new copied instance of {@code obj} in which
-     * ObjectNames (if any) will have been rewritten, if {@code obj} contains
-     * ObjectNames, or if it is not known whether {@code obj} contains
-     * ObjectNames or not.
-     * </p>
-     * <p>
-     * The default implementation of this method is as follows: if the
-     * {@link #RewritingProcessor(RewritingProcessor) delegate} is {@code
-     * null}, throws an {@link IllegalArgumentException}. Otherwise,
-     * returns {@code delegate.rewriteOutput(obj)}.
-     * </p>
-     * <p>This behavior can be overridden by subclasses as shown in this
-     * class {@link RewritingProcessor description}.
-     * </p>
-     * @param obj The result to be rewritten if needed.
-     *
-     * @return {@code obj}, or a clone of {@code obj} in which ObjectNames
-     *         have been rewritten. See this class {@link RewritingProcessor
-     *         description} for more details.
-     * @throws IllegalArgumentException if this implementation does not know
-     *         how to rewrite the object.
-     **/
-    public <T> T rewriteOutput(T obj) {
-        if (obj == null) return null;
-        if (delegate != null)
-            return delegate.rewriteOutput(obj);
-        throw new IllegalArgumentException("can't rewrite "+
-                obj.getClass().getName());
-    }
-
-    /**
-     * Rewrites ObjectNames when {@link RewritingProcessor entering} a {@link
-     * javax.management.namespace namespace}.
-     * <p>
-     * Returns {@code obj}, if it is known that {@code obj} doesn't contain
-     * any ObjectName, or a new copied instance of {@code obj} in which
-     * ObjectNames (if any) will have been rewritten, if {@code obj} contains
-     * ObjectNames, or if it is not known whether {@code obj} contains
-     * ObjectNames or not.
-     * </p>
-     * <p>
-     * The default implementation of this method is as follows: if the
-     * {@link #RewritingProcessor(RewritingProcessor) delegate} is {@code
-     * null}, throws an {@link IllegalArgumentException}. Otherwise,
-     * returns {@code delegate.rewriteInput(obj)}.
-     * </p>
-     * <p>This behavior can be overridden by subclasses as shown in this
-     * class {@link RewritingProcessor description}.
-     * </p>
-     * @param obj The result to be rewritten if needed.
-     * @return {@code obj}, or a clone of {@code obj} in which ObjectNames
-     *         have been rewritten. See this class {@link RewritingProcessor
-     *         description} for more details.
-     * @throws IllegalArgumentException if this implementation does not know
-     *         how to rewrite the object.
-     **/
-    public <T> T rewriteInput(T obj) {
-        if (obj == null) return null;
-        if (delegate != null)
-            return delegate.rewriteInput(obj);
-        throw new IllegalArgumentException("can't rewrite "+
-                obj.getClass().getName());
-    }
-
-    /**
-     * Translate a routing ObjectName from the target (calling) context to
-     * the source (called) context when {@link RewritingProcessor entering} a
-     * {@link javax.management.namespace namespace}.
-     * <p>
-     * The default implementation of this method is as follows: if the
-     * {@link #RewritingProcessor(RewritingProcessor) delegate} is {@code
-     * null}, throws an {@link IllegalArgumentException}. Otherwise,
-     * returns {@code delegate.toSourceContext(targetName)}.
-     * </p>
-     * <p>This behavior can be overridden by subclasses as shown in this
-     * class {@link RewritingProcessor description}.
-     * </p>
-     * @param targetName The routing target ObjectName to translate.
-     * @return The ObjectName translated to the source context.
-     * @throws IllegalArgumentException if this implementation does not know
-     *         how to rewrite the object.
-     **/
-    public ObjectName toSourceContext(ObjectName targetName) {
-        if (delegate != null)
-            return delegate.toSourceContext(targetName);
-        throw new IllegalArgumentException("can't rewrite targetName: "+
-               " no delegate.");
-    }
-
-    /**
-     * Translate an ObjectName returned from the source context into
-     * the target (calling) context when {@link RewritingProcessor leaving} a
-     * {@link javax.management.namespace namespace}.
-     * <p>
-     * The default implementation of this method is as follows: if the
-     * {@link #RewritingProcessor(RewritingProcessor) delegate} is {@code
-     * null}, throws an {@link IllegalArgumentException}. Otherwise,
-     * returns {@code delegate.toTargetContext(sourceName)}.
-     * </p>
-     * <p>This behavior can be overridden by subclasses as shown in this
-     * class {@link RewritingProcessor description}.
-     * </p>
-     * @param sourceName The routing source ObjectName to translate to the
-     *        target context.
-     * @return The ObjectName translated to the target context.
-     * @throws IllegalArgumentException if this implementation does not know
-     *         how to rewrite the object.
-     **/
-    public ObjectName toTargetContext(ObjectName sourceName) {
-        if (delegate != null)
-            return delegate.toTargetContext(sourceName);
-        throw new IllegalArgumentException("can't rewrite sourceName: "+
-               " no delegate.");
-    }
-
-    /**
-     * Translate an ObjectInstance returned from the source context into
-     * the target (calling) context when {@link RewritingProcessor leaving} a
-     * {@link javax.management.namespace namespace}.
-     * <p>
-     * The default implementation of this method is as follows: if the
-     * {@link #RewritingProcessor(RewritingProcessor) delegate} is {@code
-     * null}, throws an {@link IllegalArgumentException}. Otherwise,
-     * returns {@code delegate.toTargetContext(sourceMoi)}.
-     * </p>
-     * <p>This behavior can be overridden by subclasses as shown in this
-     * class {@link RewritingProcessor description}.
-     * </p>
-     * @param sourceMoi The routing source ObjectInstance to translate.
-     * @return The ObjectInstance translated to the target context.
-     * @throws IllegalArgumentException if this implementation does not know
-     *         how to rewrite the object.
-     **/
-    public ObjectInstance toTargetContext(ObjectInstance sourceMoi) {
-        if (delegate != null)
-            return delegate.toTargetContext(sourceMoi);
-        throw new IllegalArgumentException("can't rewrite sourceName: "+
-               " no delegate.");
-    }
-
-    /**
-     * Creates a new default instance of {@link RewritingProcessor}.
-     * @param remove The prefix to remove from {@link ObjectName ObjectNames}
-     *        when {@link RewritingProcessor entering} the {@link
-     *        javax.management.namespace namespace}.
-     * @param add The prefix to add to {@link ObjectName ObjectNames}
-     *        when {@link RewritingProcessor entering} the {@link
-     *        javax.management.namespace namespace} (this is performed
-     *        after having removed the {@code remove} prefix.
-     * @return A new {@link RewritingProcessor} processor object that will
-     *         perform the requested operation, using Java serialization if
-     *         necessary.
-     **/
-    public static RewritingProcessor newRewritingProcessor(String remove,
-            String add) {
-        return new DefaultRewritingProcessor(remove,add);
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/serial/RoutingOnlyProcessor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * 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.jmx.namespace.serial;
-
-import com.sun.jmx.namespace.ObjectNameRouter;
-
-
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-/**
- * Class RoutingOnlyProcessor. A RewritingProcessor that uses
- * Java Serialization to rewrite ObjectNames contained in
- * input and results...
- *
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-class RoutingOnlyProcessor extends RewritingProcessor {
-
-    final ObjectNameRouter router;
-
-    public RoutingOnlyProcessor(String targetDirName) {
-        this(targetDirName,null);
-    }
-
-    /** Creates a new instance of RoutingOnlyProcessor */
-    public RoutingOnlyProcessor(final String remove, final String add) {
-        super(new IdentityProcessor());
-        if (remove == null || add == null)
-            throw new IllegalArgumentException("Null argument");
-        router = new ObjectNameRouter(remove,add);
-    }
-
-    @Override
-    public final ObjectName toTargetContext(ObjectName sourceName) {
-        return router.toTargetContext(sourceName,false);
-    }
-
-    @Override
-    public final ObjectName toSourceContext(ObjectName targetName) {
-        return router.toSourceContext(targetName,false);
-    }
-
-    @Override
-    public final ObjectInstance toTargetContext(ObjectInstance sourceMoi) {
-        return router.toTargetContext(sourceMoi,false);
-    }
-}
--- a/src/share/classes/com/sun/jmx/namespace/serial/SerialRewritingProcessor.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,172 +0,0 @@
-/*
- * 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.jmx.namespace.serial;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InvalidClassException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.ObjectStreamClass;
-import java.io.OutputStream;
-import java.util.LinkedList;
-import java.util.Queue;
-
-import javax.management.ObjectName;
-
-/**
- * Class SerialRewritingProcessor. A RewritingProcessor that uses
- * Java Serialization to rewrite ObjectNames contained in
- * input & results...
- * <p><b>
- * This API is a Sun internal API and is subject to changes without notice.
- * </b></p>
- * @since 1.7
- */
-class SerialRewritingProcessor extends RewritingProcessor {
-
-
-    private static class CloneOutput extends ObjectOutputStream {
-        Queue<Class<?>> classQueue = new LinkedList<Class<?>>();
-
-        CloneOutput(OutputStream out) throws IOException {
-            super(out);
-        }
-
-        @Override
-        protected void annotateClass(Class<?> c) {
-            classQueue.add(c);
-        }
-
-        @Override
-        protected void annotateProxyClass(Class<?> c) {
-            classQueue.add(c);
-        }
-    }
-
-    private static class CloneInput extends ObjectInputStream {
-        private final CloneOutput output;
-
-        CloneInput(InputStream in, CloneOutput output) throws IOException {
-            super(in);
-            this.output = output;
-        }
-
-        @Override
-        protected Class<?> resolveClass(ObjectStreamClass osc)
-        throws IOException, ClassNotFoundException {
-            Class<?> c = output.classQueue.poll();
-            String expected = osc.getName();
-            String found = (c == null) ? null : c.getName();
-            if (!expected.equals(found)) {
-                throw new InvalidClassException("Classes desynchronized: " +
-                        "found " + found + " when expecting " + expected);
-            }
-            return c;
-        }
-
-        @Override
-        protected Class<?> resolveProxyClass(String[] interfaceNames)
-        throws IOException, ClassNotFoundException {
-            return output.classQueue.poll();
-        }
-    }
-
-
-    final String targetPrefix;
-    final String sourcePrefix;
-    final boolean identity;
-
-
-    public SerialRewritingProcessor(String targetDirName) {
-        this(targetDirName,null);
-    }
-
-    /** Creates a new instance of SerialRewritingProcessor */
-    public SerialRewritingProcessor(final String remove, final String add) {
-        super(new RoutingOnlyProcessor(remove,add));
-        this.targetPrefix = remove;
-        this.sourcePrefix = add;
-        identity = targetPrefix.equals(sourcePrefix);
-    }
-
-    private <T> T  switchContext(T result, String from,String to)
-            throws IOException, ClassNotFoundException {
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        final CloneOutput ostream = new CloneOutput(baos);
-
-        JMXNamespaceContext.serialize(ostream,result,from,null);
-        ostream.flush();
-
-        final byte[] bytes = baos.toByteArray();
-        final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
-        final CloneInput istream = new CloneInput(bais, ostream);
-        @SuppressWarnings("unchecked")
-        final T clone = (T) JMXNamespaceContext.deserialize(istream,null,to);
-        return clone;
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public <T> T rewriteOutput(T result) {
-        if (identity) return result;
-        return (T) processOutput(result);
-    }
-
-    private Object processOutput(Object result) {
-        try {
-            if (result instanceof ObjectName)
-                return toTargetContext((ObjectName) result);
-            return switchContext(result,sourcePrefix,targetPrefix);
-        } catch (ClassNotFoundException x) {
-            throw new IllegalArgumentException("Can't process result: "+x,x);
-        } catch (IOException x) {
-            throw new IllegalArgumentException("Can't process result: "+x,x);
-        }
-    }
-
-    @Override
-    @SuppressWarnings("unchecked")
-    public <T> T rewriteInput(T input) {
-        if (identity) return input;
-        return (T) processInput(input);
-    }
-
-    private Object processInput(Object input) {
-        try {
-            if (input instanceof ObjectName)
-                return toSourceContext((ObjectName) input);
-            return switchContext(input,targetPrefix,sourcePrefix);
-        } catch (ClassNotFoundException x) {
-            throw new IllegalArgumentException("Can't process input: "+x,x);
-        } catch (IOException x) {
-            throw new IllegalArgumentException("Can't process input: "+x,x);
-        }
-    }
-
-}
--- a/src/share/classes/com/sun/jmx/namespace/serial/package.html	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
-<html>
-  <head>
-    <title>The <code>com.sun.jmx.namespace.serial</code> package</title>
-<!--
-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.
--->
-  </head>
-  <body bgcolor="white">
-  <p>The <code>com.sun.jmx.namespace.serial</code> package contains
-     sun specific implementation classes used to switch namespace
-     prefixes in ObjectName during serialization.
-  </p>
-  <p><b>NEVER USE THESE CLASSES DIRECTLY</b></p>
-  <p><b>
-  This API is a Sun internal API and is subject to changes without notice.
-  </b></p>
-  <p>The public API through which these proprietary classes can be invoked is
-      located in <code>javax.management.namespace.JMXNamespaces</code>
-  </p>
-  </body>
-</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,188 @@
+/*
+ * 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.jmx.remote.internal;
+
+import java.util.Properties;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
+
+import java.util.Properties;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * A helper class for RMI-IIOP and CORBA APIs.
+ */
+
+public final class IIOPHelper {
+    private IIOPHelper() { }
+
+    // loads IIOPProxy implementation class if available
+    private static final String IMPL_CLASS =
+        "com.sun.jmx.remote.protocol.iiop.IIOPProxyImpl";
+    private static final IIOPProxy proxy =
+        AccessController.doPrivileged(new PrivilegedAction<IIOPProxy>() {
+            public IIOPProxy run() {
+                try {
+                    Class<?> c = Class.forName(IMPL_CLASS, true, null);
+                    return (IIOPProxy)c.newInstance();
+                } catch (ClassNotFoundException cnf) {
+                    return null;
+                } catch (InstantiationException e) {
+                    throw new AssertionError(e);
+                } catch (IllegalAccessException e) {
+                    throw new AssertionError(e);
+                }
+            }});
+
+    /**
+     * Returns true if RMI-IIOP and CORBA is available.
+     */
+    public static boolean isAvailable() {
+        return proxy != null;
+    }
+
+    private static void ensureAvailable() {
+        if (proxy == null)
+            throw new AssertionError("Should not here");
+    }
+
+    /**
+     * Returns true if the given object is a Stub.
+     */
+    public static boolean isStub(Object obj) {
+        return (proxy == null) ? false : proxy.isStub(obj);
+    }
+
+    /**
+     * Returns the Delegate to which the given Stub delegates.
+     */
+    public static Object getDelegate(Object stub) {
+        ensureAvailable();
+        return proxy.getDelegate(stub);
+    }
+
+    /**
+     * Sets the Delegate for a given Stub.
+     */
+    public static void setDelegate(Object stub, Object delegate) {
+        ensureAvailable();
+        proxy.setDelegate(stub, delegate);
+    }
+
+    /**
+     * Returns the ORB associated with the given stub
+     *
+     * @throws  UnsupportedOperationException
+     *          if the object does not support the operation that
+     *          was invoked
+     */
+    public static Object getOrb(Object stub) {
+        ensureAvailable();
+        return proxy.getOrb(stub);
+    }
+
+    /**
+     * Connects the Stub to the given ORB.
+     */
+    public static void connect(Object stub, Object orb)
+        throws RemoteException
+    {
+        ensureAvailable();
+        proxy.connect(stub, orb);
+    }
+
+    /**
+     * Returns true if the given object is an ORB.
+     */
+    public static boolean isOrb(Object obj) {
+        ensureAvailable();
+        return proxy.isOrb(obj);
+    }
+
+    /**
+     * Creates, and returns, a new ORB instance.
+     */
+    public static Object createOrb(String[] args, Properties props) {
+        ensureAvailable();
+        return proxy.createOrb(args, props);
+    }
+
+    /**
+     * Converts a string, produced by the object_to_string method, back
+     * to a CORBA object reference.
+     */
+    public static Object stringToObject(Object orb, String str) {
+        ensureAvailable();
+        return proxy.stringToObject(orb, str);
+    }
+
+    /**
+     * Converts the given CORBA object reference to a string.
+     */
+    public static String objectToString(Object orb, Object obj) {
+        ensureAvailable();
+        return proxy.objectToString(orb, obj);
+    }
+
+    /**
+     * Checks to ensure that an object of a remote or abstract interface
+     * type can be cast to a desired type.
+     */
+    public static <T> T narrow(Object narrowFrom, Class<T> narrowTo) {
+        ensureAvailable();
+        return proxy.narrow(narrowFrom, narrowTo);
+    }
+
+    /**
+     * Makes a server object ready to receive remote calls
+     */
+    public static void exportObject(Remote obj) throws RemoteException {
+        ensureAvailable();
+        proxy.exportObject(obj);
+    }
+
+    /**
+     * Deregisters a server object from the runtime.
+     */
+    public static void unexportObject(Remote obj) throws NoSuchObjectException {
+        ensureAvailable();
+        proxy.unexportObject(obj);
+    }
+
+    /**
+     * Returns a stub for the given server object.
+     */
+    public static Remote toStub(Remote obj) throws NoSuchObjectException {
+        ensureAvailable();
+        return proxy.toStub(obj);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/jmx/remote/internal/IIOPProxy.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,110 @@
+/*
+ * 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.jmx.remote.internal;
+
+import java.util.Properties;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
+
+/**
+ * An interface to a subset of the RMI-IIOP and CORBA APIs to avoid a
+ * static dependencies on the types defined by these APIs.
+ */
+
+public interface IIOPProxy {
+
+    /**
+     * Returns true if the given object is a Stub.
+     */
+    boolean isStub(Object obj);
+
+    /**
+     * Returns the Delegate to which the given Stub delegates.
+     */
+    Object getDelegate(Object stub);
+
+    /**
+     * Sets the Delegate for a given Stub.
+     */
+    void setDelegate(Object stub, Object delegate);
+
+    /**
+     * Returns the ORB associated with the given stub
+     *
+     * @throws  UnsupportedOperationException
+     *          if the object does not support the operation that
+     *          was invoked
+     */
+    Object getOrb(Object stub);
+
+    /**
+     * Connects the Stub to the given ORB.
+     */
+    void connect(Object stub, Object orb) throws RemoteException;
+
+    /**
+     * Returns true if the given object is an ORB.
+     */
+    boolean isOrb(Object obj);
+
+    /**
+     * Creates, and returns, a new ORB instance.
+     */
+    Object createOrb(String[] args, Properties props);
+
+    /**
+     * Converts a string, produced by the object_to_string method, back
+     * to a CORBA object reference.
+     */
+    Object stringToObject(Object orb, String str);
+
+    /**
+     * Converts the given CORBA object reference to a string.
+     */
+    String objectToString(Object orb, Object obj);
+
+    /**
+     * Checks to ensure that an object of a remote or abstract interface
+     * type can be cast to a desired type.
+     */
+    <T> T narrow(Object narrowFrom, Class<T> narrowTo);
+
+    /**
+     * Makes a server object ready to receive remote calls
+     */
+    void exportObject(Remote obj) throws RemoteException;
+
+    /**
+     * Deregisters a server object from the runtime.
+     */
+    void unexportObject(Remote obj) throws NoSuchObjectException;
+
+    /**
+     * Returns a stub for the given server object.
+     */
+    Remote toStub(Remote obj) throws NoSuchObjectException;
+}
--- a/src/share/classes/com/sun/jmx/remote/internal/ProxyInputStream.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,241 +0,0 @@
-/*
- * Copyright 2003-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.jmx.remote.internal;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-import org.omg.CORBA.Any;
-import org.omg.CORBA.Context;
-import org.omg.CORBA.NO_IMPLEMENT;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.portable.BoxedValueHelper;
-
-@SuppressWarnings({"deprecation", "rawtypes"})
-public class ProxyInputStream extends org.omg.CORBA_2_3.portable.InputStream {
-    public ProxyInputStream(org.omg.CORBA.portable.InputStream in) {
-        this.in = in;
-    }
-
-    public boolean read_boolean() {
-        return in.read_boolean();
-    }
-
-    public char read_char() {
-        return in.read_char();
-    }
-
-    public char read_wchar() {
-        return in.read_wchar();
-    }
-
-    public byte read_octet() {
-        return in.read_octet();
-    }
-
-    public short read_short() {
-        return in.read_short();
-    }
-
-    public short read_ushort() {
-        return in.read_ushort();
-    }
-
-    public int read_long() {
-        return in.read_long();
-    }
-
-    public int read_ulong() {
-        return in.read_ulong();
-    }
-
-    public long read_longlong() {
-        return in.read_longlong();
-    }
-
-    public long read_ulonglong() {
-        return in.read_ulonglong();
-    }
-
-    public float read_float() {
-        return in.read_float();
-    }
-
-    public double read_double() {
-        return in.read_double();
-    }
-
-    public String read_string() {
-        return in.read_string();
-    }
-
-    public String read_wstring() {
-        return in.read_wstring();
-    }
-
-    public void read_boolean_array(boolean[] value, int offset, int length) {
-        in.read_boolean_array(value, offset, length);
-    }
-
-    public void read_char_array(char[] value, int offset, int length) {
-        in.read_char_array(value, offset, length);
-    }
-
-    public void read_wchar_array(char[] value, int offset, int length) {
-        in.read_wchar_array(value, offset, length);
-    }
-
-    public void read_octet_array(byte[] value, int offset, int length) {
-        in.read_octet_array(value, offset, length);
-    }
-
-    public void read_short_array(short[] value, int offset, int length) {
-        in.read_short_array(value, offset, length);
-    }
-
-    public void read_ushort_array(short[] value, int offset, int length) {
-        in.read_ushort_array(value, offset, length);
-    }
-
-    public void read_long_array(int[] value, int offset, int length) {
-        in.read_long_array(value, offset, length);
-    }
-
-    public void read_ulong_array(int[] value, int offset, int length) {
-        in.read_ulong_array(value, offset, length);
-    }
-
-    public void read_longlong_array(long[] value, int offset, int length) {
-        in.read_longlong_array(value, offset, length);
-    }
-
-    public void read_ulonglong_array(long[] value, int offset, int length) {
-        in.read_ulonglong_array(value, offset, length);
-    }
-
-    public void read_float_array(float[] value, int offset, int length) {
-        in.read_float_array(value, offset, length);
-    }
-
-    public void read_double_array(double[] value, int offset, int length) {
-        in.read_double_array(value, offset, length);
-    }
-
-    public org.omg.CORBA.Object read_Object() {
-        return in.read_Object();
-    }
-
-    public TypeCode read_TypeCode() {
-        return in.read_TypeCode();
-    }
-
-    public Any read_any() {
-        return in.read_any();
-    }
-
-    /**
-     * @deprecated
-     */
-    @Override
-    @Deprecated
-    public org.omg.CORBA.Principal read_Principal() {
-        return in.read_Principal();
-    }
-
-    @Override
-    public int read() throws IOException {
-        return in.read();
-    }
-
-    @Override
-    public BigDecimal read_fixed() {
-        return in.read_fixed();
-    }
-
-    @Override
-    public Context read_Context() {
-        return in.read_Context();
-    }
-
-    @Override
-    public org.omg.CORBA.Object read_Object(java.lang.Class clz) {
-        return in.read_Object(clz);
-    }
-
-    @Override
-    public ORB orb() {
-        return in.orb();
-    }
-
-    @Override
-    public Serializable read_value() {
-        return narrow().read_value();
-    }
-
-    @Override
-    public Serializable read_value(Class clz) {
-        return narrow().read_value(clz);
-    }
-
-    @Override
-    public Serializable read_value(BoxedValueHelper factory) {
-        return narrow().read_value(factory);
-    }
-
-    @Override
-    public Serializable read_value(String rep_id) {
-        return narrow().read_value(rep_id);
-    }
-
-    @Override
-    public Serializable read_value(Serializable value) {
-        return narrow().read_value(value);
-    }
-
-    @Override
-    public Object read_abstract_interface() {
-        return narrow().read_abstract_interface();
-    }
-
-    @Override
-    public Object read_abstract_interface(Class clz) {
-        return narrow().read_abstract_interface(clz);
-    }
-
-    protected org.omg.CORBA_2_3.portable.InputStream narrow() {
-        if (in instanceof org.omg.CORBA_2_3.portable.InputStream)
-            return (org.omg.CORBA_2_3.portable.InputStream) in;
-        throw new NO_IMPLEMENT();
-    }
-
-    public org.omg.CORBA.portable.InputStream getProxiedInputStream() {
-        return in;
-    }
-
-    protected final org.omg.CORBA.portable.InputStream in;
-}
--- a/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java	Wed Nov 25 11:08:25 2009 -0800
@@ -86,8 +86,7 @@
 
         // Explicitly check MBeanPermission for addNotificationListener
         //
-        checkMBeanPermission(getMBeanServerName(),
-                mbeanServer, name, "addNotificationListener");
+        checkMBeanPermission(name, "addNotificationListener");
         if (notificationAccessController != null) {
             notificationAccessController.addNotificationListener(
                 connectionId, name, getSubject());
@@ -157,8 +156,7 @@
 
         // Explicitly check MBeanPermission for removeNotificationListener
         //
-        checkMBeanPermission(getMBeanServerName(),
-                mbeanServer, name, "removeNotificationListener");
+        checkMBeanPermission(name, "removeNotificationListener");
         if (notificationAccessController != null) {
             notificationAccessController.removeNotificationListener(
                 connectionId, name, getSubject());
@@ -333,8 +331,8 @@
      * Explicitly check the MBeanPermission for
      * the current access control context.
      */
-    public static void checkMBeanPermission(String serverName,
-            final MBeanServer mbs, final ObjectName name, final String actions)
+    public void checkMBeanPermission(
+            final ObjectName name, final String actions)
             throws InstanceNotFoundException, SecurityException {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
@@ -345,7 +343,7 @@
                     new PrivilegedExceptionAction<ObjectInstance>() {
                         public ObjectInstance run()
                         throws InstanceNotFoundException {
-                            return mbs.getObjectInstance(name);
+                            return mbeanServer.getObjectInstance(name);
                         }
                 });
             } catch (PrivilegedActionException e) {
@@ -353,7 +351,6 @@
             }
             String classname = oi.getClassName();
             MBeanPermission perm = new MBeanPermission(
-                serverName,
                 classname,
                 null,
                 name,
@@ -369,8 +366,7 @@
                                               TargetedNotification tn) {
         try {
             if (checkNotificationEmission) {
-                checkMBeanPermission(getMBeanServerName(),
-                        mbeanServer, name, "addNotificationListener");
+                checkMBeanPermission(name, "addNotificationListener");
             }
             if (notificationAccessController != null) {
                 notificationAccessController.fetchNotification(
@@ -432,27 +428,12 @@
         }
     }
 
-    private String getMBeanServerName() {
-        if (mbeanServerName != null) return mbeanServerName;
-        else return (mbeanServerName = getMBeanServerName(mbeanServer));
-    }
-
-    private static String getMBeanServerName(final MBeanServer server) {
-        final PrivilegedAction<String> action = new PrivilegedAction<String>() {
-            public String run() {
-                return Util.getMBeanServerSecurityName(server);
-            }
-        };
-        return AccessController.doPrivileged(action);
-    }
-
 
     //------------------
     // PRIVATE VARIABLES
     //------------------
 
     private MBeanServer mbeanServer;
-    private volatile String mbeanServerName;
 
     private final String connectionId;
 
@@ -462,7 +443,7 @@
     private final static int[] listenerCounterLock = new int[0];
 
     private NotificationBuffer notifBuffer;
-    private Map<ObjectName, Set<IdAndFilter>> listenerMap =
+    private final Map<ObjectName, Set<IdAndFilter>> listenerMap =
             new HashMap<ObjectName, Set<IdAndFilter>>();
 
     private boolean terminated = false;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/jmx/remote/protocol/iiop/IIOPProxyImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,119 @@
+/*
+ * 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.jmx.remote.protocol.iiop;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.Delegate;
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Stub;
+
+import java.util.Properties;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.NoSuchObjectException;
+
+import com.sun.jmx.remote.internal.IIOPProxy;
+
+/**
+ * An implementatin of IIOPProxy that simply delegates to the appropriate
+ * RMI-IIOP and CORBA APIs.
+ */
+
+public class IIOPProxyImpl implements IIOPProxy {
+    public IIOPProxyImpl() { }
+
+    @Override
+    public boolean isStub(Object obj) {
+        return (obj instanceof Stub);
+    }
+
+    @Override
+    public Object getDelegate(Object stub) {
+        return ((Stub)stub)._get_delegate();
+    }
+
+    @Override
+    public void setDelegate(Object stub, Object delegate) {
+        ((Stub)stub)._set_delegate((Delegate)delegate);
+    }
+
+    @Override
+    public Object getOrb(Object stub) {
+        try {
+            return ((Stub)stub)._orb();
+        } catch (org.omg.CORBA.BAD_OPERATION x) {
+            throw new UnsupportedOperationException(x);
+        }
+    }
+
+    @Override
+    public void connect(Object stub, Object orb)
+        throws RemoteException
+    {
+        ((Stub)stub).connect((ORB)orb);
+    }
+
+    @Override
+    public boolean isOrb(Object obj) {
+        return (obj instanceof ORB);
+    }
+
+    @Override
+    public Object createOrb(String[] args, Properties props) {
+        return ORB.init(args, props);
+    }
+
+    @Override
+    public Object stringToObject(Object orb, String str) {
+        return ((ORB)orb).string_to_object(str);
+    }
+
+    @Override
+    public String objectToString(Object orb, Object obj) {
+        return ((ORB)orb).object_to_string((org.omg.CORBA.Object)obj);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public <T> T narrow(Object narrowFrom, Class<T> narrowTo) {
+        return (T)PortableRemoteObject.narrow(narrowFrom, narrowTo);
+    }
+
+    @Override
+    public void exportObject(Remote obj) throws RemoteException {
+        PortableRemoteObject.exportObject(obj);
+    }
+
+    @Override
+    public void unexportObject(Remote obj) throws NoSuchObjectException {
+        PortableRemoteObject.unexportObject(obj);
+    }
+
+    @Override
+    public Remote toStub(Remote obj) throws NoSuchObjectException {
+        return PortableRemoteObject.toStub(obj);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/jmx/remote/protocol/iiop/ProxyInputStream.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,241 @@
+/*
+ * Copyright 2003-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.jmx.remote.protocol.iiop;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.NO_IMPLEMENT;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.TypeCode;
+import org.omg.CORBA.portable.BoxedValueHelper;
+
+@SuppressWarnings({"deprecation", "rawtypes"})
+public class ProxyInputStream extends org.omg.CORBA_2_3.portable.InputStream {
+    public ProxyInputStream(org.omg.CORBA.portable.InputStream in) {
+        this.in = in;
+    }
+
+    public boolean read_boolean() {
+        return in.read_boolean();
+    }
+
+    public char read_char() {
+        return in.read_char();
+    }
+
+    public char read_wchar() {
+        return in.read_wchar();
+    }
+
+    public byte read_octet() {
+        return in.read_octet();
+    }
+
+    public short read_short() {
+        return in.read_short();
+    }
+
+    public short read_ushort() {
+        return in.read_ushort();
+    }
+
+    public int read_long() {
+        return in.read_long();
+    }
+
+    public int read_ulong() {
+        return in.read_ulong();
+    }
+
+    public long read_longlong() {
+        return in.read_longlong();
+    }
+
+    public long read_ulonglong() {
+        return in.read_ulonglong();
+    }
+
+    public float read_float() {
+        return in.read_float();
+    }
+
+    public double read_double() {
+        return in.read_double();
+    }
+
+    public String read_string() {
+        return in.read_string();
+    }
+
+    public String read_wstring() {
+        return in.read_wstring();
+    }
+
+    public void read_boolean_array(boolean[] value, int offset, int length) {
+        in.read_boolean_array(value, offset, length);
+    }
+
+    public void read_char_array(char[] value, int offset, int length) {
+        in.read_char_array(value, offset, length);
+    }
+
+    public void read_wchar_array(char[] value, int offset, int length) {
+        in.read_wchar_array(value, offset, length);
+    }
+
+    public void read_octet_array(byte[] value, int offset, int length) {
+        in.read_octet_array(value, offset, length);
+    }
+
+    public void read_short_array(short[] value, int offset, int length) {
+        in.read_short_array(value, offset, length);
+    }
+
+    public void read_ushort_array(short[] value, int offset, int length) {
+        in.read_ushort_array(value, offset, length);
+    }
+
+    public void read_long_array(int[] value, int offset, int length) {
+        in.read_long_array(value, offset, length);
+    }
+
+    public void read_ulong_array(int[] value, int offset, int length) {
+        in.read_ulong_array(value, offset, length);
+    }
+
+    public void read_longlong_array(long[] value, int offset, int length) {
+        in.read_longlong_array(value, offset, length);
+    }
+
+    public void read_ulonglong_array(long[] value, int offset, int length) {
+        in.read_ulonglong_array(value, offset, length);
+    }
+
+    public void read_float_array(float[] value, int offset, int length) {
+        in.read_float_array(value, offset, length);
+    }
+
+    public void read_double_array(double[] value, int offset, int length) {
+        in.read_double_array(value, offset, length);
+    }
+
+    public org.omg.CORBA.Object read_Object() {
+        return in.read_Object();
+    }
+
+    public TypeCode read_TypeCode() {
+        return in.read_TypeCode();
+    }
+
+    public Any read_any() {
+        return in.read_any();
+    }
+
+    /**
+     * @deprecated
+     */
+    @Override
+    @Deprecated
+    public org.omg.CORBA.Principal read_Principal() {
+        return in.read_Principal();
+    }
+
+    @Override
+    public int read() throws IOException {
+        return in.read();
+    }
+
+    @Override
+    public BigDecimal read_fixed() {
+        return in.read_fixed();
+    }
+
+    @Override
+    public Context read_Context() {
+        return in.read_Context();
+    }
+
+    @Override
+    public org.omg.CORBA.Object read_Object(java.lang.Class clz) {
+        return in.read_Object(clz);
+    }
+
+    @Override
+    public ORB orb() {
+        return in.orb();
+    }
+
+    @Override
+    public Serializable read_value() {
+        return narrow().read_value();
+    }
+
+    @Override
+    public Serializable read_value(Class clz) {
+        return narrow().read_value(clz);
+    }
+
+    @Override
+    public Serializable read_value(BoxedValueHelper factory) {
+        return narrow().read_value(factory);
+    }
+
+    @Override
+    public Serializable read_value(String rep_id) {
+        return narrow().read_value(rep_id);
+    }
+
+    @Override
+    public Serializable read_value(Serializable value) {
+        return narrow().read_value(value);
+    }
+
+    @Override
+    public Object read_abstract_interface() {
+        return narrow().read_abstract_interface();
+    }
+
+    @Override
+    public Object read_abstract_interface(Class clz) {
+        return narrow().read_abstract_interface(clz);
+    }
+
+    protected org.omg.CORBA_2_3.portable.InputStream narrow() {
+        if (in instanceof org.omg.CORBA_2_3.portable.InputStream)
+            return (org.omg.CORBA_2_3.portable.InputStream) in;
+        throw new NO_IMPLEMENT();
+    }
+
+    public org.omg.CORBA.portable.InputStream getProxiedInputStream() {
+        return in;
+    }
+
+    protected final org.omg.CORBA.portable.InputStream in;
+}
--- a/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jmx/remote/util/EnvHelp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -781,25 +781,6 @@
     }
 
     /**
-     * Returns true if the parameter JMXConnector.USE_EVENT_SERVICE is set to a
-     * String equals "true" by ignoring case in the map or in the System.
-     */
-    public static boolean eventServiceEnabled(Map<String, ?> env) {
-        return computeBooleanFromString(env, JMXConnector.USE_EVENT_SERVICE, true);
-    }
-
-    /**
-     * Returns true if the parameter JMXConnectorServer.DELEGATE_TO_EVENT_SERVICE
-     * is set to a String equals "true" (ignores case).
-     * If the property DELEGATE_TO_EVENT_SERVICE is not set, returns
-     * a default value of "true".
-     */
-    public static boolean delegateToEventService(Map<String, ?> env) {
-        return computeBooleanFromString(env,
-                JMXConnectorServer.DELEGATE_TO_EVENT_SERVICE, true, true);
-    }
-
-    /**
      * <p>Name of the attribute that specifies whether a connector server
      * should not prevent the VM from exiting
      */
@@ -817,46 +798,6 @@
                 ("true".equalsIgnoreCase((String)env.get(JMX_SERVER_DAEMON)));
     }
 
-//    /**
-//     * <p>Name of the attribute that specifies an EventRelay object to use.
-//     */
-//    public static final String EVENT_RELAY =
-//            "jmx.remote.x.event.relay";
-//
-//
-//    /**
-//     * Returns an EventRelay object. The default one is FetchingEventRelay.
-//     * If {@code EVENT_RELAY} is specified in {@code env} as a key,
-//     * its value will be returned as an EventRelay object, if the value is
-//     * not of type {@code EventRelay}, the default {@code FetchingEventRelay}
-//     * will be returned.
-//     * If {@code EVENT_RELAY} is not specified but {@code ENABLE_EVENT_RELAY}
-//     * is specified as a key and its value is <code true>, the default {@code FetchingEventRelay}
-//     * will be returned.
-//     */
-//    public static EventRelay getEventRelay(Map env) {
-//        Map info = env == null ?
-//            Collections.EMPTY_MAP : env;
-//
-//        Object o = env.get(EVENT_RELAY);
-//        if (o instanceof EventRelay) {
-//            return (EventRelay)o;
-//        } else if (o != null) {
-//            logger.warning("getEventRelay",
-//                    "The user specified object is not an EventRelay object, " +
-//                    "using the default class FetchingEventRelay.");
-//
-//            return new FetchingEventRelay();
-//        }
-//
-//        if (enableEventRelay(env)) {
-//            return new FetchingEventRelay();
-//        }
-//
-//        return null;
-//    }
-
-
     private static final class SinkOutputStream extends OutputStream {
         public void write(byte[] b, int off, int len) {}
         public void write(int b) {}
--- a/src/share/classes/com/sun/jmx/remote/util/EventClientConnection.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,469 +0,0 @@
-/*
- * 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.
- */
-
-package com.sun.jmx.remote.util;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.event.EventClientFactory;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.MBeanServerConnection;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.namespace.JMXNamespaces;
-
-/**
- * Class EventClientConnection - a {@link Proxy} that wraps an
- * {@link MBeanServerConnection} and an {@link EventClient}.
- * All methods are routed to the underlying {@code MBeanServerConnection},
- * except add/remove notification listeners which are routed to the
- * {@code EventClient}.
- * The caller only sees an {@code MBeanServerConnection} which uses an
- * {@code EventClient} behind the scenes.
- *
- * @author Sun Microsystems, Inc.
- */
-public class EventClientConnection implements InvocationHandler,
-        EventClientFactory {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NOTIFICATION_LOGGER;
-
-    private static final int NAMESPACE_SEPARATOR_LENGTH =
-            JMXNamespaces.NAMESPACE_SEPARATOR.length();
-
-    /**
-     * Creates a new {@code EventClientConnection}.
-     * @param  connection The underlying MBeanServerConnection.
-     */
-    public EventClientConnection(MBeanServerConnection connection) {
-        this(connection,null);
-    }
-
-    /**
-     * Creates a new {@code EventClientConnection}.
-     * @param connection The underlying MBeanServerConnection.
-     * @param eventClientFactory a factory object that will be invoked
-     *        to create an {@link EventClient} when needed.
-     *        The {@code EventClient} is created lazily, when it is needed
-     *        for the first time. If null, a default factory will be used
-     *        (see {@link #createEventClient}).
-     */
-    public EventClientConnection(MBeanServerConnection connection,
-                                 Callable<EventClient> eventClientFactory) {
-
-        if (connection == null) {
-            throw new IllegalArgumentException("Null connection");
-        }
-        this.connection = connection;
-        if (eventClientFactory == null) {
-            eventClientFactory = new Callable<EventClient>() {
-                public final EventClient call() throws Exception {
-                    return createEventClient(EventClientConnection.this.connection);
-                }
-            };
-        }
-        this.eventClientFactory = eventClientFactory;
-        this.lock = new ReentrantLock();
-     }
-
-    /**
-     * <p>The MBean server connection through which the methods of
-     * a proxy using this handler are forwarded.</p>
-     *
-     * @return the MBean server connection.
-     *
-     * @since 1.6
-     */
-    public MBeanServerConnection getMBeanServerConnection() {
-        return connection;
-    }
-
-
-
-
-    /**
-     * Creates a new EventClientConnection proxy instance.
-     *
-     * @param <T> The underlying {@code MBeanServerConnection} - which should
-     *        not be using the Event Service itself.
-     * @param interfaceClass {@code MBeanServerConnection.class}, or a subclass.
-     * @param eventClientFactory a factory used to create the EventClient.
-     *        If null, a default factory is used (see {@link
-     *        #createEventClient}).
-     * @return the new proxy instance, which will route add/remove notification
-     *         listener calls through an {@code EventClient}.
-     *
-     */
-    private static <T extends MBeanServerConnection> T
-            newProxyInstance(T connection,
-            Class<T> interfaceClass, Callable<EventClient> eventClientFactory) {
-        final InvocationHandler handler =
-                new EventClientConnection(connection,eventClientFactory);
-        final Class<?>[] interfaces =
-                new Class<?>[] {interfaceClass, EventClientFactory.class};
-
-        Object proxy =
-                Proxy.newProxyInstance(interfaceClass.getClassLoader(),
-                interfaces,
-                handler);
-        return interfaceClass.cast(proxy);
-    }
-
-
-    public Object invoke(Object proxy, Method method, Object[] args)
-            throws Throwable {
-        final String methodName = method.getName();
-
-        // add/remove notification listener are routed to the EventClient
-        if (methodName.equals("addNotificationListener")
-            || methodName.equals("removeNotificationListener")) {
-            final Class<?>[] sig = method.getParameterTypes();
-            if (sig.length>1 &&
-                    NotificationListener.class.isAssignableFrom(sig[1])) {
-                return invokeBroadcasterMethod(proxy,method,args);
-            }
-        }
-
-        // subscribe/unsubscribe are also routed to the EventClient.
-        final Class<?> clazz = method.getDeclaringClass();
-        if (clazz.equals(EventClientFactory.class)) {
-            return invokeEventClientSubscriberMethod(proxy,method,args);
-        }
-
-        // local or not: equals, toString, hashCode
-        if (shouldDoLocally(proxy, method))
-            return doLocally(proxy, method, args);
-
-        return call(connection,method,args);
-    }
-
-    // The purpose of this method is to unwrap InvocationTargetException,
-    // in order to avoid throwing UndeclaredThrowableException for
-    // declared exceptions.
-    //
-    // When calling method.invoke(), any exception thrown by the invoked
-    // method will be wrapped in InvocationTargetException. If we don't
-    // unwrap this exception, the proxy will always throw
-    // UndeclaredThrowableException, even for runtime exceptions.
-    //
-    private Object call(final Object obj, final Method m,
-            final Object[] args)
-        throws Throwable {
-        try {
-            return m.invoke(obj,args);
-        } catch (InvocationTargetException x) {
-            final Throwable xx = x.getTargetException();
-            if (xx == null) throw x;
-            else throw xx;
-        }
-    }
-
-    /**
-     * Route add/remove notification listener to the event client.
-     **/
-    private Object invokeBroadcasterMethod(Object proxy, Method method,
-                                           Object[] args) throws Exception {
-        final String methodName = method.getName();
-        final int nargs = (args == null) ? 0 : args.length;
-
-        if (nargs < 1) {
-           final String msg =
-                    "Bad arg count: " + nargs;
-           throw new IllegalArgumentException(msg);
-        }
-
-        final ObjectName mbean = (ObjectName) args[0];
-        final EventClient evtClient = getEventClient();
-
-        // Fails if evtClient is null AND the MBean we try to listen to is
-        // in a subnamespace. We fail here because we know this will not
-        // work.
-        //
-        // Note that if the wrapped MBeanServerConnection points to a an
-        // earlier agent (JDK 1.6 or earlier), then the EventClient will
-        // be null (we can't use the event service with earlier JDKs).
-        //
-        // In principle a null evtClient indicates that the remote VM is of
-        // an earlier version, in which case it shouldn't contain any namespace.
-        //
-        // So having a null evtClient AND an MBean contained in a namespace is
-        // clearly an error case.
-        //
-        if (evtClient == null) {
-            final String domain = mbean.getDomain();
-            final int index = domain.indexOf(JMXNamespaces.NAMESPACE_SEPARATOR);
-            if (index > -1 && index <
-                    (domain.length()-NAMESPACE_SEPARATOR_LENGTH)) {
-                throw new UnsupportedOperationException(method.getName()+
-                        " on namespace "+domain.substring(0,index+
-                        NAMESPACE_SEPARATOR_LENGTH));
-            }
-        }
-
-        if (methodName.equals("addNotificationListener")) {
-            /* The various throws of IllegalArgumentException here
-               should not happen, since we know what the methods in
-               NotificationBroadcaster and NotificationEmitter
-               are.  */
-            if (nargs != 4) {
-                final String msg =
-                    "Bad arg count to addNotificationListener: " + nargs;
-                throw new IllegalArgumentException(msg);
-            }
-            /* Other inconsistencies will produce ClassCastException
-               below.  */
-
-            final NotificationListener listener = (NotificationListener) args[1];
-            final NotificationFilter filter = (NotificationFilter) args[2];
-            final Object handback = args[3];
-
-            if (evtClient != null) {
-                // general case
-                evtClient.addNotificationListener(mbean,listener,filter,handback);
-            } else {
-                // deprecated case. Only works for mbean in local namespace.
-                connection.addNotificationListener(mbean,listener,filter,
-                                                   handback);
-            }
-            return null;
-
-        } else if (methodName.equals("removeNotificationListener")) {
-
-            /* NullPointerException if method with no args, but that
-               shouldn't happen because removeNL does have args.  */
-            NotificationListener listener = (NotificationListener) args[1];
-
-            switch (nargs) {
-            case 2:
-                if (evtClient != null) {
-                    // general case
-                    evtClient.removeNotificationListener(mbean,listener);
-                } else {
-                    // deprecated case. Only works for mbean in local namespace.
-                    connection.removeNotificationListener(mbean, listener);
-                }
-                return null;
-
-            case 4:
-                NotificationFilter filter = (NotificationFilter) args[2];
-                Object handback = args[3];
-                if (evtClient != null) {
-                    evtClient.removeNotificationListener(mbean,
-                                                      listener,
-                                                      filter,
-                                                      handback);
-                } else {
-                    connection.removeNotificationListener(mbean,
-                                                      listener,
-                                                      filter,
-                                                      handback);
-                }
-                return null;
-
-            default:
-                final String msg =
-                    "Bad arg count to removeNotificationListener: " + nargs;
-                throw new IllegalArgumentException(msg);
-            }
-
-        } else {
-            throw new IllegalArgumentException("Bad method name: " +
-                                               methodName);
-        }
-    }
-
-    private boolean shouldDoLocally(Object proxy, Method method) {
-        final String methodName = method.getName();
-        if ((methodName.equals("hashCode") || methodName.equals("toString"))
-            && method.getParameterTypes().length == 0
-                && isLocal(proxy, method))
-            return true;
-        if (methodName.equals("equals")
-            && Arrays.equals(method.getParameterTypes(),
-                new Class<?>[] {Object.class})
-                && isLocal(proxy, method))
-            return true;
-        return false;
-    }
-
-    private Object doLocally(Object proxy, Method method, Object[] args) {
-        final String methodName = method.getName();
-
-        if (methodName.equals("equals")) {
-
-            if (this == args[0]) {
-                return true;
-            }
-
-            if (!(args[0] instanceof Proxy)) {
-                return false;
-            }
-
-            final InvocationHandler ihandler =
-                Proxy.getInvocationHandler(args[0]);
-
-            if (ihandler == null ||
-                !(ihandler instanceof EventClientConnection)) {
-                return false;
-            }
-
-            final EventClientConnection handler =
-                (EventClientConnection)ihandler;
-
-            return connection.equals(handler.connection) &&
-                proxy.getClass().equals(args[0].getClass());
-        } else if (methodName.equals("hashCode")) {
-            return connection.hashCode();
-        }
-
-        throw new RuntimeException("Unexpected method name: " + methodName);
-    }
-
-    private static boolean isLocal(Object proxy, Method method) {
-        final Class<?>[] interfaces = proxy.getClass().getInterfaces();
-        if(interfaces == null) {
-            return true;
-        }
-
-        final String methodName = method.getName();
-        final Class<?>[] params = method.getParameterTypes();
-        for (Class<?> intf : interfaces) {
-            try {
-                intf.getMethod(methodName, params);
-                return false; // found method in one of our interfaces
-            } catch (NoSuchMethodException nsme) {
-                // OK.
-            }
-        }
-
-        return true;  // did not find in any interface
-    }
-
-    /**
-     * Return the EventClient used by this object. Can be null if the
-     * remote VM is of an earlier JDK version which doesn't have the
-     * event service.<br>
-     * This method will invoke the event client factory the first time
-     * it is called.
-     **/
-    public final EventClient getEventClient()  {
-        if (initialized) return client;
-        try {
-            if (!lock.tryLock(TRYLOCK_TIMEOUT,TimeUnit.SECONDS))
-                throw new IllegalStateException("can't acquire lock");
-            try {
-                client = eventClientFactory.call();
-                initialized = true;
-            } finally {
-                lock.unlock();
-            }
-        } catch (RuntimeException x) {
-            throw x;
-        } catch (Exception x) {
-            throw new IllegalStateException("Can't create EventClient: "+x,x);
-        }
-        return client;
-    }
-
-    /**
-     * Returns an event client for the wrapped {@code MBeanServerConnection}.
-     * This is the method invoked by the default event client factory.
-     * @param connection the  wrapped {@code MBeanServerConnection}.
-     **/
-    protected EventClient createEventClient(MBeanServerConnection connection)
-        throws Exception {
-        final ObjectName name =
-           EventClientDelegate.OBJECT_NAME;
-        if (connection.isRegistered(name)) {
-            return new EventClient(connection);
-        }
-        return null;
-    }
-
-    /**
-     * Creates a new {@link MBeanServerConnection} that goes through an
-     * {@link EventClient} to receive/subscribe to notifications.
-     * @param connection the underlying {@link MBeanServerConnection}.
-     *        The given <code>connection</code> shouldn't be already
-     *        using an {@code EventClient}.
-     * @param eventClientFactory a factory object that will be invoked
-     *        to create an {@link EventClient} when needed.
-     *        The {@code EventClient} is created lazily, when it is needed
-     *        for the first time. If null, a default factory will be used
-     *        (see {@link #createEventClient}).
-     * @return the MBeanServerConnection.
-     **/
-    public static MBeanServerConnection getEventConnectionFor(
-                    MBeanServerConnection connection,
-                    Callable<EventClient> eventClientFactory) {
-        if (connection instanceof EventClientFactory
-            && eventClientFactory != null)
-            throw new IllegalArgumentException("connection already uses EventClient");
-
-        if (connection instanceof EventClientFactory)
-            return connection;
-
-        // create a new proxy using an event client.
-        //
-        if (LOG.isLoggable(Level.FINE))
-            LOG.fine("Creating EventClient for: "+connection);
-        return newProxyInstance(connection,
-                MBeanServerConnection.class,
-                eventClientFactory);
-    }
-
-    private Object invokeEventClientSubscriberMethod(Object proxy,
-            Method method, Object[] args) throws Throwable {
-        return call(this,method,args);
-    }
-
-    // Maximum lock timeout in seconds. Obviously arbitrary.
-    //
-    private final static short TRYLOCK_TIMEOUT = 3;
-
-    private final MBeanServerConnection connection;
-    private final Callable<EventClient> eventClientFactory;
-    private final Lock lock;
-    private volatile EventClient client = null;
-    private volatile boolean initialized = false;
-
-}
--- a/src/share/classes/com/sun/jndi/ldap/Connection.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jndi/ldap/Connection.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-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
@@ -32,12 +32,8 @@
 import java.io.OutputStream;
 import java.io.InputStream;
 import java.net.Socket;
-import java.util.Vector;
-import java.util.Hashtable;
 
 import javax.naming.CommunicationException;
-import javax.naming.AuthenticationException;
-import javax.naming.AuthenticationNotSupportedException;
 import javax.naming.ServiceUnavailableException;
 import javax.naming.NamingException;
 import javax.naming.InterruptedNamingException;
@@ -47,6 +43,8 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import sun.misc.IOUtils;
 //import javax.net.SocketFactory;
 
 /**
@@ -799,7 +797,6 @@
         byte inbuf[];   // Buffer for reading incoming bytes
         int inMsgId;    // Message id of incoming response
         int bytesread;  // Number of bytes in inbuf
-        int bytesleft;  // Number of bytes that need to read for completing resp
         int br;         // Temp; number of bytes read from stream
         int offset;     // Offset of where to store bytes in inbuf
         int seqlen;     // Length of ASN sequence
@@ -811,7 +808,7 @@
         try {
             while (true) {
                 try {
-                    inbuf = new byte[2048];
+                    inbuf = new byte[10];
 
                     offset = 0;
                     seqlen = 0;
@@ -871,19 +868,10 @@
                     }
 
                     // read in seqlen bytes
-                    bytesleft = seqlen;
-                    if ((offset + bytesleft) > inbuf.length) {
-                        byte nbuf[] = new byte[offset + bytesleft];
-                        System.arraycopy(inbuf, 0, nbuf, 0, offset);
-                        inbuf = nbuf;
-                    }
-                    while (bytesleft > 0) {
-                        bytesread = in.read(inbuf, offset, bytesleft);
-                        if (bytesread < 0)
-                            break; // EOF
-                        offset += bytesread;
-                        bytesleft -= bytesread;
-                    }
+                    byte[] left = IOUtils.readFully(in, seqlen, false);
+                    inbuf = Arrays.copyOf(inbuf, offset + left.length);
+                    System.arraycopy(left, 0, inbuf, offset, left.length);
+                    offset += left.length;
 /*
 if (dump > 0) {
 System.err.println("seqlen: " + seqlen);
--- a/src/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/jndi/ldap/ext/StartTlsResponseImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -40,7 +40,6 @@
 import java.security.Principal;
 import java.security.cert.X509Certificate;
 import java.security.cert.CertificateException;
-import javax.security.auth.kerberos.KerberosPrincipal;
 
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
@@ -413,14 +412,15 @@
         try {
             HostnameChecker checker = HostnameChecker.getInstance(
                                                 HostnameChecker.TYPE_LDAP);
-            Principal principal = getPeerPrincipal(session);
-            if (principal instanceof KerberosPrincipal) {
-                if (!checker.match(hostname, (KerberosPrincipal) principal)) {
+            // Use ciphersuite to determine whether Kerberos is active.
+            if (session.getCipherSuite().startsWith("TLS_KRB5")) {
+                Principal principal = getPeerPrincipal(session);
+                if (!checker.match(hostname, principal)) {
                     throw new SSLPeerUnverifiedException(
                         "hostname of the kerberos principal:" + principal +
                         " does not match the hostname:" + hostname);
                 }
-            } else {
+            } else { // X.509
 
                 // get the subject's certificate
                 certs = session.getPeerCertificates();
--- a/src/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/com/sun/net/ssl/internal/www/protocol/https/DelegateHttpsURLConnection.java	Wed Nov 25 11:08:25 2009 -0800
@@ -36,7 +36,6 @@
 import java.security.cert.*;
 
 import javax.security.auth.x500.X500Principal;
-import javax.security.auth.kerberos.KerberosPrincipal;
 
 import sun.security.util.HostnameChecker;
 import sun.security.util.DerValue;
@@ -109,20 +108,18 @@
     /*
      * In com.sun.net.ssl.HostnameVerifier the method is defined
      * as verify(String urlHostname, String certHostname).
-     * This means we need to extract the hostname from the certificate
-     * in this wrapper
+     * This means we need to extract the hostname from the X.509 certificate
+     * or from the Kerberos principal name, in this wrapper.
      */
     public boolean verify(String hostname, javax.net.ssl.SSLSession session) {
         try {
             String serverName;
-            Principal principal = getPeerPrincipal(session);
-            // X.500 principal or Kerberos principal.
-            // (Use ciphersuite check to determine whether Kerberos is present.)
-            if (session.getCipherSuite().startsWith("TLS_KRB5") &&
-                    principal instanceof KerberosPrincipal) {
+            // Use ciphersuite to determine whether Kerberos is active.
+            if (session.getCipherSuite().startsWith("TLS_KRB5")) {
                 serverName =
-                    HostnameChecker.getServerName((KerberosPrincipal)principal);
-            } else {
+                    HostnameChecker.getServerName(getPeerPrincipal(session));
+
+            } else { // X.509
                 Certificate[] serverChain = session.getPeerCertificates();
                 if ((serverChain == null) || (serverChain.length == 0)) {
                     return false;
--- a/src/share/classes/java/applet/Applet.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/applet/Applet.java	Wed Nov 25 11:08:25 2009 -0800
@@ -230,6 +230,21 @@
     }
 
     /**
+     * Indicates if this container is a validate root.
+     * <p>
+     * {@code Applet} objects are the validate roots, and, therefore, they
+     * override this method to return {@code true}.
+     *
+     * @return {@code true}
+     * @since 1.7
+     * @see java.awt.Container#isValidateRoot
+     */
+    @Override
+    public boolean isValidateRoot() {
+        return true;
+    }
+
+    /**
      * Requests that the argument string be displayed in the
      * "status window". Many browsers and applet viewers
      * provide such a window, where the application can inform users of
--- a/src/share/classes/java/awt/AWTPermission.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/AWTPermission.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -92,7 +92,15 @@
  *   <td>Enter full-screen exclusive mode</td>
  *   <td>Entering full-screen exclusive mode allows direct access to
  * low-level graphics card memory.  This could be used to spoof the
- * system, since the program is in direct control of rendering.</td>
+ * system, since the program is in direct control of rendering. Depending on
+ * the implementation, the security warning may not be shown for the windows
+ * used to enter the full-screen exclusive mode (assuming that the {@code
+ * fullScreenExclusive} permission has been granted to this application). Note
+ * that this behavior does not mean that the {@code
+ * showWindowWithoutWarningBanner} permission will be automatically granted to
+ * the application which has the {@code fullScreenExclusive} permission:
+ * non-full-screen windows will continue to be shown with the security
+ * warning.</td>
  * </tr>
  *
  * <tr>
--- a/src/share/classes/java/awt/Component.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/Component.java	Wed Nov 25 11:08:25 2009 -0800
@@ -2764,8 +2764,11 @@
     }
 
     /**
-     * Ensures that this component has a valid layout.  This method is
-     * primarily intended to operate on instances of <code>Container</code>.
+     * Validates this component.
+     * <p>
+     * The meaning of the term <i>validating</i> is defined by the ancestors of
+     * this class. See {@link Container#validate} for more details.
+     *
      * @see       #invalidate
      * @see       #doLayout()
      * @see       LayoutManager
@@ -2794,12 +2797,24 @@
     }
 
     /**
-     * Invalidates this component.  This component and all parents
-     * above it are marked as needing to be laid out.  This method can
-     * be called often, so it needs to execute quickly.
+     * Invalidates this component and its ancestors.
+     * <p>
+     * All the ancestors of this component up to the nearest validate root are
+     * marked invalid also. If there is no a validate root container for this
+     * component, all of its ancestors up to the root of the hierarchy are
+     * marked invalid as well. Marking a container <i>invalid</i> indicates
+     * that the container needs to be laid out.
+     * <p>
+     * This method is called automatically when any layout-related information
+     * changes (e.g. setting the bounds of the component, or adding the
+     * component to a container).
+     * <p>
+     * This method might be called often, so it should work fast.
+     *
      * @see       #validate
      * @see       #doLayout
      * @see       LayoutManager
+     * @see       java.awt.Container#isValidateRoot
      * @since     JDK1.0
      */
     public void invalidate() {
@@ -2818,9 +2833,18 @@
             if (!isMaximumSizeSet()) {
                 maxSize = null;
             }
-            if (parent != null) {
-                parent.invalidateIfValid();
-            }
+            invalidateParent();
+        }
+    }
+
+    /**
+     * Invalidates the parent of this component if any.
+     *
+     * This method MUST BE invoked under the TreeLock.
+     */
+    void invalidateParent() {
+        if (parent != null) {
+            parent.invalidateIfValid();
         }
     }
 
@@ -6727,12 +6751,13 @@
                     }
                 }
             } else {
-                // It's native.  If the parent is lightweight it
-                // will need some help.
-                Container parent = this.parent;
-                if (parent != null && parent.peer instanceof LightweightPeer) {
+                // It's native. If the parent is lightweight it will need some
+                // help.
+                Container parent = getContainer();
+                if (parent != null && parent.isLightweight()) {
                     relocateComponent();
-                    if (!isRecursivelyVisible()) {
+                    if (!parent.isRecursivelyVisibleUpToHeavyweightContainer())
+                    {
                         peer.setVisible(false);
                     }
                 }
--- a/src/share/classes/java/awt/Container.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/Container.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1492,20 +1492,59 @@
     }
 
     /**
-     * Invalidates the container.  The container and all parents
-     * above it are marked as needing to be laid out.  This method can
-     * be called often, so it needs to execute quickly.
+     * Indicates if this container is a <i>validate root</i>.
+     * <p>
+     * Layout-related changes, such as bounds of the validate root descendants,
+     * do not affect the layout of the validate root parent. This peculiarity
+     * enables the {@code invalidate()} method to stop invalidating the
+     * component hierarchy when the method encounters a validate root.
+     * <p>
+     * If a component hierarchy contains validate roots, the {@code validate()}
+     * method must be invoked on the validate root of a previously invalidated
+     * component, rather than on the top-level container (such as a {@code
+     * Frame} object) to restore the validity of the hierarchy later.
+     * <p>
+     * The {@code Window} class and the {@code Applet} class are the validate
+     * roots in AWT.  Swing introduces more validate roots.
      *
-     * <p> If the {@code LayoutManager} installed on this container is
-     * an instance of {@code LayoutManager2}, then
-     * {@link LayoutManager2#invalidateLayout(Container)} is invoked on
-     * it supplying this {@code Container} as the argument.
+     * @return whether this container is a validate root
+     * @see #invalidate
+     * @see java.awt.Component#invalidate
+     * @see javax.swing.JComponent#isValidateRoot
+     * @see javax.swing.JComponent#revalidate
+     * @since 1.7
+     */
+    public boolean isValidateRoot() {
+        return false;
+    }
+
+    /**
+     * Invalidates the parent of the container unless the container
+     * is a validate root.
+     */
+    @Override
+    void invalidateParent() {
+        if (!isValidateRoot()) {
+            super.invalidateParent();
+        }
+    }
+
+    /**
+     * Invalidates the container.
+     * <p>
+     * If the {@code LayoutManager} installed on this container is an instance
+     * of the {@code LayoutManager2} interface, then
+     * the {@link LayoutManager2#invalidateLayout(Container)} method is invoked
+     * on it supplying this {@code Container} as the argument.
+     * <p>
+     * Afterwards this method marks this container invalid, and invalidates its
+     * ancestors. See the {@link Component#invalidate} method for more details.
      *
      * @see #validate
      * @see #layout
-     * @see LayoutManager
-     * @see LayoutManager2#invalidateLayout(Container)
+     * @see LayoutManager2
      */
+    @Override
     public void invalidate() {
         LayoutManager layoutMgr = this.layoutMgr;
         if (layoutMgr instanceof LayoutManager2) {
@@ -1518,52 +1557,90 @@
     /**
      * Validates this container and all of its subcomponents.
      * <p>
-     * The <code>validate</code> method is used to cause a container
-     * to lay out its subcomponents again. It should be invoked when
-     * this container's subcomponents are modified (added to or
-     * removed from the container, or layout-related information
-     * changed) after the container has been displayed.
-     *
-     * <p>If this {@code Container} is not valid, this method invokes
+     * Validating a container means laying out its subcomponents.
+     * Layout-related changes, such as setting the bounds of a component, or
+     * adding a component to the container, invalidate the container
+     * automatically.  Note that the ancestors of the container may be
+     * invalidated also (see {@link Component#invalidate} for details.)
+     * Therefore, to restore the validity of the hierarchy, the {@code
+     * validate()} method should be invoked on a validate root of an
+     * invalidated component, or on the top-most container if the hierarchy
+     * does not contain validate roots.
+     * <p>
+     * Validating the container may be a quite time-consuming operation. For
+     * performance reasons a developer may postpone the validation of the
+     * hierarchy till a set of layout-related operations completes, e.g. after
+     * adding all the children to the container.
+     * <p>
+     * If this {@code Container} is not valid, this method invokes
      * the {@code validateTree} method and marks this {@code Container}
      * as valid. Otherwise, no action is performed.
-     * <p>
-     * Note that the {@code invalidate()} method may invalidate not only the
-     * component it is called upon, but also the parents of the component.
-     * Therefore, to restore the validity of the hierarchy, the {@code
-     * validate()} method must be invoked on the top-most invalid container of
-     * the hierarchy. For performance reasons a developer may postpone the
-     * validation of the hierarchy till a bunch of layout-related operations
-     * completes, e.g. after adding all the children to the container.
      *
      * @see #add(java.awt.Component)
      * @see #invalidate
+     * @see Container#isValidateRoot
      * @see javax.swing.JComponent#revalidate()
      * @see #validateTree
      */
     public void validate() {
-        /* Avoid grabbing lock unless really necessary. */
-        if (!isValid()) {
-            boolean updateCur = false;
-            synchronized (getTreeLock()) {
-                if (!isValid() && peer != null) {
-                    ContainerPeer p = null;
-                    if (peer instanceof ContainerPeer) {
-                        p = (ContainerPeer) peer;
-                    }
-                    if (p != null) {
-                        p.beginValidate();
-                    }
-                    validateTree();
-                    if (p != null) {
-                        p.endValidate();
+        boolean updateCur = false;
+        synchronized (getTreeLock()) {
+            if ((!isValid() || descendUnconditionallyWhenValidating)
+                    && peer != null)
+            {
+                ContainerPeer p = null;
+                if (peer instanceof ContainerPeer) {
+                    p = (ContainerPeer) peer;
+                }
+                if (p != null) {
+                    p.beginValidate();
+                }
+                validateTree();
+                if (p != null) {
+                    p.endValidate();
+                    // Avoid updating cursor if this is an internal call.
+                    // See validateUnconditionally() for details.
+                    if (!descendUnconditionallyWhenValidating) {
                         updateCur = isVisible();
                     }
                 }
             }
-            if (updateCur) {
-                updateCursorImmediately();
+        }
+        if (updateCur) {
+            updateCursorImmediately();
+        }
+    }
+
+    /**
+     * Indicates whether valid containers should also traverse their
+     * children and call the validateTree() method on them.
+     *
+     * Synchronization: TreeLock.
+     *
+     * The field is allowed to be static as long as the TreeLock itself is
+     * static.
+     *
+     * @see #validateUnconditionally()
+     */
+    private static boolean descendUnconditionallyWhenValidating = false;
+
+    /**
+     * Unconditionally validate the component hierarchy.
+     */
+    final void validateUnconditionally() {
+        boolean updateCur = false;
+        synchronized (getTreeLock()) {
+            descendUnconditionallyWhenValidating = true;
+
+            validate();
+            if (peer instanceof ContainerPeer) {
+                updateCur = isVisible();
             }
+
+            descendUnconditionallyWhenValidating = false;
+        }
+        if (updateCur) {
+            updateCursorImmediately();
         }
     }
 
@@ -1578,16 +1655,20 @@
      */
     protected void validateTree() {
         checkTreeLock();
-        if (!isValid()) {
+        if (!isValid() || descendUnconditionallyWhenValidating) {
             if (peer instanceof ContainerPeer) {
                 ((ContainerPeer)peer).beginLayout();
             }
-            doLayout();
+            if (!isValid()) {
+                doLayout();
+            }
             for (int i = 0; i < component.size(); i++) {
                 Component comp = component.get(i);
                 if (   (comp instanceof Container)
                        && !(comp instanceof Window)
-                       && !comp.isValid()) {
+                       && (!comp.isValid() ||
+                           descendUnconditionallyWhenValidating))
+                {
                     ((Container)comp).validateTree();
                 } else {
                     comp.validate();
@@ -4092,16 +4173,29 @@
         }
     }
 
-    /*
+    /**
+     * Checks if the container and its direct lightweight containers are
+     * visible.
+     *
      * Consider the heavyweight container hides or shows the HW descendants
      * automatically. Therefore we care of LW containers' visibility only.
+     *
+     * This method MUST be invoked under the TreeLock.
      */
-    private boolean isRecursivelyVisibleUpToHeavyweightContainer() {
+    final boolean isRecursivelyVisibleUpToHeavyweightContainer() {
         if (!isLightweight()) {
             return true;
         }
-        return isVisible() && (getContainer() == null ||
-             getContainer().isRecursivelyVisibleUpToHeavyweightContainer());
+
+        for (Container cont = getContainer();
+                cont != null && cont.isLightweight();
+                cont = cont.getContainer())
+        {
+            if (!cont.isVisible()) {
+                return false;
+            }
+        }
+        return true;
     }
 
     @Override
--- a/src/share/classes/java/awt/EventQueue.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/EventQueue.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1027,7 +1027,9 @@
 
         synchronized (lock) {
             Toolkit.getEventQueue().postEvent(event);
-            lock.wait();
+            while (!event.isDispatched()) {
+                lock.wait();
+            }
         }
 
         Throwable eventThrowable = event.getThrowable();
--- a/src/share/classes/java/awt/Frame.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/Frame.java	Wed Nov 25 11:08:25 2009 -0800
@@ -845,8 +845,11 @@
      * others by setting those fields you want to accept from system
      * to <code>Integer.MAX_VALUE</code>.
      * <p>
-     * On some systems only the size portion of the bounds is taken
-     * into account.
+     * Note, the given maximized bounds are used as a hint for the native
+     * system, because the underlying platform may not support setting the
+     * location and/or size of the maximized windows.  If that is the case, the
+     * provided values do not affect the appearance of the frame in the
+     * maximized state.
      *
      * @param bounds  bounds for the maximized state
      * @see #getMaximizedBounds()
--- a/src/share/classes/java/awt/KeyboardFocusManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/KeyboardFocusManager.java	Wed Nov 25 11:08:25 2009 -0800
@@ -53,7 +53,8 @@
 import java.util.StringTokenizer;
 import java.util.WeakHashMap;
 
-import sun.util.logging.PlatformLogger;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import sun.awt.AppContext;
 import sun.awt.HeadlessToolkit;
@@ -110,7 +111,7 @@
 {
 
     // Shared focus engine logger
-    private static final PlatformLogger focusLog = PlatformLogger.getLogger("java.awt.focus.KeyboardFocusManager");
+    private static final Logger focusLog = Logger.getLogger("java.awt.focus.KeyboardFocusManager");
 
     static {
         /* ensure that the necessary native libraries are loaded */
@@ -153,7 +154,7 @@
      */
     private static native void initIDs();
 
-    private static final PlatformLogger log = PlatformLogger.getLogger("java.awt.KeyboardFocusManager");
+    private static final Logger log = Logger.getLogger("java.awt.KeyboardFocusManager");
 
     /**
      * The identifier for the Forward focus traversal keys.
@@ -503,8 +504,8 @@
             if (this == getCurrentKeyboardFocusManager()) {
                 return focusOwner;
             } else {
-                if (focusLog.isLoggable(PlatformLogger.FINER)) {
-                    focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+                if (focusLog.isLoggable(Level.FINER)) {
+                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
                 }
                 throw new SecurityException(notPrivileged);
             }
@@ -608,9 +609,9 @@
     }
 
     void setNativeFocusOwner(Component comp) {
-        if (focusLog.isLoggable(PlatformLogger.FINEST)) {
-            focusLog.finest("Calling peer {0} setCurrentFocusOwner for {1}",
-                            peer, comp);
+        if (focusLog.isLoggable(Level.FINEST)) {
+            focusLog.log(Level.FINEST, "Calling peer {0} setCurrentFocusOwner for {1}",
+                         new Object[] {String.valueOf(peer), String.valueOf(comp)});
         }
         peer.setCurrentFocusOwner(comp);
     }
@@ -672,8 +673,8 @@
             if (this == getCurrentKeyboardFocusManager()) {
                 return permanentFocusOwner;
             } else {
-                if (focusLog.isLoggable(PlatformLogger.FINER)) {
-                    focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+                if (focusLog.isLoggable(Level.FINER)) {
+                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
                 }
                 throw new SecurityException(notPrivileged);
             }
@@ -780,8 +781,8 @@
             if (this == getCurrentKeyboardFocusManager()) {
                return focusedWindow;
             } else {
-                if (focusLog.isLoggable(PlatformLogger.FINER)) {
-                    focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+                if (focusLog.isLoggable(Level.FINER)) {
+                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
                 }
                 throw new SecurityException(notPrivileged);
             }
@@ -884,8 +885,8 @@
             if (this == getCurrentKeyboardFocusManager()) {
                return activeWindow;
             } else {
-                if (focusLog.isLoggable(PlatformLogger.FINER)) {
-                    focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+                if (focusLog.isLoggable(Level.FINER)) {
+                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
                 }
                 throw new SecurityException(notPrivileged);
             }
@@ -918,8 +919,8 @@
         Window oldActiveWindow;
         synchronized (KeyboardFocusManager.class) {
             oldActiveWindow = getActiveWindow();
-            if (focusLog.isLoggable(PlatformLogger.FINER)) {
-                focusLog.finer("Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
+            if (focusLog.isLoggable(Level.FINER)) {
+                focusLog.log(Level.FINER, "Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
             }
 
             try {
@@ -1214,8 +1215,8 @@
             if (this == getCurrentKeyboardFocusManager()) {
                 return currentFocusCycleRoot;
             } else {
-                if (focusLog.isLoggable(PlatformLogger.FINER)) {
-                    focusLog.finer("This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
+                if (focusLog.isLoggable(Level.FINER)) {
+                    focusLog.log(Level.FINER, "This manager is " + this + ", current is " + getCurrentKeyboardFocusManager());
                 }
                 throw new SecurityException(notPrivileged);
             }
@@ -2148,9 +2149,9 @@
 
         HeavyweightFocusRequest(Component heavyweight, Component descendant,
                                 boolean temporary, CausedFocusEvent.Cause cause) {
-            if (log.isLoggable(PlatformLogger.FINE)) {
+            if (log.isLoggable(Level.FINE)) {
                 if (heavyweight == null) {
-                    log.fine("Assertion (heavyweight != null) failed");
+                    log.log(Level.FINE, "Assertion (heavyweight != null) failed");
                 }
             }
 
@@ -2160,12 +2161,12 @@
         }
         boolean addLightweightRequest(Component descendant,
                                       boolean temporary, CausedFocusEvent.Cause cause) {
-            if (log.isLoggable(PlatformLogger.FINE)) {
+            if (log.isLoggable(Level.FINE)) {
                 if (this == HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) {
-                    log.fine("Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
+                    log.log(Level.FINE, "Assertion (this != HeavyweightFocusRequest.CLEAR_GLOBAL_FOCUS_OWNER) failed");
                 }
                 if (descendant == null) {
-                    log.fine("Assertion (descendant != null) failed");
+                    log.log(Level.FINE, "Assertion (descendant != null) failed");
                 }
             }
 
@@ -2338,12 +2339,12 @@
         (Component heavyweight, Component descendant, boolean temporary,
          boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause)
     {
-        if (log.isLoggable(PlatformLogger.FINE)) {
+        if (log.isLoggable(Level.FINE)) {
             if (heavyweight == null) {
-                log.fine("Assertion (heavyweight != null) failed");
+                log.log(Level.FINE, "Assertion (heavyweight != null) failed");
             }
             if (time == 0) {
-                log.fine("Assertion (time != 0) failed");
+                log.log(Level.FINE, "Assertion (time != 0) failed");
             }
         }
 
@@ -2360,31 +2361,31 @@
         Component currentFocusOwner = thisManager.getGlobalFocusOwner();
         Component nativeFocusOwner = thisManager.getNativeFocusOwner();
         Window nativeFocusedWindow = thisManager.getNativeFocusedWindow();
-        if (focusLog.isLoggable(PlatformLogger.FINER)) {
-            focusLog.finer("SNFH for {0} in {1}",
-                           descendant, heavyweight);
+        if (focusLog.isLoggable(Level.FINER)) {
+            focusLog.log(Level.FINER, "SNFH for {0} in {1}",
+                         new Object[] {String.valueOf(descendant), String.valueOf(heavyweight)});
         }
-        if (focusLog.isLoggable(PlatformLogger.FINEST)) {
-            focusLog.finest("0. Current focus owner {0}",
-                            currentFocusOwner);
-            focusLog.finest("0. Native focus owner {0}",
-                            nativeFocusOwner);
-            focusLog.finest("0. Native focused window {0}",
-                            nativeFocusedWindow);
+        if (focusLog.isLoggable(Level.FINEST)) {
+            focusLog.log(Level.FINEST, "0. Current focus owner {0}",
+                         String.valueOf(currentFocusOwner));
+            focusLog.log(Level.FINEST, "0. Native focus owner {0}",
+                         String.valueOf(nativeFocusOwner));
+            focusLog.log(Level.FINEST, "0. Native focused window {0}",
+                         String.valueOf(nativeFocusedWindow));
         }
         synchronized (heavyweightRequests) {
             HeavyweightFocusRequest hwFocusRequest = getLastHWRequest();
-            if (focusLog.isLoggable(PlatformLogger.FINEST)) {
-                focusLog.finest("Request {0}", hwFocusRequest);
+            if (focusLog.isLoggable(Level.FINEST)) {
+                focusLog.log(Level.FINEST, "Request {0}", String.valueOf(hwFocusRequest));
             }
             if (hwFocusRequest == null &&
                 heavyweight == nativeFocusOwner)
             {
                 if (descendant == currentFocusOwner) {
                     // Redundant request.
-                    if (focusLog.isLoggable(PlatformLogger.FINEST))
-                        focusLog.finest("1. SNFH_FAILURE for {0}",
-                                        descendant);
+                    if (focusLog.isLoggable(Level.FINEST))
+                        focusLog.log(Level.FINEST, "1. SNFH_FAILURE for {0}",
+                                     String.valueOf(descendant));
                     return SNFH_FAILURE;
                 }
 
@@ -2416,8 +2417,8 @@
                 // SunToolkit.postPriorityEvent(newFocusOwnerEvent);
                 SunToolkit.postEvent(descendant.appContext, newFocusOwnerEvent);
 
-                if (focusLog.isLoggable(PlatformLogger.FINEST))
-                    focusLog.finest("2. SNFH_HANDLED for {0}", descendant);
+                if (focusLog.isLoggable(Level.FINEST))
+                    focusLog.log(Level.FINEST, "2. SNFH_HANDLED for {0}", String.valueOf(descendant));
                 return SNFH_SUCCESS_HANDLED;
             } else if (hwFocusRequest != null &&
                        hwFocusRequest.heavyweight == heavyweight) {
@@ -2430,7 +2431,7 @@
                     manager.enqueueKeyEvents(time, descendant);
                 }
 
-                if (focusLog.isLoggable(PlatformLogger.FINEST))
+                if (focusLog.isLoggable(Level.FINEST))
                     focusLog.finest("3. SNFH_HANDLED for lightweight" +
                                     descendant + " in " + heavyweight);
                 return SNFH_SUCCESS_HANDLED;
@@ -2453,7 +2454,7 @@
                                              (hwFocusRequest != null)
                                              ? hwFocusRequest.heavyweight
                                              : nativeFocusedWindow)) {
-                        if (focusLog.isLoggable(PlatformLogger.FINEST))
+                        if (focusLog.isLoggable(Level.FINEST))
                             focusLog.finest("4. SNFH_FAILURE for " + descendant);
                         return SNFH_FAILURE;
                     }
@@ -2463,7 +2464,7 @@
                 heavyweightRequests.add
                     (new HeavyweightFocusRequest(heavyweight, descendant,
                                                  temporary, cause));
-                if (focusLog.isLoggable(PlatformLogger.FINEST))
+                if (focusLog.isLoggable(Level.FINEST))
                     focusLog.finest("5. SNFH_PROCEED for " + descendant);
                 return SNFH_SUCCESS_PROCEED;
             }
@@ -2854,13 +2855,14 @@
         }
 
         KeyboardFocusManager manager = getCurrentKeyboardFocusManager();
-        if (focusLog.isLoggable(PlatformLogger.FINER)) {
+        if (focusLog.isLoggable(Level.FINER)) {
             if (event instanceof FocusEvent || event instanceof WindowEvent) {
-                focusLog.finer(">>> {0}", event);
+                focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)});
             }
-            if (focusLog.isLoggable(PlatformLogger.FINER) && event instanceof KeyEvent) {
-                focusLog.finer("    focus owner is {0}", manager.getGlobalFocusOwner());
-                focusLog.finer(">>> {0}", event);
+            if (focusLog.isLoggable(Level.FINER) && event instanceof KeyEvent) {
+                focusLog.log(Level.FINER, "    focus owner is {0}",
+                                          new Object[] {String.valueOf(manager.getGlobalFocusOwner())});
+                focusLog.log(Level.FINER, ">>> {0}", new Object[] {String.valueOf(event)});
             }
         }
 
@@ -2944,9 +2946,9 @@
         }
     }
     static void removeLastFocusRequest(Component heavyweight) {
-        if (log.isLoggable(PlatformLogger.FINE)) {
+        if (log.isLoggable(Level.FINE)) {
             if (heavyweight == null) {
-                log.fine("Assertion (heavyweight != null) failed");
+                log.log(Level.FINE, "Assertion (heavyweight != null) failed");
             }
         }
 
--- a/src/share/classes/java/awt/Window.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/Window.java	Wed Nov 25 11:08:25 2009 -0800
@@ -767,7 +767,7 @@
             isPacked = true;
         }
 
-        validate();
+        validateUnconditionally();
     }
 
     /**
@@ -943,7 +943,7 @@
         if (peer == null) {
             addNotify();
         }
-        validate();
+        validateUnconditionally();
 
         isInShow = true;
         if (visible) {
@@ -2600,6 +2600,21 @@
     }
 
     /**
+     * Indicates if this container is a validate root.
+     * <p>
+     * {@code Window} objects are the validate roots, and, therefore, they
+     * override this method to return {@code true}.
+     *
+     * @return {@code true}
+     * @since 1.7
+     * @see java.awt.Container#isValidateRoot
+     */
+    @Override
+    public boolean isValidateRoot() {
+        return true;
+    }
+
+    /**
      * Dispatches an event to this window or one of its sub components.
      * @param e the event
      */
--- a/src/share/classes/java/awt/color/ICC_Profile.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/color/ICC_Profile.java	Wed Nov 25 11:08:25 2009 -0800
@@ -865,7 +865,9 @@
         case ColorSpace.CS_PYCC:
             synchronized(ICC_Profile.class) {
                 if (PYCCprofile == null) {
-                    if (getProfileFile("PYCC.pf") != null) {
+                    if (BootClassLoaderHook.getHook() != null ||
+                        standardProfileExists("PYCC.pf"))
+                    {
                         ProfileDeferralInfo pInfo =
                             new ProfileDeferralInfo("PYCC.pf",
                                                     ColorSpace.TYPE_3CLR, 3,
@@ -963,15 +965,15 @@
      * and it does not permit read access to the given file.
      */
     public static ICC_Profile getInstance(String fileName) throws IOException {
-    ICC_Profile thisProfile;
-    FileInputStream fis;
+        ICC_Profile thisProfile;
+        FileInputStream fis = null;
+
 
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkRead(fileName);
+        File f = getProfileFile(fileName);
+        if (f != null) {
+            fis = new FileInputStream(f);
         }
-
-        if ((fis = openProfile(fileName)) == null) {
+        if (fis == null) {
             throw new IOException("Cannot open file " + fileName);
         }
 
@@ -1083,11 +1085,22 @@
     void activateDeferredProfile() throws ProfileDataException {
         byte profileData[];
         FileInputStream fis;
-        String fileName = deferralInfo.filename;
+        final String fileName = deferralInfo.filename;
 
         profileActivator = null;
         deferralInfo = null;
-        if ((fis = openProfile(fileName)) == null) {
+        PrivilegedAction<FileInputStream> pa = new PrivilegedAction<FileInputStream>() {
+            public FileInputStream run() {
+                File f = getStandardProfileFile(fileName);
+                if (f != null) {
+                    try {
+                        return new FileInputStream(f);
+                    } catch (FileNotFoundException e) {}
+                }
+                return null;
+            }
+        };
+        if ((fis = AccessController.doPrivileged(pa)) == null) {
             throw new ProfileDataException("Cannot open file " + fileName);
         }
         try {
@@ -1786,85 +1799,104 @@
      * available, such as a profile for sRGB.  Built-in profiles use .pf as
      * the file name extension for profiles, e.g. sRGB.pf.
      */
-    private static FileInputStream openProfile(final String fileName) {
-        return (FileInputStream)java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-            public Object run() {
-                File f = privilegedGetProfileFile(fileName);
-                if (f != null) {
-                    try {
-                        return new FileInputStream(f);
-                    } catch (FileNotFoundException e) {
-                    }
-                }
-                return null;
-            }
-        });
-    }
-
-    private static File getProfileFile(final String fileName) {
-        return (File)java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction() {
-            public Object run() {
-                return privilegedGetProfileFile(fileName);
-            }
-        });
-    }
-
-    /*
-     * this version is called from doPrivileged in openProfile
-     * or getProfileFile, so the whole method is privileged!
-     */
-
-    private static File privilegedGetProfileFile(String fileName) {
+    private static File getProfileFile(String fileName) {
         String path, dir, fullPath;
 
         File f = new File(fileName); /* try absolute file name */
-
+        if (f.isAbsolute()) {
+            /* Rest of code has little sense for an absolute pathname,
+               so return here. */
+            return f.isFile() ? f : null;
+        }
         if ((!f.isFile()) &&
                 ((path = System.getProperty("java.iccprofile.path")) != null)){
                                     /* try relative to java.iccprofile.path */
                 StringTokenizer st =
                     new StringTokenizer(path, File.pathSeparator);
-                while (st.hasMoreTokens() && (!f.isFile())) {
+                while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) {
+                    dir = st.nextToken();
+                        fullPath = dir + File.separatorChar + fileName;
+                    f = new File(fullPath);
+                    if (!isChildOf(f, dir)) {
+                        f = null;
+                    }
+                }
+            }
+
+        if (((f == null) || (!f.isFile())) &&
+                ((path = System.getProperty("java.class.path")) != null)) {
+                                    /* try relative to java.class.path */
+                StringTokenizer st =
+                    new StringTokenizer(path, File.pathSeparator);
+                while (st.hasMoreTokens() && ((f == null) || (!f.isFile()))) {
                     dir = st.nextToken();
                         fullPath = dir + File.separatorChar + fileName;
                     f = new File(fullPath);
                 }
             }
 
-        if ((!f.isFile()) &&
-                ((path = System.getProperty("java.class.path")) != null)) {
-                                    /* try relative to java.class.path */
-                StringTokenizer st =
-                    new StringTokenizer(path, File.pathSeparator);
-                while (st.hasMoreTokens() && (!f.isFile())) {
-                    dir = st.nextToken();
-                        fullPath = dir + File.separatorChar + fileName;
-                    f = new File(fullPath);
-                }
-            }
-
-        if (!f.isFile()) { /* try the directory of built-in profiles */
-            dir = System.getProperty("java.home") +
-                File.separatorChar + "lib" + File.separatorChar + "cmm";
-            fullPath = dir + File.separatorChar + fileName;
-                f = new File(fullPath);
-                if (!f.isFile()) {
-                    //make sure file was installed in the kernel mode
-                    BootClassLoaderHook hook = BootClassLoaderHook.getHook();
-                    if (hook.getHook() != null) {
-                        hook.prefetchFile("lib/cmm/"+fileName);
-                    }
-                }
-            }
-
-        if (f.isFile()) {
+        if ((f == null) || (!f.isFile())) {
+            /* try the directory of built-in profiles */
+            f = getStandardProfileFile(fileName);
+        }
+        if (f != null && f.isFile()) {
             return f;
         }
         return null;
     }
 
+    /**
+     * Returns a file object corresponding to a built-in profile
+     * specified by fileName.
+     * If there is no built-in profile with such name, then the method
+     * returns null.
+     */
+    private static File getStandardProfileFile(String fileName) {
+        String dir = System.getProperty("java.home") +
+            File.separatorChar + "lib" + File.separatorChar + "cmm";
+        String fullPath = dir + File.separatorChar + fileName;
+        File f = new File(fullPath);
+        if (!f.isFile()) {
+            //make sure file was installed in the kernel mode
+            BootClassLoaderHook hook = BootClassLoaderHook.getHook();
+            if (hook != null) {
+                hook.prefetchFile("lib/cmm/"+fileName);
+            }
+        }
+        return (f.isFile() && isChildOf(f, dir)) ? f : null;
+    }
+
+    /**
+     * Checks whether given file resides inside give directory.
+     */
+    private static boolean isChildOf(File f, String dirName) {
+        try {
+            File dir = new File(dirName);
+            String canonicalDirName = dir.getCanonicalPath();
+            if (!canonicalDirName.endsWith(File.separator)) {
+                canonicalDirName += File.separator;
+            }
+            String canonicalFileName = f.getCanonicalPath();
+            return canonicalFileName.startsWith(canonicalDirName);
+        } catch (IOException e) {
+            /* we do not expect the IOException here, because invocation
+             * of this function is always preceeded by isFile() call.
+             */
+            return false;
+        }
+    }
+
+    /**
+     * Checks whether built-in profile specified by fileName exists.
+     */
+    private static boolean standardProfileExists(final String fileName) {
+        return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+                public Boolean run() {
+                    return getStandardProfileFile(fileName) != null;
+                }
+            });
+    }
+
 
     /*
      * Serialization support.
--- a/src/share/classes/java/awt/datatransfer/DataFlavor.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/datatransfer/DataFlavor.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1184,7 +1184,7 @@
     */
 
     public boolean isRepresentationClassRemote() {
-        return java.rmi.Remote.class.isAssignableFrom(representationClass);
+        return DataTransferer.isRemote(representationClass);
     }
 
    /**
--- a/src/share/classes/java/awt/event/InvocationEvent.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/event/InvocationEvent.java	Wed Nov 25 11:08:25 2009 -0800
@@ -78,11 +78,22 @@
 
     /**
      * The (potentially null) Object whose notifyAll() method will be called
-     * immediately after the Runnable.run() method returns.
+     * immediately after the Runnable.run() method has returned or thrown an exception.
+     *
+     * @see #isDispatched
      */
     protected Object notifier;
 
     /**
+     * Indicates whether the <code>run()</code> method of the <code>runnable</code>
+     * was executed or not.
+     *
+     * @see #isDispatched
+     * @since 1.7
+     */
+    private volatile boolean dispatched = false;
+
+    /**
      * Set to true if dispatch() catches Throwable and stores it in the
      * exception instance variable. If false, Throwables are propagated up
      * to the EventDispatchThread's dispatch loop.
@@ -144,7 +155,7 @@
      * source which will execute the runnable's <code>run</code>
      * method when dispatched.  If notifier is non-<code>null</code>,
      * <code>notifyAll()</code> will be called on it
-     * immediately after <code>run</code> returns.
+     * immediately after <code>run</code> has returned or thrown an exception.
      * <p>An invocation of the form <tt>InvocationEvent(source,
      * runnable, notifier, catchThrowables)</tt>
      * behaves in exactly the same way as the invocation of
@@ -159,7 +170,8 @@
      *                          executed
      * @param notifier          The {@code Object} whose <code>notifyAll</code>
      *                          method will be called after
-     *                          <code>Runnable.run</code> has returned
+     *                          <code>Runnable.run</code> has returned or
+     *                          thrown an exception
      * @param catchThrowables   Specifies whether <code>dispatch</code>
      *                          should catch Throwable when executing
      *                          the <code>Runnable</code>'s <code>run</code>
@@ -180,8 +192,8 @@
      * Constructs an <code>InvocationEvent</code> with the specified
      * source and ID which will execute the runnable's <code>run</code>
      * method when dispatched.  If notifier is non-<code>null</code>,
-     * <code>notifyAll</code> will be called on it
-     * immediately after <code>run</code> returns.
+     * <code>notifyAll</code> will be called on it immediately after
+     * <code>run</code> has returned or thrown an exception.
      * <p>This method throws an
      * <code>IllegalArgumentException</code> if <code>source</code>
      * is <code>null</code>.
@@ -195,7 +207,8 @@
      *                          <code>run</code> method will be executed
      * @param notifier          The <code>Object</code> whose <code>notifyAll</code>
      *                          method will be called after
-     *                          <code>Runnable.run</code> has returned
+     *                          <code>Runnable.run</code> has returned or
+     *                          thrown an exception
      * @param catchThrowables   Specifies whether <code>dispatch</code>
      *                          should catch Throwable when executing the
      *                          <code>Runnable</code>'s <code>run</code>
@@ -217,27 +230,33 @@
 
     /**
      * Executes the Runnable's <code>run()</code> method and notifies the
-     * notifier (if any) when <code>run()</code> returns.
+     * notifier (if any) when <code>run()</code> has returned or thrown an exception.
+     *
+     * @see #isDispatched
      */
     public void dispatch() {
-        if (catchExceptions) {
-            try {
+        try {
+            if (catchExceptions) {
+                try {
+                    runnable.run();
+                }
+                catch (Throwable t) {
+                    if (t instanceof Exception) {
+                        exception = (Exception) t;
+                    }
+                    throwable = t;
+                }
+            }
+            else {
                 runnable.run();
             }
-            catch (Throwable t) {
-                if (t instanceof Exception) {
-                    exception = (Exception) t;
+        } finally {
+            dispatched = true;
+
+            if (notifier != null) {
+                synchronized (notifier) {
+                    notifier.notifyAll();
                 }
-                throwable = t;
-            }
-        }
-        else {
-            runnable.run();
-        }
-
-        if (notifier != null) {
-            synchronized (notifier) {
-                notifier.notifyAll();
             }
         }
     }
@@ -278,6 +297,40 @@
     }
 
     /**
+     * Returns {@code true} if the event is dispatched or any exception is
+     * thrown while dispatching, {@code false} otherwise. The method should
+     * be called by a waiting thread that calls the {@code notifier.wait()} method.
+     * Since spurious wakeups are possible (as explained in {@link Object#wait()}),
+     * this method should be used in a waiting loop to ensure that the event
+     * got dispatched:
+     * <pre>
+     *     while (!event.isDispatched()) {
+     *         notifier.wait();
+     *     }
+     * </pre>
+     * If the waiting thread wakes up without dispatching the event,
+     * the {@code isDispatched()} method returns {@code false}, and
+     * the {@code while} loop executes once more, thus, causing
+     * the awakened thread to revert to the waiting mode.
+     * <p>
+     * If the {@code notifier.notifyAll()} happens before the waiting thread
+     * enters the {@code notifier.wait()} method, the {@code while} loop ensures
+     * that the waiting thread will not enter the {@code notifier.wait()} method.
+     * Otherwise, there is no guarantee that the waiting thread will ever be woken
+     * from the wait.
+     *
+     * @return {@code true} if the event has been dispatched, or any exception
+     * has been thrown while dispatching, {@code false} otherwise
+     * @see #dispatch
+     * @see #notifier
+     * @see #catchExceptions
+     * @since 1.7
+     */
+    public boolean isDispatched() {
+        return dispatched;
+    }
+
+    /**
      * Returns a parameter string identifying this event.
      * This method is useful for event-logging and for debugging.
      *
--- a/src/share/classes/java/awt/font/NumericShaper.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/awt/font/NumericShaper.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-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
@@ -25,6 +25,13 @@
 
 package java.awt.font;
 
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.EnumSet;
+import java.util.Set;
+
 /**
  * The <code>NumericShaper</code> class is used to convert Latin-1 (European)
  * digits to other Unicode decimal digits.  Users of this class will
@@ -64,13 +71,261 @@
  *      NumericShaper.getContextualShaper(NumericShaper.ARABIC |
  *                                              NumericShaper.TAMIL,
  *                                              NumericShaper.EUROPEAN);
- *   shaper.shape(text. start, count);
+ *   shaper.shape(text, start, count);
+ * </pre></blockquote>
+ *
+ * <p><b>Bit mask- and enum-based Unicode ranges</b></p>
+ *
+ * <p>This class supports two different programming interfaces to
+ * represent Unicode ranges for script-specific digits: bit
+ * mask-based ones, such as {@link #ARABIC NumericShaper.ARABIC}, and
+ * enum-based ones, such as {@link NumericShaper.Range#ARABIC}.
+ * Multiple ranges can be specified by ORing bit mask-based constants,
+ * such as:
+ * <blockquote><pre>
+ * NumericShaper.ARABIC | NumericShaper.TAMIL
  * </pre></blockquote>
+ * or creating a {@code Set} with the {@link NumericShaper.Range}
+ * constants, such as:
+ * <blockquote><pre>
+ * EnumSet.of(NumericShaper.Scirpt.ARABIC, NumericShaper.Range.TAMIL)
+ * </pre></blockquote>
+ * The enum-based ranges are a super set of the bit mask-based ones.
+ *
+ * <p>If the two interfaces are mixed (including serialization),
+ * Unicode range values are mapped to their counterparts where such
+ * mapping is possible, such as {@code NumericShaper.Range.ARABIC}
+ * from/to {@code NumericShaper.ARABIC}.  If any unmappable range
+ * values are specified, such as {@code NumericShaper.Range.BALINESE},
+ * those ranges are ignored.
  *
  * @since 1.4
  */
 
 public final class NumericShaper implements java.io.Serializable {
+    /**
+     * A {@code NumericShaper.Range} represents a Unicode range of a
+     * script having its own decimal digits. For example, the {@link
+     * NumericShaper.Range#THAI} range has the Thai digits, THAI DIGIT
+     * ZERO (U+0E50) to THAI DIGIT NINE (U+0E59).
+     *
+     * <p>The <code>Range</code> enum replaces the traditional bit
+     * mask-based values (e.g., {@link NumericShaper#ARABIC}), and
+     * supports more Unicode ranges than the bit mask-based ones. For
+     * example, the following code using the bit mask:
+     * <blockquote><pre>
+     * NumericShaper.getContextualShaper(NumericShaper.ARABIC |
+     *                                     NumericShaper.TAMIL,
+     *                                   NumericShaper.EUROPEAN);
+     * </pre></blockquote>
+     * can be written using this enum as:
+     * <blockquote><pre>
+     * NumericShaper.getContextualShaper(EnumSet.of(
+     *                                     NumericShaper.Range.ARABIC,
+     *                                     NumericShaper.Range.TAMIL),
+     *                                   NumericShaper.Range.EUROPEAN);
+     * </pre></blockquote>
+     *
+     * @since 1.7
+     */
+    public static enum Range {
+        /**
+         * The Latin (European) range with the Latin (ASCII) digits.
+         */
+        EUROPEAN        ('\u0030', '\u0000', '\u0300'),
+        /**
+         * The Arabic range with the Arabic-Indic digits.
+         */
+        ARABIC          ('\u0660', '\u0600', '\u0780'),
+        /**
+         * The Arabic range with the Eastern Arabic-Indic digits.
+         */
+        EASTERN_ARABIC  ('\u06f0', '\u0600', '\u0780'),
+        /**
+         * The Devanagari range with the Devanagari digits.
+         */
+        DEVANAGARI      ('\u0966', '\u0900', '\u0980'),
+        /**
+         * The Bengali range with the Bengali digits.
+         */
+        BENGALI         ('\u09e6', '\u0980', '\u0a00'),
+        /**
+         * The Gurmukhi range with the Gurmukhi digits.
+         */
+        GURMUKHI        ('\u0a66', '\u0a00', '\u0a80'),
+        /**
+         * The Gujarati range with the Gujarati digits.
+         */
+        GUJARATI        ('\u0ae6', '\u0b00', '\u0b80'),
+        /**
+         * The Oriya range with the Oriya digits.
+         */
+        ORIYA           ('\u0b66', '\u0b00', '\u0b80'),
+        /**
+         * The Tamil range with the Tamil digits.
+         */
+        TAMIL           ('\u0be6', '\u0b80', '\u0c00'),
+        /**
+         * The Telugu range with the Telugu digits.
+         */
+        TELUGU          ('\u0c66', '\u0c00', '\u0c80'),
+        /**
+         * The Kannada range with the Kannada digits.
+         */
+        KANNADA         ('\u0ce6', '\u0c80', '\u0d00'),
+        /**
+         * The Malayalam range with the Malayalam digits.
+         */
+        MALAYALAM       ('\u0d66', '\u0d00', '\u0d80'),
+        /**
+         * The Thai range with the Thai digits.
+         */
+        THAI            ('\u0e50', '\u0e00', '\u0e80'),
+        /**
+         * The Lao range with the Lao digits.
+         */
+        LAO             ('\u0ed0', '\u0e80', '\u0f00'),
+        /**
+         * The Tibetan range with the Tibetan digits.
+         */
+        TIBETAN         ('\u0f20', '\u0f00', '\u1000'),
+        /**
+         * The Myanmar range with the Myanmar digits.
+         */
+        MYANMAR         ('\u1040', '\u1000', '\u1080'),
+        /**
+         * The Ethiopic range with the Ethiopic digits. Ethiopic
+         * does not have a decimal digit 0 so Latin (European) 0 is
+         * used.
+         */
+        ETHIOPIC        ('\u1369', '\u1200', '\u1380') {
+            @Override
+            char getNumericBase() { return 1; }
+        },
+        /**
+         * The Khmer range with the Khmer digits.
+         */
+        KHMER           ('\u17e0', '\u1780', '\u1800'),
+        /**
+         * The Mongolian range with the Mongolian digits.
+         */
+        MONGOLIAN       ('\u1810', '\u1800', '\u1900'),
+        /**
+         * The N'Ko range with the N'Ko digits.
+         */
+        NKO             ('\u07c0', '\u07c0', '\u0800'),
+        /**
+         * The Myanmar range with the Myanmar Shan digits.
+         */
+        MYANMAR_SHAN    ('\u1090', '\u1000', '\u10a0'),
+        /**
+         * The Limbu range with the Limbu digits.
+         */
+        LIMBU           ('\u1946', '\u1900', '\u1950'),
+        /**
+         * The New Tai Lue range with the New Tai Lue digits.
+         */
+        NEW_TAI_LUE     ('\u19d0', '\u1980', '\u19e0'),
+        /**
+         * The Balinese range with the Balinese digits.
+         */
+        BALINESE        ('\u1b50', '\u1b00', '\u1b80'),
+        /**
+         * The Sundanese range with the Sundanese digits.
+         */
+        SUNDANESE       ('\u1bb0', '\u1b80', '\u1bc0'),
+        /**
+         * The Lepcha range with the Lepcha digits.
+         */
+        LEPCHA          ('\u1c40', '\u1c00', '\u1c50'),
+        /**
+         * The Ol Chiki range with the Ol Chiki digits.
+         */
+        OL_CHIKI        ('\u1c50', '\u1c50', '\u1c80'),
+        /**
+         * The Vai range with the Vai digits.
+         */
+        VAI             ('\ua620', '\ua500', '\ua640'),
+        /**
+         * The Saurashtra range with the Saurashtra digits.
+         */
+        SAURASHTRA      ('\ua8d0', '\ua880', '\ua8e0'),
+        /**
+         * The Kayah Li range with the Kayah Li digits.
+         */
+        KAYAH_LI        ('\ua900', '\ua900', '\ua930'),
+        /**
+         * The Cham range with the Cham digits.
+         */
+        CHAM            ('\uaa50', '\uaa00', '\uaa60');
+
+        private static final Range[] ranges = Range.class.getEnumConstants();
+        static {
+            // sort ranges[] by base for binary search
+            Arrays.sort(ranges,
+                        new Comparator<Range>() {
+                            public int compare(Range s1, Range s2) {
+                                return s1.base > s2.base ? 1 : s1.base == s2.base ? 0 : -1;
+                            }
+                        });
+        }
+
+        private static int toRangeIndex(Range script) {
+            int index = script.ordinal();
+            return index < NUM_KEYS ? index : -1;
+        }
+
+        private static Range indexToRange(int index) {
+            return index < NUM_KEYS ? Range.values()[index] : null;
+        }
+
+        private static int toRangeMask(Set<Range> ranges) {
+            int m = 0;
+            for (Range range : ranges) {
+                int index = range.ordinal();
+                if (index < NUM_KEYS) {
+                    m |= 1 << index;
+                }
+            }
+            return m;
+        }
+
+        private static Set<Range> maskToRangeSet(int mask) {
+            Set<Range> set = EnumSet.noneOf(Range.class);
+            Range[] a = Range.values();
+            for (int i = 0; i < NUM_KEYS; i++) {
+                if ((mask & (1 << i)) != 0) {
+                    set.add(a[i]);
+                }
+            }
+            return set;
+        }
+
+        // base character of range digits
+        private final int base;
+        // Unicode range
+        private final int start, // inclusive
+                          end;   // exclusive
+
+        private Range(int base, int start, int end) {
+            this.base = base - ('0' + getNumericBase());
+            this.start = start;
+            this.end = end;
+        }
+
+        private int getDigitBase() {
+            return base;
+        }
+
+        char getNumericBase() {
+            return 0;
+        }
+
+        private boolean inRange(int c) {
+            return start <= c && c < end;
+        }
+    }
+
     /** index of context for contextual shaping - values range from 0 to 18 */
     private int key;
 
@@ -79,6 +334,25 @@
      */
     private int mask;
 
+    /**
+     * The context {@code Range} for contextual shaping or the {@code
+     * Range} for non-contextual shaping. {@code null} for the bit
+     * mask-based API.
+     *
+     * @since 1.7
+     */
+    private Range shapingRange;
+
+    /**
+     * {@code Set<Range>} indicating which Unicode ranges to
+     * shape. {@code null} for the bit mask-based API.
+     *
+     * @since 1.7
+     */
+    private transient Set<Range> rangeSet;
+
+    private static final long serialVersionUID = -8022764705923730308L;
+
     /** Identifies the Latin-1 (European) and extended range, and
      *  Latin-1 (European) decimal base.
      */
@@ -105,9 +379,8 @@
     /** Identifies the ORIYA range and decimal base. */
     public static final int ORIYA = 1<<7;
 
-    /** Identifies the TAMIL range and decimal base. Tamil does not have a
-     *  decimal digit 0 so Latin-1 (European) 0 is used.
-     */
+    /** Identifies the TAMIL range and decimal base. */
+    // TAMIL DIGIT ZERO was added in Unicode 4.1
     public static final int TAMIL = 1<<8;
 
     /** Identifies the TELUGU range and decimal base. */
@@ -140,7 +413,12 @@
     /** Identifies the MONGOLIAN range and decimal base. */
     public static final int MONGOLIAN = 1<<18;
 
-    /** Identifies all ranges, for full contextual shaping. */
+    /** Identifies all ranges, for full contextual shaping.
+     *
+     * <p>This constant specifies all of the bit mask-based
+     * ranges. Use {@code EmunSet.allOf(NumericShaper.Range.class)} to
+     * specify all of the enum-based ranges.
+     */
     public static final int ALL_RANGES = 0x0007ffff;
 
     private static final int EUROPEAN_KEY = 0;
@@ -163,42 +441,20 @@
     private static final int KHMER_KEY = 17;
     private static final int MONGOLIAN_KEY = 18;
 
-    private static final int NUM_KEYS = 19;
-
-    private static final String[] keyNames = {
-        "EUROPEAN",
-        "ARABIC",
-        "EASTERN_ARABIC",
-        "DEVANAGARI",
-        "BENGALI",
-        "GURMUKHI",
-        "GUJARATI",
-        "ORIYA",
-        "TAMIL",
-        "TELUGU",
-        "KANNADA",
-        "MALAYALAM",
-        "THAI",
-        "LAO",
-        "TIBETAN",
-        "MYANMAR",
-        "ETHIOPIC",
-        "KHMER",
-        "MONGOLIAN"
-    };
+    private static final int NUM_KEYS = MONGOLIAN_KEY + 1; // fixed
 
     private static final int CONTEXTUAL_MASK = 1<<31;
 
     private static final char[] bases = {
         '\u0030' - '\u0030', // EUROPEAN
-        '\u0660' - '\u0030', // ARABIC
-        '\u06f0' - '\u0030', // EASTERN_ARABIC
+        '\u0660' - '\u0030', // ARABIC-INDIC
+        '\u06f0' - '\u0030', // EXTENDED ARABIC-INDIC (EASTERN_ARABIC)
         '\u0966' - '\u0030', // DEVANAGARI
         '\u09e6' - '\u0030', // BENGALI
         '\u0a66' - '\u0030', // GURMUKHI
         '\u0ae6' - '\u0030', // GUJARATI
         '\u0b66' - '\u0030', // ORIYA
-        '\u0be7' - '\u0030', // TAMIL - note missing zero
+        '\u0be6' - '\u0030', // TAMIL - zero was added in Unicode 4.1
         '\u0c66' - '\u0030', // TELUGU
         '\u0ce6' - '\u0030', // KANNADA
         '\u0d66' - '\u0030', // MALAYALAM
@@ -206,7 +462,7 @@
         '\u0ed0' - '\u0030', // LAO
         '\u0f20' - '\u0030', // TIBETAN
         '\u1040' - '\u0030', // MYANMAR
-        '\u1369' - '\u0030', // ETHIOPIC
+        '\u1369' - '\u0031', // ETHIOPIC - no zero
         '\u17e0' - '\u0030', // KHMER
         '\u1810' - '\u0030', // MONGOLIAN
     };
@@ -215,14 +471,14 @@
 
     private static final char[] contexts = {
         '\u0000', '\u0300', // 'EUROPEAN' (really latin-1 and extended)
-        '\u0600', '\u0700', // ARABIC
-        '\u0600', '\u0700', // EASTERN_ARABIC -- note overlap with arabic
+        '\u0600', '\u0780', // ARABIC
+        '\u0600', '\u0780', // EASTERN_ARABIC -- note overlap with arabic
         '\u0900', '\u0980', // DEVANAGARI
         '\u0980', '\u0a00', // BENGALI
         '\u0a00', '\u0a80', // GURMUKHI
         '\u0a80', '\u0b00', // GUJARATI
         '\u0b00', '\u0b80', // ORIYA
-        '\u0b80', '\u0c00', // TAMIL - note missing zero
+        '\u0b80', '\u0c00', // TAMIL
         '\u0c00', '\u0c80', // TELUGU
         '\u0c80', '\u0d00', // KANNADA
         '\u0d00', '\u0d80', // MALAYALAM
@@ -230,7 +486,7 @@
         '\u0e80', '\u0f00', // LAO
         '\u0f00', '\u1000', // TIBETAN
         '\u1000', '\u1080', // MYANMAR
-        '\u1200', '\u1380', // ETHIOPIC
+        '\u1200', '\u1380', // ETHIOPIC - note missing zero
         '\u1780', '\u1800', // KHMER
         '\u1800', '\u1900', // MONGOLIAN
         '\uffff',
@@ -254,378 +510,290 @@
         return (ctCache & 0x1) == 0 ? (ctCache / 2) : EUROPEAN_KEY;
     }
 
+    // cache for the NumericShaper.Range version
+    private transient volatile Range currentRange = Range.EUROPEAN;
+
+    private Range rangeForCodePoint(int codepoint) {
+        Range range = currentRange;
+        if (range.inRange(codepoint)) {
+            return range;
+        }
+
+        final Range[] ranges = Range.ranges;
+        int lo = 0;
+        int hi = ranges.length - 1;
+        while (lo <= hi) {
+            int mid = (lo + hi) / 2;
+            range = ranges[mid];
+            if (codepoint < range.start) {
+                hi = mid - 1;
+            } else if (codepoint >= range.end) {
+                lo = mid + 1;
+            } else {
+                currentRange = range;
+                return range;
+            }
+        }
+        return Range.EUROPEAN;
+    }
+
     /*
      * A range table of strong directional characters (types L, R, AL).
      * Even (left) indexes are starts of ranges of non-strong-directional (or undefined)
      * characters, odd (right) indexes are starts of ranges of strong directional
      * characters.
      */
-    private static char[] strongTable = {
-        '\u0000', '\u0041',
-        '\u005b', '\u0061',
-        '\u007b', '\u00aa',
-        '\u00ab', '\u00b5',
-        '\u00b6', '\u00ba',
-        '\u00bb', '\u00c0',
-        '\u00d7', '\u00d8',
-        '\u00f7', '\u00f8',
-        '\u0220', '\u0222',
-        '\u0234', '\u0250',
-        '\u02ae', '\u02b0',
-        '\u02b9', '\u02bb',
-        '\u02c2', '\u02d0',
-        '\u02d2', '\u02e0',
-        '\u02e5', '\u02ee',
-        '\u02ef', '\u037a',
-        '\u037b', '\u0386',
-        '\u0387', '\u0388',
-        '\u038b', '\u038c',
-        '\u038d', '\u038e',
-        '\u03a2', '\u03a3',
-        '\u03cf', '\u03d0',
-        '\u03d8', '\u03da',
-        '\u03f4', '\u0400',
-        '\u0483', '\u048c',
-        '\u04c5', '\u04c7',
-        '\u04c9', '\u04cb',
-        '\u04cd', '\u04d0',
-        '\u04f6', '\u04f8',
-        '\u04fa', '\u0531',
-        '\u0557', '\u0559',
-        '\u0560', '\u0561',
-        '\u0588', '\u0589',
-        '\u058a', '\u05be',
-        '\u05bf', '\u05c0',
-        '\u05c1', '\u05c3',
-        '\u05c4', '\u05d0',
-        '\u05eb', '\u05f0',
-        '\u05f5', '\u061b',
-        '\u061c', '\u061f',
-        '\u0620', '\u0621',
-        '\u063b', '\u0640',
-        '\u064b', '\u066d',
-        '\u066e', '\u0671',
-        '\u06d6', '\u06e5',
-        '\u06e7', '\u06fa',
-        '\u06ff', '\u0700',
-        '\u070e', '\u0710',
-        '\u0711', '\u0712',
-        '\u072d', '\u0780',
-        '\u07a6', '\u0903',
-        '\u0904', '\u0905',
-        '\u093a', '\u093d',
-        '\u0941', '\u0949',
-        '\u094d', '\u0950',
-        '\u0951', '\u0958',
-        '\u0962', '\u0964',
-        '\u0971', '\u0982',
-        '\u0984', '\u0985',
-        '\u098d', '\u098f',
-        '\u0991', '\u0993',
-        '\u09a9', '\u09aa',
-        '\u09b1', '\u09b2',
-        '\u09b3', '\u09b6',
-        '\u09ba', '\u09be',
-        '\u09c1', '\u09c7',
-        '\u09c9', '\u09cb',
-        '\u09cd', '\u09d7',
-        '\u09d8', '\u09dc',
-        '\u09de', '\u09df',
-        '\u09e2', '\u09e6',
-        '\u09f2', '\u09f4',
-        '\u09fb', '\u0a05',
-        '\u0a0b', '\u0a0f',
-        '\u0a11', '\u0a13',
-        '\u0a29', '\u0a2a',
-        '\u0a31', '\u0a32',
-        '\u0a34', '\u0a35',
-        '\u0a37', '\u0a38',
-        '\u0a3a', '\u0a3e',
-        '\u0a41', '\u0a59',
-        '\u0a5d', '\u0a5e',
-        '\u0a5f', '\u0a66',
-        '\u0a70', '\u0a72',
-        '\u0a75', '\u0a83',
-        '\u0a84', '\u0a85',
-        '\u0a8c', '\u0a8d',
-        '\u0a8e', '\u0a8f',
-        '\u0a92', '\u0a93',
-        '\u0aa9', '\u0aaa',
-        '\u0ab1', '\u0ab2',
-        '\u0ab4', '\u0ab5',
-        '\u0aba', '\u0abd',
-        '\u0ac1', '\u0ac9',
-        '\u0aca', '\u0acb',
-        '\u0acd', '\u0ad0',
-        '\u0ad1', '\u0ae0',
-        '\u0ae1', '\u0ae6',
-        '\u0af0', '\u0b02',
-        '\u0b04', '\u0b05',
-        '\u0b0d', '\u0b0f',
-        '\u0b11', '\u0b13',
-        '\u0b29', '\u0b2a',
-        '\u0b31', '\u0b32',
-        '\u0b34', '\u0b36',
-        '\u0b3a', '\u0b3d',
-        '\u0b3f', '\u0b40',
-        '\u0b41', '\u0b47',
-        '\u0b49', '\u0b4b',
-        '\u0b4d', '\u0b57',
-        '\u0b58', '\u0b5c',
-        '\u0b5e', '\u0b5f',
-        '\u0b62', '\u0b66',
-        '\u0b71', '\u0b83',
-        '\u0b84', '\u0b85',
-        '\u0b8b', '\u0b8e',
-        '\u0b91', '\u0b92',
-        '\u0b96', '\u0b99',
-        '\u0b9b', '\u0b9c',
-        '\u0b9d', '\u0b9e',
-        '\u0ba0', '\u0ba3',
-        '\u0ba5', '\u0ba8',
-        '\u0bab', '\u0bae',
-        '\u0bb6', '\u0bb7',
-        '\u0bba', '\u0bbe',
-        '\u0bc0', '\u0bc1',
-        '\u0bc3', '\u0bc6',
-        '\u0bc9', '\u0bca',
-        '\u0bcd', '\u0bd7',
-        '\u0bd8', '\u0be7',
-        '\u0bf3', '\u0c01',
-        '\u0c04', '\u0c05',
-        '\u0c0d', '\u0c0e',
-        '\u0c11', '\u0c12',
-        '\u0c29', '\u0c2a',
-        '\u0c34', '\u0c35',
-        '\u0c3a', '\u0c41',
-        '\u0c45', '\u0c60',
-        '\u0c62', '\u0c66',
-        '\u0c70', '\u0c82',
-        '\u0c84', '\u0c85',
-        '\u0c8d', '\u0c8e',
-        '\u0c91', '\u0c92',
-        '\u0ca9', '\u0caa',
-        '\u0cb4', '\u0cb5',
-        '\u0cba', '\u0cbe',
-        '\u0cbf', '\u0cc0',
-        '\u0cc5', '\u0cc7',
-        '\u0cc9', '\u0cca',
-        '\u0ccc', '\u0cd5',
-        '\u0cd7', '\u0cde',
-        '\u0cdf', '\u0ce0',
-        '\u0ce2', '\u0ce6',
-        '\u0cf0', '\u0d02',
-        '\u0d04', '\u0d05',
-        '\u0d0d', '\u0d0e',
-        '\u0d11', '\u0d12',
-        '\u0d29', '\u0d2a',
-        '\u0d3a', '\u0d3e',
-        '\u0d41', '\u0d46',
-        '\u0d49', '\u0d4a',
-        '\u0d4d', '\u0d57',
-        '\u0d58', '\u0d60',
-        '\u0d62', '\u0d66',
-        '\u0d70', '\u0d82',
-        '\u0d84', '\u0d85',
-        '\u0d97', '\u0d9a',
-        '\u0db2', '\u0db3',
-        '\u0dbc', '\u0dbd',
-        '\u0dbe', '\u0dc0',
-        '\u0dc7', '\u0dcf',
-        '\u0dd2', '\u0dd8',
-        '\u0de0', '\u0df2',
-        '\u0df5', '\u0e01',
-        '\u0e31', '\u0e32',
-        '\u0e34', '\u0e40',
-        '\u0e47', '\u0e4f',
-        '\u0e5c', '\u0e81',
-        '\u0e83', '\u0e84',
-        '\u0e85', '\u0e87',
-        '\u0e89', '\u0e8a',
-        '\u0e8b', '\u0e8d',
-        '\u0e8e', '\u0e94',
-        '\u0e98', '\u0e99',
-        '\u0ea0', '\u0ea1',
-        '\u0ea4', '\u0ea5',
-        '\u0ea6', '\u0ea7',
-        '\u0ea8', '\u0eaa',
-        '\u0eac', '\u0ead',
-        '\u0eb1', '\u0eb2',
-        '\u0eb4', '\u0ebd',
-        '\u0ebe', '\u0ec0',
-        '\u0ec5', '\u0ec6',
-        '\u0ec7', '\u0ed0',
-        '\u0eda', '\u0edc',
-        '\u0ede', '\u0f00',
-        '\u0f18', '\u0f1a',
-        '\u0f35', '\u0f36',
-        '\u0f37', '\u0f38',
-        '\u0f39', '\u0f3e',
-        '\u0f48', '\u0f49',
-        '\u0f6b', '\u0f7f',
-        '\u0f80', '\u0f85',
-        '\u0f86', '\u0f88',
-        '\u0f8c', '\u0fbe',
-        '\u0fc6', '\u0fc7',
-        '\u0fcd', '\u0fcf',
-        '\u0fd0', '\u1000',
-        '\u1022', '\u1023',
-        '\u1028', '\u1029',
-        '\u102b', '\u102c',
-        '\u102d', '\u1031',
-        '\u1032', '\u1038',
-        '\u1039', '\u1040',
-        '\u1058', '\u10a0',
-        '\u10c6', '\u10d0',
-        '\u10f7', '\u10fb',
-        '\u10fc', '\u1100',
-        '\u115a', '\u115f',
-        '\u11a3', '\u11a8',
-        '\u11fa', '\u1200',
-        '\u1207', '\u1208',
-        '\u1247', '\u1248',
-        '\u1249', '\u124a',
-        '\u124e', '\u1250',
-        '\u1257', '\u1258',
-        '\u1259', '\u125a',
-        '\u125e', '\u1260',
-        '\u1287', '\u1288',
-        '\u1289', '\u128a',
-        '\u128e', '\u1290',
-        '\u12af', '\u12b0',
-        '\u12b1', '\u12b2',
-        '\u12b6', '\u12b8',
-        '\u12bf', '\u12c0',
-        '\u12c1', '\u12c2',
-        '\u12c6', '\u12c8',
-        '\u12cf', '\u12d0',
-        '\u12d7', '\u12d8',
-        '\u12ef', '\u12f0',
-        '\u130f', '\u1310',
-        '\u1311', '\u1312',
-        '\u1316', '\u1318',
-        '\u131f', '\u1320',
-        '\u1347', '\u1348',
-        '\u135b', '\u1361',
-        '\u137d', '\u13a0',
-        '\u13f5', '\u1401',
-        '\u1677', '\u1681',
-        '\u169b', '\u16a0',
-        '\u16f1', '\u1780',
-        '\u17b7', '\u17be',
-        '\u17c6', '\u17c7',
-        '\u17c9', '\u17d4',
-        '\u17db', '\u17dc',
-        '\u17dd', '\u17e0',
-        '\u17ea', '\u1810',
-        '\u181a', '\u1820',
-        '\u1878', '\u1880',
-        '\u18a9', '\u1e00',
-        '\u1e9c', '\u1ea0',
-        '\u1efa', '\u1f00',
-        '\u1f16', '\u1f18',
-        '\u1f1e', '\u1f20',
-        '\u1f46', '\u1f48',
-        '\u1f4e', '\u1f50',
-        '\u1f58', '\u1f59',
-        '\u1f5a', '\u1f5b',
-        '\u1f5c', '\u1f5d',
-        '\u1f5e', '\u1f5f',
-        '\u1f7e', '\u1f80',
-        '\u1fb5', '\u1fb6',
-        '\u1fbd', '\u1fbe',
-        '\u1fbf', '\u1fc2',
-        '\u1fc5', '\u1fc6',
-        '\u1fcd', '\u1fd0',
-        '\u1fd4', '\u1fd6',
-        '\u1fdc', '\u1fe0',
-        '\u1fed', '\u1ff2',
-        '\u1ff5', '\u1ff6',
-        '\u1ffd', '\u200e',
-        '\u2010', '\u207f',
-        '\u2080', '\u2102',
-        '\u2103', '\u2107',
-        '\u2108', '\u210a',
-        '\u2114', '\u2115',
-        '\u2116', '\u2119',
-        '\u211e', '\u2124',
-        '\u2125', '\u2126',
-        '\u2127', '\u2128',
-        '\u2129', '\u212a',
-        '\u212e', '\u212f',
-        '\u2132', '\u2133',
-        '\u213a', '\u2160',
-        '\u2184', '\u2336',
-        '\u237b', '\u2395',
-        '\u2396', '\u249c',
-        '\u24ea', '\u3005',
-        '\u3008', '\u3021',
-        '\u302a', '\u3031',
-        '\u3036', '\u3038',
-        '\u303b', '\u3041',
-        '\u3095', '\u309d',
-        '\u309f', '\u30a1',
-        '\u30fb', '\u30fc',
-        '\u30ff', '\u3105',
-        '\u312d', '\u3131',
-        '\u318f', '\u3190',
-        '\u31b8', '\u3200',
-        '\u321d', '\u3220',
-        '\u3244', '\u3260',
-        '\u327c', '\u327f',
-        '\u32b1', '\u32c0',
-        '\u32cc', '\u32d0',
-        '\u32ff', '\u3300',
-        '\u3377', '\u337b',
-        '\u33de', '\u33e0',
-        '\u33ff', '\u3400',
-        '\u4db6', '\u4e00',
-        '\u9fa6', '\ua000',
-        '\ua48d', '\uac00',
-        '\ud7a4', '\uf900',
-        '\ufa2e', '\ufb00',
-        '\ufb07', '\ufb13',
-        '\ufb18', '\ufb1d',
-        '\ufb1e', '\ufb1f',
-        '\ufb29', '\ufb2a',
-        '\ufb37', '\ufb38',
-        '\ufb3d', '\ufb3e',
-        '\ufb3f', '\ufb40',
-        '\ufb42', '\ufb43',
-        '\ufb45', '\ufb46',
-        '\ufbb2', '\ufbd3',
-        '\ufd3e', '\ufd50',
-        '\ufd90', '\ufd92',
-        '\ufdc8', '\ufdf0',
-        '\ufdfc', '\ufe70',
-        '\ufe73', '\ufe74',
-        '\ufe75', '\ufe76',
-        '\ufefd', '\uff21',
-        '\uff3b', '\uff41',
-        '\uff5b', '\uff66',
-        '\uffbf', '\uffc2',
-        '\uffc8', '\uffca',
-        '\uffd0', '\uffd2',
-        '\uffd8', '\uffda',
-        '\uffdd', '\uffff' // last entry is sentinel, actually never checked
+    private static int[] strongTable = {
+        0x0000, 0x0041,
+        0x005b, 0x0061,
+        0x007b, 0x00aa,
+        0x00ab, 0x00b5,
+        0x00b6, 0x00ba,
+        0x00bb, 0x00c0,
+        0x00d7, 0x00d8,
+        0x00f7, 0x00f8,
+        0x02b9, 0x02bb,
+        0x02c2, 0x02d0,
+        0x02d2, 0x02e0,
+        0x02e5, 0x02ee,
+        0x02ef, 0x0370,
+        0x0374, 0x0376,
+        0x037e, 0x0386,
+        0x0387, 0x0388,
+        0x03f6, 0x03f7,
+        0x0483, 0x048a,
+        0x058a, 0x05be,
+        0x05bf, 0x05c0,
+        0x05c1, 0x05c3,
+        0x05c4, 0x05c6,
+        0x05c7, 0x05d0,
+        0x0600, 0x0608,
+        0x0609, 0x060b,
+        0x060c, 0x060d,
+        0x060e, 0x061b,
+        0x064b, 0x066d,
+        0x0670, 0x0671,
+        0x06d6, 0x06e5,
+        0x06e7, 0x06ee,
+        0x06f0, 0x06fa,
+        0x070f, 0x0710,
+        0x0711, 0x0712,
+        0x0730, 0x074d,
+        0x07a6, 0x07b1,
+        0x07eb, 0x07f4,
+        0x07f6, 0x07fa,
+        0x0901, 0x0903,
+        0x093c, 0x093d,
+        0x0941, 0x0949,
+        0x094d, 0x0950,
+        0x0951, 0x0958,
+        0x0962, 0x0964,
+        0x0981, 0x0982,
+        0x09bc, 0x09bd,
+        0x09c1, 0x09c7,
+        0x09cd, 0x09ce,
+        0x09e2, 0x09e6,
+        0x09f2, 0x09f4,
+        0x0a01, 0x0a03,
+        0x0a3c, 0x0a3e,
+        0x0a41, 0x0a59,
+        0x0a70, 0x0a72,
+        0x0a75, 0x0a83,
+        0x0abc, 0x0abd,
+        0x0ac1, 0x0ac9,
+        0x0acd, 0x0ad0,
+        0x0ae2, 0x0ae6,
+        0x0af1, 0x0b02,
+        0x0b3c, 0x0b3d,
+        0x0b3f, 0x0b40,
+        0x0b41, 0x0b47,
+        0x0b4d, 0x0b57,
+        0x0b62, 0x0b66,
+        0x0b82, 0x0b83,
+        0x0bc0, 0x0bc1,
+        0x0bcd, 0x0bd0,
+        0x0bf3, 0x0c01,
+        0x0c3e, 0x0c41,
+        0x0c46, 0x0c58,
+        0x0c62, 0x0c66,
+        0x0c78, 0x0c7f,
+        0x0cbc, 0x0cbd,
+        0x0ccc, 0x0cd5,
+        0x0ce2, 0x0ce6,
+        0x0cf1, 0x0d02,
+        0x0d41, 0x0d46,
+        0x0d4d, 0x0d57,
+        0x0d62, 0x0d66,
+        0x0dca, 0x0dcf,
+        0x0dd2, 0x0dd8,
+        0x0e31, 0x0e32,
+        0x0e34, 0x0e40,
+        0x0e47, 0x0e4f,
+        0x0eb1, 0x0eb2,
+        0x0eb4, 0x0ebd,
+        0x0ec8, 0x0ed0,
+        0x0f18, 0x0f1a,
+        0x0f35, 0x0f36,
+        0x0f37, 0x0f38,
+        0x0f39, 0x0f3e,
+        0x0f71, 0x0f7f,
+        0x0f80, 0x0f85,
+        0x0f86, 0x0f88,
+        0x0f90, 0x0fbe,
+        0x0fc6, 0x0fc7,
+        0x102d, 0x1031,
+        0x1032, 0x1038,
+        0x1039, 0x103b,
+        0x103d, 0x103f,
+        0x1058, 0x105a,
+        0x105e, 0x1061,
+        0x1071, 0x1075,
+        0x1082, 0x1083,
+        0x1085, 0x1087,
+        0x108d, 0x108e,
+        0x135f, 0x1360,
+        0x1390, 0x13a0,
+        0x1680, 0x1681,
+        0x169b, 0x16a0,
+        0x1712, 0x1720,
+        0x1732, 0x1735,
+        0x1752, 0x1760,
+        0x1772, 0x1780,
+        0x17b7, 0x17be,
+        0x17c6, 0x17c7,
+        0x17c9, 0x17d4,
+        0x17db, 0x17dc,
+        0x17dd, 0x17e0,
+        0x17f0, 0x1810,
+        0x18a9, 0x18aa,
+        0x1920, 0x1923,
+        0x1927, 0x1929,
+        0x1932, 0x1933,
+        0x1939, 0x1946,
+        0x19de, 0x1a00,
+        0x1a17, 0x1a19,
+        0x1b00, 0x1b04,
+        0x1b34, 0x1b35,
+        0x1b36, 0x1b3b,
+        0x1b3c, 0x1b3d,
+        0x1b42, 0x1b43,
+        0x1b6b, 0x1b74,
+        0x1b80, 0x1b82,
+        0x1ba2, 0x1ba6,
+        0x1ba8, 0x1baa,
+        0x1c2c, 0x1c34,
+        0x1c36, 0x1c3b,
+        0x1dc0, 0x1e00,
+        0x1fbd, 0x1fbe,
+        0x1fbf, 0x1fc2,
+        0x1fcd, 0x1fd0,
+        0x1fdd, 0x1fe0,
+        0x1fed, 0x1ff2,
+        0x1ffd, 0x200e,
+        0x2010, 0x2071,
+        0x2074, 0x207f,
+        0x2080, 0x2090,
+        0x20a0, 0x2102,
+        0x2103, 0x2107,
+        0x2108, 0x210a,
+        0x2114, 0x2115,
+        0x2116, 0x2119,
+        0x211e, 0x2124,
+        0x2125, 0x2126,
+        0x2127, 0x2128,
+        0x2129, 0x212a,
+        0x212e, 0x212f,
+        0x213a, 0x213c,
+        0x2140, 0x2145,
+        0x214a, 0x214e,
+        0x2153, 0x2160,
+        0x2190, 0x2336,
+        0x237b, 0x2395,
+        0x2396, 0x249c,
+        0x24ea, 0x26ac,
+        0x26ad, 0x2800,
+        0x2900, 0x2c00,
+        0x2ce5, 0x2d00,
+        0x2de0, 0x3005,
+        0x3008, 0x3021,
+        0x302a, 0x3031,
+        0x3036, 0x3038,
+        0x303d, 0x3041,
+        0x3099, 0x309d,
+        0x30a0, 0x30a1,
+        0x30fb, 0x30fc,
+        0x31c0, 0x31f0,
+        0x321d, 0x3220,
+        0x3250, 0x3260,
+        0x327c, 0x327f,
+        0x32b1, 0x32c0,
+        0x32cc, 0x32d0,
+        0x3377, 0x337b,
+        0x33de, 0x33e0,
+        0x33ff, 0x3400,
+        0x4dc0, 0x4e00,
+        0xa490, 0xa500,
+        0xa60d, 0xa610,
+        0xa66f, 0xa680,
+        0xa700, 0xa722,
+        0xa788, 0xa789,
+        0xa802, 0xa803,
+        0xa806, 0xa807,
+        0xa80b, 0xa80c,
+        0xa825, 0xa827,
+        0xa828, 0xa840,
+        0xa874, 0xa880,
+        0xa8c4, 0xa8ce,
+        0xa926, 0xa92e,
+        0xa947, 0xa952,
+        0xaa29, 0xaa2f,
+        0xaa31, 0xaa33,
+        0xaa35, 0xaa40,
+        0xaa43, 0xaa44,
+        0xaa4c, 0xaa4d,
+        0xfb1e, 0xfb1f,
+        0xfb29, 0xfb2a,
+        0xfd3e, 0xfd50,
+        0xfdfd, 0xfe70,
+        0xfeff, 0xff21,
+        0xff3b, 0xff41,
+        0xff5b, 0xff66,
+        0xffe0, 0x10000,
+        0x10101, 0x10102,
+        0x10140, 0x101d0,
+        0x101fd, 0x10280,
+        0x1091f, 0x10920,
+        0x10a01, 0x10a10,
+        0x10a38, 0x10a40,
+        0x1d167, 0x1d16a,
+        0x1d173, 0x1d183,
+        0x1d185, 0x1d18c,
+        0x1d1aa, 0x1d1ae,
+        0x1d200, 0x1d360,
+        0x1d7ce, 0x20000,
+        0xe0001, 0xf0000,
+        0x10fffe, 0x10ffff // sentinel
     };
 
 
     // use a binary search with a cache
 
-    private static int stCache = 0;
+    private transient volatile int stCache = 0;
 
-    // warning, synchronize access to this as it modifies state
-    private static boolean isStrongDirectional(char c) {
-        if (c < strongTable[stCache]) {
-            stCache = search(c, strongTable, 0, stCache);
-        } else if (c >= strongTable[stCache + 1]) {
-            stCache = search(c, strongTable, stCache + 1, strongTable.length - stCache - 1);
+    private boolean isStrongDirectional(char c) {
+        int cachedIndex = stCache;
+        if (c < strongTable[cachedIndex]) {
+            cachedIndex = search(c, strongTable, 0, cachedIndex);
+        } else if (c >= strongTable[cachedIndex + 1]) {
+            cachedIndex = search(c, strongTable, cachedIndex + 1,
+                                 strongTable.length - cachedIndex - 1);
         }
-        return (stCache & 0x1) == 1;
+        boolean val = (cachedIndex & 0x1) == 1;
+        stCache = cachedIndex;
+        return val;
     }
 
-    static private int getKeyFromMask(int mask) {
+    private static int getKeyFromMask(int mask) {
         int key = 0;
         while (key < NUM_KEYS && ((mask & (1<<key)) == 0)) {
             ++key;
@@ -644,12 +812,27 @@
      * @return a non-contextual numeric shaper
      * @throws IllegalArgumentException if the range is not a single range
      */
-    static public NumericShaper getShaper(int singleRange) {
+    public static NumericShaper getShaper(int singleRange) {
         int key = getKeyFromMask(singleRange);
         return new NumericShaper(key, singleRange);
     }
 
     /**
+     * Returns a shaper for the provided Unicode
+     * range. All Latin-1 (EUROPEAN) digits are converted to the
+     * corresponding decimal digits of the specified Unicode range.
+     *
+     * @param singleRange the Unicode range given by a {@link
+     *                    NumericShaper.Range} constant.
+     * @return a non-contextual {@code NumericShaper}.
+     * @throws NullPointerException if {@code singleRange} is {@code null}
+     * @since 1.7
+     */
+    public static NumericShaper getShaper(Range singleRange) {
+        return new NumericShaper(singleRange, EnumSet.of(singleRange));
+    }
+
+    /**
      * Returns a contextual shaper for the provided unicode range(s).
      * Latin-1 (EUROPEAN) digits are converted to the decimal digits
      * corresponding to the range of the preceding text, if the
@@ -663,12 +846,34 @@
      * @param ranges the specified Unicode ranges
      * @return a shaper for the specified ranges
      */
-    static public NumericShaper getContextualShaper(int ranges) {
+    public static NumericShaper getContextualShaper(int ranges) {
         ranges |= CONTEXTUAL_MASK;
         return new NumericShaper(EUROPEAN_KEY, ranges);
     }
 
     /**
+     * Returns a contextual shaper for the provided Unicode
+     * range(s). The Latin-1 (EUROPEAN) digits are converted to the
+     * decimal digits corresponding to the range of the preceding
+     * text, if the range is one of the provided ranges.
+     *
+     * <p>The shaper assumes EUROPEAN as the starting context, that
+     * is, if EUROPEAN digits are encountered before any strong
+     * directional text in the string, the context is presumed to be
+     * EUROPEAN, and so the digits will not shape.
+     *
+     * @param ranges the specified Unicode ranges
+     * @return a contextual shaper for the specified ranges
+     * @throws NullPointerException if {@code ranges} is {@code null}.
+     * @since 1.7
+     */
+    public static NumericShaper getContextualShaper(Set<Range> ranges) {
+        NumericShaper shaper = new NumericShaper(Range.EUROPEAN, ranges);
+        shaper.mask = CONTEXTUAL_MASK;
+        return shaper;
+    }
+
+    /**
      * Returns a contextual shaper for the provided unicode range(s).
      * Latin-1 (EUROPEAN) digits will be converted to the decimal digits
      * corresponding to the range of the preceding text, if the
@@ -683,13 +888,38 @@
      * @throws IllegalArgumentException if the specified
      * <code>defaultContext</code> is not a single valid range.
      */
-    static public NumericShaper getContextualShaper(int ranges, int defaultContext) {
+    public static NumericShaper getContextualShaper(int ranges, int defaultContext) {
         int key = getKeyFromMask(defaultContext);
         ranges |= CONTEXTUAL_MASK;
         return new NumericShaper(key, ranges);
     }
 
     /**
+     * Returns a contextual shaper for the provided Unicode range(s).
+     * The Latin-1 (EUROPEAN) digits will be converted to the decimal
+     * digits corresponding to the range of the preceding text, if the
+     * range is one of the provided ranges. The shaper uses {@code
+     * defaultContext} as the starting context.
+     *
+     * @param ranges the specified Unicode ranges
+     * @param defaultContext the starting context, such as
+     *                       {@code NumericShaper.Range.EUROPEAN}
+     * @return a contextual shaper for the specified Unicode ranges.
+     * @throws NullPointerException
+     *         if {@code ranges} or {@code defaultContext} is {@code null}
+     * @since 1.7
+     */
+    public static NumericShaper getContextualShaper(Set<Range> ranges,
+                                                    Range defaultContext) {
+        if (defaultContext == null) {
+            throw new NullPointerException();
+        }
+        NumericShaper shaper = new NumericShaper(defaultContext, ranges);
+        shaper.mask = CONTEXTUAL_MASK;
+        return shaper;
+    }
+
+    /**
      * Private constructor.
      */
     private NumericShaper(int key, int mask) {
@@ -697,6 +927,11 @@
         this.mask = mask;
     }
 
+    private NumericShaper(Range defaultContext, Set<Range> ranges) {
+        this.shapingRange = defaultContext;
+        this.rangeSet = EnumSet.copyOf(ranges); // throws NPE if ranges is null.
+    }
+
     /**
      * Converts the digits in the text that occur between start and
      * start + count.
@@ -710,19 +945,13 @@
      * @throws NullPointerException if text is null
      */
     public void shape(char[] text, int start, int count) {
-        if (text == null) {
-            throw new NullPointerException("text is null");
-        }
-        if ((start < 0)
-            || (start > text.length)
-            || ((start + count) < 0)
-            || ((start + count) > text.length)) {
-            throw new IndexOutOfBoundsException(
-                "bad start or count for text of length " + text.length);
-        }
-
+        checkParams(text, start, count);
         if (isContextual()) {
-            shapeContextually(text, start, count, key);
+            if (rangeSet == null) {
+                shapeContextually(text, start, count, key);
+            } else {
+                shapeContextually(text, start, count, shapingRange);
+            }
         } else {
             shapeNonContextually(text, start, count);
         }
@@ -747,6 +976,60 @@
      * range.
      */
     public void shape(char[] text, int start, int count, int context) {
+        checkParams(text, start, count);
+        if (isContextual()) {
+            int ctxKey = getKeyFromMask(context);
+            if (rangeSet == null) {
+                shapeContextually(text, start, count, ctxKey);
+            } else {
+                shapeContextually(text, start, count, Range.values()[ctxKey]);
+            }
+        } else {
+            shapeNonContextually(text, start, count);
+        }
+    }
+
+    /**
+     * Converts the digits in the text that occur between {@code
+     * start} and {@code start + count}, using the provided {@code
+     * context}. {@code Context} is ignored if the shaper is not a
+     * contextual shaper.
+     *
+     * @param text  a {@code char} array
+     * @param start the index into {@code text} to start converting
+     * @param count the number of {@code char}s in {@code text}
+     *              to convert
+     * @param context the context to which to convert the characters,
+     *                such as {@code NumericShaper.Range.EUROPEAN}
+     * @throws IndexOutOfBoundsException
+     *         if {@code start} or {@code start + count} is out of bounds
+     * @throws NullPointerException
+     *         if {@code text} or {@code context} is null
+     * @since 1.7
+     */
+    public void shape(char[] text, int start, int count, Range context) {
+        checkParams(text, start, count);
+        if (context == null) {
+            throw new NullPointerException("context is null");
+        }
+
+        if (isContextual()) {
+            if (rangeSet != null) {
+                shapeContextually(text, start, count, context);
+            } else {
+                int key = Range.toRangeIndex(context);
+                if (key >= 0) {
+                    shapeContextually(text, start, count, key);
+                } else {
+                    shapeContextually(text, start, count, shapingRange);
+                }
+            }
+        } else {
+            shapeNonContextually(text, start, count);
+        }
+    }
+
+    private void checkParams(char[] text, int start, int count) {
         if (text == null) {
             throw new NullPointerException("text is null");
         }
@@ -757,13 +1040,6 @@
             throw new IndexOutOfBoundsException(
                 "bad start or count for text of length " + text.length);
         }
-
-        if (isContextual()) {
-            int ctxKey = getKeyFromMask(context);
-            shapeContextually(text, start, count, ctxKey);
-        } else {
-            shapeNonContextually(text, start, count);
-        }
     }
 
     /**
@@ -785,6 +1061,10 @@
      * <blockquote>
      *   <code>if ((shaper.getRanges() & shaper.ARABIC) != 0) { ... </code>
      * </blockquote>
+     *
+     * <p>Note that this method supports only the bit mask-based
+     * ranges. Call {@link #getRangeSet()} for the enum-based ranges.
+     *
      * @return the values for all the ranges to be shaped.
      */
     public int getRanges() {
@@ -792,11 +1072,34 @@
     }
 
     /**
+     * Returns a {@code Set} representing all the Unicode ranges in
+     * this {@code NumericShaper} that will be shaped.
+     *
+     * @return all the Unicode ranges to be shaped.
+     * @since 1.7
+     */
+    public Set<Range> getRangeSet() {
+        if (rangeSet != null) {
+            return EnumSet.copyOf(rangeSet);
+        }
+        return Range.maskToRangeSet(mask);
+    }
+
+    /**
      * Perform non-contextual shaping.
      */
     private void shapeNonContextually(char[] text, int start, int count) {
-        int base = bases[key];
-        char minDigit = key == TAMIL_KEY ? '\u0031' : '\u0030'; // Tamil doesn't use decimal zero
+        int base;
+        char minDigit = '0';
+        if (shapingRange != null) {
+            base = shapingRange.getDigitBase();
+            minDigit += shapingRange.getNumericBase();
+        } else {
+            base = bases[key];
+            if (key == ETHIOPIC_KEY) {
+                minDigit++; // Ethiopic doesn't use decimal zero
+            }
+        }
         for (int i = start, e = start + count; i < e; ++i) {
             char c = text[i];
             if (c >= minDigit && c <= '\u0039') {
@@ -807,7 +1110,7 @@
 
     /**
      * Perform contextual shaping.
-     * Synchronized to protect caches used in getContextKey and isStrongDirectional.
+     * Synchronized to protect caches used in getContextKey.
      */
     private synchronized void shapeContextually(char[] text, int start, int count, int ctxKey) {
 
@@ -818,29 +1121,64 @@
         int lastkey = ctxKey;
 
         int base = bases[ctxKey];
-        char minDigit = ctxKey == TAMIL_KEY ? '\u0031' : '\u0030'; // Tamil doesn't use decimal zero
+        char minDigit = ctxKey == ETHIOPIC_KEY ? '1' : '0'; // Ethiopic doesn't use decimal zero
+
+        synchronized (NumericShaper.class) {
+            for (int i = start, e = start + count; i < e; ++i) {
+                char c = text[i];
+                if (c >= minDigit && c <= '\u0039') {
+                    text[i] = (char)(c + base);
+                }
+
+                if (isStrongDirectional(c)) {
+                    int newkey = getContextKey(c);
+                    if (newkey != lastkey) {
+                        lastkey = newkey;
 
-        for (int i = start, e = start + count; i < e; ++i) {
+                        ctxKey = newkey;
+                        if (((mask & EASTERN_ARABIC) != 0) && (ctxKey == ARABIC_KEY || ctxKey == EASTERN_ARABIC_KEY)) {
+                            ctxKey = EASTERN_ARABIC_KEY;
+                        } else if ((mask & (1<<ctxKey)) == 0) {
+                            ctxKey = EUROPEAN_KEY;
+                        }
+
+                        base = bases[ctxKey];
+
+                        minDigit = ctxKey == ETHIOPIC_KEY ? '1' : '0'; // Ethiopic doesn't use decimal zero
+                    }
+                }
+            }
+        }
+    }
+
+    private void shapeContextually(char[] text, int start, int count, Range ctxKey) {
+        if (ctxKey == null) {
+            ctxKey = Range.EUROPEAN;
+        }
+
+        Range lastKey = ctxKey;
+        int base = ctxKey.getDigitBase();
+        char minDigit = (char)('0' + ctxKey.getNumericBase());
+        for (int i = start, end = start + count; i < end; ++i) {
             char c = text[i];
-            if (c >= minDigit && c <= '\u0039') {
+            if (c >= minDigit && c <= '9') {
                 text[i] = (char)(c + base);
+                continue;
             }
-
             if (isStrongDirectional(c)) {
-                int newkey = getContextKey(c);
-                if (newkey != lastkey) {
-                    lastkey = newkey;
-
-                    ctxKey = newkey;
-                    if (((mask & EASTERN_ARABIC) != 0) && (ctxKey == ARABIC_KEY || ctxKey == EASTERN_ARABIC_KEY)) {
-                        ctxKey = EASTERN_ARABIC_KEY;
-                    } else if ((mask & (1<<ctxKey)) == 0) {
-                        ctxKey = EUROPEAN_KEY;
+                Range newKey = rangeForCodePoint(c);
+                if (newKey != lastKey) {
+                    lastKey = newKey;
+                    ctxKey = newKey;
+                    if (rangeSet.contains(Range.EUROPEAN)
+                        && (ctxKey == Range.ARABIC || ctxKey == Range.EASTERN_ARABIC)) {
+                        ctxKey = Range.EASTERN_ARABIC;
+                    } else if (!rangeSet.contains(ctxKey)) {
+                        ctxKey = Range.EUROPEAN;
                     }
 
-                    base = bases[ctxKey];
-
-                    minDigit = ctxKey == TAMIL_KEY ? '\u0031' : '\u0030'; // Tamil doesn't use decimal zero
+                    base = ctxKey.getDigitBase();
+                    minDigit = (char)('0' + ctxKey.getNumericBase());
                 }
             }
         }
@@ -852,12 +1190,28 @@
      * @see java.lang.Object#hashCode
      */
     public int hashCode() {
-        return mask;
+        int hash = mask;
+        if (rangeSet != null) {
+            // Use the CONTEXTUAL_MASK bit only for the enum-based
+            // NumericShaper. A deserialized NumericShaper might have
+            // bit masks.
+            hash &= CONTEXTUAL_MASK;
+            hash ^= rangeSet.hashCode();
+        }
+        return hash;
     }
 
     /**
-     * Returns true if the specified object is an instance of
-     * <code>NumericShaper</code> and shapes identically to this one.
+     * Returns {@code true} if the specified object is an instance of
+     * <code>NumericShaper</code> and shapes identically to this one,
+     * regardless of the range representations, the bit mask or the
+     * enum. For example, the following code produces {@code "true"}.
+     * <blockquote><pre>
+     * NumericShaper ns1 = NumericShaper.getShaper(NumericShaper.ARABIC);
+     * NumericShaper ns2 = NumericShaper.getShaper(NumericShaper.Range.ARABIC);
+     * System.out.println(ns1.equals(ns2));
+     * </pre></blockquote>
+     *
      * @param o the specified object to compare to this
      *          <code>NumericShaper</code>
      * @return <code>true</code> if <code>o</code> is an instance
@@ -869,6 +1223,22 @@
         if (o != null) {
             try {
                 NumericShaper rhs = (NumericShaper)o;
+                if (rangeSet != null) {
+                    if (rhs.rangeSet != null) {
+                        return isContextual() == rhs.isContextual()
+                            && rangeSet.equals(rhs.rangeSet)
+                            && shapingRange == rhs.shapingRange;
+                    }
+                    return isContextual() == rhs.isContextual()
+                        && rangeSet.equals(Range.maskToRangeSet(rhs.mask))
+                        && shapingRange == Range.indexToRange(rhs.key);
+                } else if (rhs.rangeSet != null) {
+                    Set<Range> rset = Range.maskToRangeSet(mask);
+                    Range srange = Range.indexToRange(key);
+                    return isContextual() == rhs.isContextual()
+                        && rset.equals(rhs.rangeSet)
+                        && srange == rhs.shapingRange;
+                }
                 return rhs.mask == mask && rhs.key == key;
             }
             catch (ClassCastException e) {
@@ -885,23 +1255,29 @@
     public String toString() {
         StringBuilder buf = new StringBuilder(super.toString());
 
-        buf.append("[contextual:" + isContextual());
+        buf.append("[contextual:").append(isContextual());
 
+        String[] keyNames = null;
         if (isContextual()) {
-            buf.append(", context:" + keyNames[key]);
+            buf.append(", context:");
+            buf.append(shapingRange == null ? Range.values()[key] : shapingRange);
         }
 
-        buf.append(", range(s): ");
-        boolean first = true;
-        for (int i = 0; i < NUM_KEYS; ++i) {
-            if ((mask & (1 << i)) != 0) {
-                if (first) {
-                    first = false;
-                } else {
-                    buf.append(", ");
+        if (rangeSet == null) {
+            buf.append(", range(s): ");
+            boolean first = true;
+            for (int i = 0; i < NUM_KEYS; ++i) {
+                if ((mask & (1 << i)) != 0) {
+                    if (first) {
+                        first = false;
+                    } else {
+                        buf.append(", ");
+                    }
+                    buf.append(Range.values()[i]);
                 }
-                buf.append(keyNames[i]);
             }
+        } else {
+            buf.append(", range set: ").append(rangeSet);
         }
         buf.append(']');
 
@@ -940,7 +1316,6 @@
         }
 
         if (value >= 1 << 1) {
-            value >>= 1;
             bit += 1;
         }
 
@@ -950,7 +1325,7 @@
     /**
      * fast binary search over subrange of array.
      */
-    private static int search(char value, char[] array, int start, int length)
+    private static int search(int value, int[] array, int start, int length)
     {
         int power = 1 << getHighBit(length);
         int extra = length - power;
@@ -971,4 +1346,27 @@
 
         return index;
     }
+
+    /**
+     * Converts the {@code NumericShaper.Range} enum-based parameters,
+     * if any, to the bit mask-based counterparts and writes this
+     * object to the {@code stream}. Any enum constants that have no
+     * bit mask-based counterparts are ignored in the conversion.
+     *
+     * @param stream the output stream to write to
+     * @throws IOException if an I/O error occurs while writing to {@code stream}
+     * @since 1.7
+     */
+    private void writeObject(ObjectOutputStream stream) throws IOException {
+        if (shapingRange != null) {
+            int index = Range.toRangeIndex(shapingRange);
+            if (index >= 0) {
+                key = index;
+            }
+        }
+        if (rangeSet != null) {
+            mask |= Range.toRangeMask(rangeSet);
+        }
+        stream.defaultWriteObject();
+    }
 }
--- a/src/share/classes/java/beans/MetaData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/beans/MetaData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -42,12 +42,11 @@
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import java.sql.Timestamp;
-
 import java.util.*;
 
 import javax.swing.Box;
@@ -290,13 +289,44 @@
  * @author Sergey A. Malenkov
  */
 final class java_sql_Timestamp_PersistenceDelegate extends java_util_Date_PersistenceDelegate {
-    protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
-        Timestamp oldTime = (Timestamp)oldInstance;
-        Timestamp newTime = (Timestamp)newInstance;
+    private static final Method getNanosMethod = getNanosMethod();
+
+    private static Method getNanosMethod() {
+        try {
+            Class<?> c = Class.forName("java.sql.Timestamp", true, null);
+            return c.getMethod("getNanos");
+        } catch (ClassNotFoundException e) {
+            return null;
+        } catch (NoSuchMethodException e) {
+            throw new AssertionError(e);
+        }
+    }
 
-        int nanos = oldTime.getNanos();
-        if (nanos != newTime.getNanos()) {
-            out.writeStatement(new Statement(oldTime, "setNanos", new Object[] {nanos}));
+    /**
+     * Invoke Timstamp getNanos.
+     */
+    private static int getNanos(Object obj) {
+        if (getNanosMethod == null)
+            throw new AssertionError("Should not get here");
+        try {
+            return (Integer)getNanosMethod.invoke(obj);
+        } catch (InvocationTargetException e) {
+            Throwable cause = e.getCause();
+            if (cause instanceof RuntimeException)
+                throw (RuntimeException)cause;
+            if (cause instanceof Error)
+                throw (Error)cause;
+            throw new AssertionError(e);
+        } catch (IllegalAccessException iae) {
+            throw new AssertionError(iae);
+        }
+    }
+
+    protected void initialize(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
+        // assumes oldInstance and newInstance are Timestamps
+        int nanos = getNanos(oldInstance);
+        if (nanos != getNanos(newInstance)) {
+            out.writeStatement(new Statement(oldInstance, "setNanos", new Object[] {nanos}));
         }
     }
 }
--- a/src/share/classes/java/io/ObjectStreamClass.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/io/ObjectStreamClass.java	Wed Nov 25 11:08:25 2009 -0800
@@ -99,7 +99,7 @@
     }
 
     /** class associated with this descriptor (if any) */
-    private Class cl;
+    private Class<?> cl;
     /** name of class represented by this descriptor */
     private String name;
     /** serialVersionUID of represented class (null if not computed yet) */
@@ -276,7 +276,7 @@
      * @param   all if true, return descriptors for all classes; if false, only
      *          return descriptors for serializable classes
      */
-    static ObjectStreamClass lookup(Class cl, boolean all) {
+    static ObjectStreamClass lookup(Class<?> cl, boolean all) {
         if (!(all || Serializable.class.isAssignableFrom(cl))) {
             return null;
         }
@@ -414,7 +414,7 @@
     /**
      * Creates local class descriptor representing given class.
      */
-    private ObjectStreamClass(final Class cl) {
+    private ObjectStreamClass(final Class<?> cl) {
         this.cl = cl;
         name = cl.getName();
         isProxy = Proxy.isProxyClass(cl);
@@ -422,7 +422,7 @@
         serializable = Serializable.class.isAssignableFrom(cl);
         externalizable = Externalizable.class.isAssignableFrom(cl);
 
-        Class superCl = cl.getSuperclass();
+        Class<?> superCl = cl.getSuperclass();
         superDesc = (superCl != null) ? lookup(superCl, false) : null;
         localDesc = this;
 
@@ -453,10 +453,10 @@
                     } else {
                         cons = getSerializableConstructor(cl);
                         writeObjectMethod = getPrivateMethod(cl, "writeObject",
-                            new Class[] { ObjectOutputStream.class },
+                            new Class<?>[] { ObjectOutputStream.class },
                             Void.TYPE);
                         readObjectMethod = getPrivateMethod(cl, "readObject",
-                            new Class[] { ObjectInputStream.class },
+                            new Class<?>[] { ObjectInputStream.class },
                             Void.TYPE);
                         readObjectNoDataMethod = getPrivateMethod(
                             cl, "readObjectNoData", null, Void.TYPE);
@@ -507,7 +507,7 @@
     /**
      * Initializes class descriptor representing a proxy class.
      */
-    void initProxy(Class cl,
+    void initProxy(Class<?> cl,
                    ClassNotFoundException resolveEx,
                    ObjectStreamClass superDesc)
         throws InvalidClassException
@@ -540,7 +540,7 @@
      * Initializes class descriptor representing a non-proxy class.
      */
     void initNonProxy(ObjectStreamClass model,
-                      Class cl,
+                      Class<?> cl,
                       ClassNotFoundException resolveEx,
                       ObjectStreamClass superDesc)
         throws InvalidClassException
@@ -1131,7 +1131,7 @@
         throws InvalidClassException
     {
         ArrayList<ClassDataSlot> slots = new ArrayList<ClassDataSlot>();
-        Class start = cl, end = cl;
+        Class<?> start = cl, end = cl;
 
         // locate closest non-serializable superclass
         while (end != null && Serializable.class.isAssignableFrom(end)) {
@@ -1142,8 +1142,8 @@
 
             // search up inheritance hierarchy for class with matching name
             String searchName = (d.cl != null) ? d.cl.getName() : d.name;
-            Class match = null;
-            for (Class c = start; c != end; c = c.getSuperclass()) {
+            Class<?> match = null;
+            for (Class<?> c = start; c != end; c = c.getSuperclass()) {
                 if (searchName.equals(c.getName())) {
                     match = c;
                     break;
@@ -1152,7 +1152,7 @@
 
             // add "no data" slot for each unmatched class below match
             if (match != null) {
-                for (Class c = start; c != match; c = c.getSuperclass()) {
+                for (Class<?> c = start; c != match; c = c.getSuperclass()) {
                     slots.add(new ClassDataSlot(
                         ObjectStreamClass.lookup(c, true), false));
                 }
@@ -1164,7 +1164,7 @@
         }
 
         // add "no data" slot for any leftover unmatched classes
-        for (Class c = start; c != end; c = c.getSuperclass()) {
+        for (Class<?> c = start; c != end; c = c.getSuperclass()) {
             slots.add(new ClassDataSlot(
                 ObjectStreamClass.lookup(c, true), false));
         }
@@ -1288,7 +1288,7 @@
      * descriptor, returns reference to this class descriptor.  Otherwise,
      * returns variant of this class descriptor bound to given class.
      */
-    private ObjectStreamClass getVariantFor(Class cl)
+    private ObjectStreamClass getVariantFor(Class<?> cl)
         throws InvalidClassException
     {
         if (this.cl == cl) {
@@ -1355,8 +1355,8 @@
      * method (if any).
      */
     private static Method getInheritableMethod(Class<?> cl, String name,
-                                               Class[] argTypes,
-                                               Class returnType)
+                                               Class<?>[] argTypes,
+                                               Class<?> returnType)
     {
         Method meth = null;
         Class<?> defCl = cl;
@@ -1410,7 +1410,7 @@
      * Returns true if classes are defined in the same runtime package, false
      * otherwise.
      */
-    private static boolean packageEquals(Class cl1, Class cl2) {
+    private static boolean packageEquals(Class<?> cl1, Class<?> cl2) {
         return (cl1.getClassLoader() == cl2.getClassLoader() &&
                 getPackageName(cl1).equals(getPackageName(cl2)));
     }
@@ -1418,7 +1418,7 @@
     /**
      * Returns package name of given class.
      */
-    private static String getPackageName(Class cl) {
+    private static String getPackageName(Class<?> cl) {
         String s = cl.getName();
         int i = s.lastIndexOf('[');
         if (i >= 0) {
@@ -1441,7 +1441,7 @@
     /**
      * Returns JVM type signature for given class.
      */
-    static String getClassSignature(Class cl) {
+    private static String getClassSignature(Class<?> cl) {
         StringBuilder sbuf = new StringBuilder();
         while (cl.isArray()) {
             sbuf.append('[');
@@ -1478,8 +1478,8 @@
     /**
      * Returns JVM type signature for given list of parameters and return type.
      */
-    private static String getMethodSignature(Class[] paramTypes,
-                                             Class retType)
+    private static String getMethodSignature(Class<?>[] paramTypes,
+                                             Class<?> retType)
     {
         StringBuilder sbuf = new StringBuilder();
         sbuf.append('(');
@@ -1515,7 +1515,7 @@
      * Field objects.  Throws InvalidClassException if the (explicitly
      * declared) serializable fields are invalid.
      */
-    private static ObjectStreamField[] getSerialFields(Class cl)
+    private static ObjectStreamField[] getSerialFields(Class<?> cl)
         throws InvalidClassException
     {
         ObjectStreamField[] fields;
@@ -1545,7 +1545,7 @@
      * InvalidClassException if the declared serializable fields are
      * invalid--e.g., if multiple fields share the same name.
      */
-    private static ObjectStreamField[] getDeclaredSerialFields(Class cl)
+    private static ObjectStreamField[] getDeclaredSerialFields(Class<?> cl)
         throws InvalidClassException
     {
         ObjectStreamField[] serialPersistentFields = null;
@@ -1602,7 +1602,7 @@
      * contains a Field object for the field it represents.  If no default
      * serializable fields exist, NO_FIELDS is returned.
      */
-    private static ObjectStreamField[] getDefaultSerialFields(Class cl) {
+    private static ObjectStreamField[] getDefaultSerialFields(Class<?> cl) {
         Field[] clFields = cl.getDeclaredFields();
         ArrayList<ObjectStreamField> list = new ArrayList<ObjectStreamField>();
         int mask = Modifier.STATIC | Modifier.TRANSIENT;
@@ -1621,7 +1621,7 @@
      * Returns explicit serial version UID value declared by given class, or
      * null if none.
      */
-    private static Long getDeclaredSUID(Class cl) {
+    private static Long getDeclaredSUID(Class<?> cl) {
         try {
             Field f = cl.getDeclaredField("serialVersionUID");
             int mask = Modifier.STATIC | Modifier.FINAL;
@@ -1637,7 +1637,7 @@
     /**
      * Computes the default serial version UID value for the given class.
      */
-    private static long computeDefaultSUID(Class cl) {
+    private static long computeDefaultSUID(Class<?> cl) {
         if (!Serializable.class.isAssignableFrom(cl) || Proxy.isProxyClass(cl))
         {
             return 0L;
@@ -1671,7 +1671,7 @@
                  * Class.getInterfaces() was modified to return Cloneable and
                  * Serializable for array classes.
                  */
-                Class[] interfaces = cl.getInterfaces();
+                Class<?>[] interfaces = cl.getInterfaces();
                 String[] ifaceNames = new String[interfaces.length];
                 for (int i = 0; i < interfaces.length; i++) {
                     ifaceNames[i] = interfaces[i].getName();
@@ -1784,7 +1784,7 @@
      * Returns true if the given class defines a static initializer method,
      * false otherwise.
      */
-    private native static boolean hasStaticInitializer(Class cl);
+    private native static boolean hasStaticInitializer(Class<?> cl);
 
     /**
      * Class for computing and caching field/constructor/method signatures
@@ -1837,7 +1837,7 @@
         /** field type codes */
         private final char[] typeCodes;
         /** field types */
-        private final Class[] types;
+        private final Class<?>[] types;
 
         /**
          * Constructs FieldReflector capable of setting/getting values from the
@@ -2071,7 +2071,7 @@
         throws InvalidClassException
     {
         // class irrelevant if no fields
-        Class cl = (localDesc != null && fields.length > 0) ?
+        Class<?> cl = (localDesc != null && fields.length > 0) ?
             localDesc.cl : null;
         processQueue(Caches.reflectorsQueue, Caches.reflectors);
         FieldReflectorKey key = new FieldReflectorKey(cl, fields,
@@ -2136,7 +2136,7 @@
         private final int hash;
         private final boolean nullClass;
 
-        FieldReflectorKey(Class cl, ObjectStreamField[] fields,
+        FieldReflectorKey(Class<?> cl, ObjectStreamField[] fields,
                           ReferenceQueue<Class<?>> queue)
         {
             super(cl, queue);
--- a/src/share/classes/java/io/ObjectStreamField.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/io/ObjectStreamField.java	Wed Nov 25 11:08:25 2009 -0800
@@ -45,7 +45,7 @@
     /** canonical JVM signature of field type */
     private final String signature;
     /** field type (Object.class if unknown non-primitive type) */
-    private final Class type;
+    private final Class<?> type;
     /** whether or not to (de)serialize field values as unshared */
     private final boolean unshared;
     /** corresponding reflective field object, if any */
@@ -88,7 +88,7 @@
         this.name = name;
         this.type = type;
         this.unshared = unshared;
-        signature = ObjectStreamClass.getClassSignature(type).intern();
+        signature = getClassSignature(type).intern();
         field = null;
     }
 
@@ -132,9 +132,9 @@
         this.field = field;
         this.unshared = unshared;
         name = field.getName();
-        Class ftype = field.getType();
+        Class<?> ftype = field.getType();
         type = (showType || ftype.isPrimitive()) ? ftype : Object.class;
-        signature = ObjectStreamClass.getClassSignature(ftype).intern();
+        signature = getClassSignature(ftype).intern();
     }
 
     /**
@@ -274,4 +274,41 @@
     String getSignature() {
         return signature;
     }
+
+    /**
+     * Returns JVM type signature for given class.
+     */
+    private static String getClassSignature(Class<?> cl) {
+        StringBuilder sbuf = new StringBuilder();
+        while (cl.isArray()) {
+            sbuf.append('[');
+            cl = cl.getComponentType();
+        }
+        if (cl.isPrimitive()) {
+            if (cl == Integer.TYPE) {
+                sbuf.append('I');
+            } else if (cl == Byte.TYPE) {
+                sbuf.append('B');
+            } else if (cl == Long.TYPE) {
+                sbuf.append('J');
+            } else if (cl == Float.TYPE) {
+                sbuf.append('F');
+            } else if (cl == Double.TYPE) {
+                sbuf.append('D');
+            } else if (cl == Short.TYPE) {
+                sbuf.append('S');
+            } else if (cl == Character.TYPE) {
+                sbuf.append('C');
+            } else if (cl == Boolean.TYPE) {
+                sbuf.append('Z');
+            } else if (cl == Void.TYPE) {
+                sbuf.append('V');
+            } else {
+                throw new InternalError();
+            }
+        } else {
+            sbuf.append('L' + cl.getName().replace('.', '/') + ';');
+        }
+        return sbuf.toString();
+    }
 }
--- a/src/share/classes/java/lang/ClassLoader.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/lang/ClassLoader.java	Wed Nov 25 11:08:25 2009 -0800
@@ -186,11 +186,6 @@
         parallelLoaders.add(ClassLoader.class);
     }
 
-    // If initialization succeed this is set to true and security checks will
-    // succeed.  Otherwise the object is not initialized and the object is
-    // useless.
-    private final boolean initialized;
-
     // The parent class loader for delegation
     // Note: VM hardcoded the offset of this field, thus all new fields
     // must be added *after* it.
@@ -232,6 +227,31 @@
     private final HashMap<String, Package> packages =
         new HashMap<String, Package>();
 
+    private static Void checkCreateClassLoader() {
+        SecurityManager security = System.getSecurityManager();
+        if (security != null) {
+            security.checkCreateClassLoader();
+        }
+        return null;
+    }
+
+    private ClassLoader(Void unused, ClassLoader parent) {
+        this.parent = parent;
+        if (parallelLoaders.contains(this.getClass())) {
+            parallelLockMap = new ConcurrentHashMap<String, Object>();
+            package2certs = new ConcurrentHashMap<String, Certificate[]>();
+            domains =
+                Collections.synchronizedSet(new HashSet<ProtectionDomain>());
+            assertionLock = new Object();
+        } else {
+            // no finer-grained lock; lock on the classloader instance
+            parallelLockMap = null;
+            package2certs = new Hashtable<String, Certificate[]>();
+            domains = new HashSet<ProtectionDomain>();
+            assertionLock = this;
+        }
+    }
+
     /**
      * Creates a new class loader using the specified parent class loader for
      * delegation.
@@ -252,25 +272,7 @@
      * @since  1.2
      */
     protected ClassLoader(ClassLoader parent) {
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
-        this.parent = parent;
-        if (parallelLoaders.contains(this.getClass())) {
-            parallelLockMap = new ConcurrentHashMap<String, Object>();
-            package2certs = new ConcurrentHashMap<String, Certificate[]>();
-            domains =
-                Collections.synchronizedSet(new HashSet<ProtectionDomain>());
-            assertionLock = new Object();
-        } else {
-            // no finer-grained lock; lock on the classloader instance
-            parallelLockMap = null;
-            package2certs = new Hashtable<String, Certificate[]>();
-            domains = new HashSet<ProtectionDomain>();
-            assertionLock = this;
-        }
-        initialized = true;
+        this(checkCreateClassLoader(), parent);
     }
 
     /**
@@ -289,25 +291,7 @@
      *          of a new class loader.
      */
     protected ClassLoader() {
-        SecurityManager security = System.getSecurityManager();
-        if (security != null) {
-            security.checkCreateClassLoader();
-        }
-        this.parent = getSystemClassLoader();
-        if (parallelLoaders.contains(this.getClass())) {
-            parallelLockMap = new ConcurrentHashMap<String, Object>();
-            package2certs = new ConcurrentHashMap<String, Certificate[]>();
-            domains =
-                Collections.synchronizedSet(new HashSet<ProtectionDomain>());
-            assertionLock = new Object();
-        } else {
-            // no finer-grained lock; lock on the classloader instance
-            parallelLockMap = null;
-            package2certs = new Hashtable<String, Certificate[]>();
-            domains = new HashSet<ProtectionDomain>();
-            assertionLock = this;
-        }
-        initialized = true;
+        this(checkCreateClassLoader(), getSystemClassLoader());
     }
 
     // -- Class --
@@ -754,7 +738,6 @@
                                          ProtectionDomain protectionDomain)
         throws ClassFormatError
     {
-        check();
         protectionDomain = preDefineClass(name, protectionDomain);
 
         Class c = null;
@@ -838,8 +821,6 @@
                                          ProtectionDomain protectionDomain)
         throws ClassFormatError
     {
-        check();
-
         int len = b.remaining();
 
         // Use byte[] if not a direct ByteBufer:
@@ -984,7 +965,6 @@
      * @see  #defineClass(String, byte[], int, int)
      */
     protected final void resolveClass(Class<?> c) {
-        check();
         resolveClass0(c);
     }
 
@@ -1015,7 +995,6 @@
     protected final Class<?> findSystemClass(String name)
         throws ClassNotFoundException
     {
-        check();
         ClassLoader system = getSystemClassLoader();
         if (system == null) {
             if (!checkName(name))
@@ -1035,7 +1014,6 @@
      */
     private Class findBootstrapClassOrNull(String name)
     {
-        check();
         if (!checkName(name)) return null;
 
         return findBootstrapClass(name);
@@ -1044,13 +1022,6 @@
     // return null if not found
     private native Class findBootstrapClass(String name);
 
-    // Check to make sure the class loader has been initialized.
-    private void check() {
-        if (!initialized) {
-            throw new SecurityException("ClassLoader object not initialized");
-        }
-    }
-
     /**
      * Returns the class with the given <a href="#name">binary name</a> if this
      * loader has been recorded by the Java virtual machine as an initiating
@@ -1066,7 +1037,6 @@
      * @since  1.1
      */
     protected final Class<?> findLoadedClass(String name) {
-        check();
         if (!checkName(name))
             return null;
         return findLoadedClass0(name);
@@ -1087,7 +1057,6 @@
      * @since  1.1
      */
     protected final void setSigners(Class<?> c, Object[] signers) {
-        check();
         c.setSigners(signers);
     }
 
@@ -2205,3 +2174,4 @@
         return sys;
     }
 }
+
--- a/src/share/classes/java/lang/management/PlatformComponent.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/lang/management/PlatformComponent.java	Wed Nov 25 11:08:25 2009 -0800
@@ -30,8 +30,7 @@
 import java.util.List;
 import java.util.HashSet;
 import java.util.Set;
-import java.util.logging.LoggingMXBean;
-import java.util.logging.LogManager;
+import java.util.logging.PlatformLoggingMXBean;
 import java.nio.BufferPoolMXBean;
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
@@ -40,6 +39,7 @@
 import com.sun.management.UnixOperatingSystemMXBean;
 
 import sun.management.ManagementFactoryHelper;
+import sun.management.Util;
 
 /**
  * This enum class defines the list of platform components
@@ -180,15 +180,14 @@
      * Logging facility.
      */
     LOGGING(
-        "java.util.logging.LoggingMXBean",
+        "java.util.logging.PlatformLoggingMXBean",
         "java.util.logging", "Logging", defaultKeyProperties(),
-        new MXBeanFetcher<LoggingMXBean>() {
-            public List<LoggingMXBean> getMXBeans() {
-                return Collections.singletonList(LogManager.getLoggingMXBean());
+        new MXBeanFetcher<PlatformLoggingMXBean>() {
+            public List<PlatformLoggingMXBean> getMXBeans() {
+                return ManagementFactoryHelper.getLoggingMXBean();
             }
         }),
 
-
     /**
      * Buffer pools.
      */
@@ -384,7 +383,7 @@
             // if there are more than 1 key properties (i.e. other than "type")
             domainAndType += ",*";
         }
-        ObjectName on = ObjectName.valueOf(domainAndType);
+        ObjectName on = Util.newObjectName(domainAndType);
         Set<ObjectName> set =  mbs.queryNames(on, null);
         for (PlatformComponent pc : subComponents) {
             set.addAll(pc.getObjectNames(mbs));
--- a/src/share/classes/java/math/BigInteger.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/math/BigInteger.java	Wed Nov 25 11:08:25 2009 -0800
@@ -288,11 +288,11 @@
      */
     public BigInteger(String val, int radix) {
         int cursor = 0, numDigits;
-        int len = val.length();
+        final int len = val.length();
 
         if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX)
             throw new NumberFormatException("Radix out of range");
-        if (val.length() == 0)
+        if (len == 0)
             throw new NumberFormatException("Zero length BigInteger");
 
         // Check for at most one leading sign
@@ -303,7 +303,7 @@
             // No leading sign character or at most one leading sign character
             if (index1 == 0 || index2 == 0) {
                 cursor = 1;
-                if (val.length() == 1)
+                if (len == 1)
                     throw new NumberFormatException("Zero length BigInteger");
             }
             if (index1 == 0)
@@ -342,7 +342,7 @@
         // Process remaining digit groups
         int superRadix = intRadix[radix];
         int groupVal = 0;
-        while (cursor < val.length()) {
+        while (cursor < len) {
             group = val.substring(cursor, cursor += digitsPerInt[radix]);
             groupVal = Integer.parseInt(group, radix);
             if (groupVal < 0)
@@ -478,7 +478,7 @@
 
     /**
      * Constructs a randomly generated BigInteger, uniformly distributed over
-     * the range {@code 0} to (2<sup>{@code numBits}</sup> - 1), inclusive.
+     * the range 0 to (2<sup>{@code numBits}</sup> - 1), inclusive.
      * The uniformity of the distribution assumes that a fair source of random
      * bits is provided in {@code rnd}.  Note that this constructor always
      * constructs a non-negative BigInteger.
@@ -1332,7 +1332,7 @@
      *
      * @param  val value by which this BigInteger is to be divided.
      * @return {@code this / val}
-     * @throws ArithmeticException {@code val==0}
+     * @throws ArithmeticException if {@code val} is zero.
      */
     public BigInteger divide(BigInteger val) {
         MutableBigInteger q = new MutableBigInteger(),
@@ -1352,7 +1352,7 @@
      * @return an array of two BigIntegers: the quotient {@code (this / val)}
      *         is the initial element, and the remainder {@code (this % val)}
      *         is the final element.
-     * @throws ArithmeticException {@code val==0}
+     * @throws ArithmeticException if {@code val} is zero.
      */
     public BigInteger[] divideAndRemainder(BigInteger val) {
         BigInteger[] result = new BigInteger[2];
@@ -1371,7 +1371,7 @@
      * @param  val value by which this BigInteger is to be divided, and the
      *         remainder computed.
      * @return {@code this % val}
-     * @throws ArithmeticException {@code val==0}
+     * @throws ArithmeticException if {@code val} is zero.
      */
     public BigInteger remainder(BigInteger val) {
         MutableBigInteger q = new MutableBigInteger(),
@@ -1547,7 +1547,7 @@
      *
      * @param  m the modulus.
      * @return {@code this mod m}
-     * @throws ArithmeticException {@code m <= 0}
+     * @throws ArithmeticException {@code m} &le; 0
      * @see    #remainder
      */
     public BigInteger mod(BigInteger m) {
@@ -1566,7 +1566,9 @@
      * @param  exponent the exponent.
      * @param  m the modulus.
      * @return <tt>this<sup>exponent</sup> mod m</tt>
-     * @throws ArithmeticException {@code m <= 0}
+     * @throws ArithmeticException {@code m} &le; 0 or the exponent is
+     *         negative and this BigInteger is not <i>relatively
+     *         prime</i> to {@code m}.
      * @see    #modInverse
      */
     public BigInteger modPow(BigInteger exponent, BigInteger m) {
@@ -2015,7 +2017,7 @@
      *
      * @param  m the modulus.
      * @return {@code this}<sup>-1</sup> {@code mod m}.
-     * @throws ArithmeticException {@code  m <= 0}, or this BigInteger
+     * @throws ArithmeticException {@code  m} &le; 0, or this BigInteger
      *         has no multiplicative inverse mod m (that is, this BigInteger
      *         is not <i>relatively prime</i> to m).
      */
@@ -2051,6 +2053,8 @@
      *
      * @param  n shift distance, in bits.
      * @return {@code this << n}
+     * @throws ArithmeticException if the shift distance is {@code
+     *         Integer.MIN_VALUE}.
      * @see #shiftRight
      */
     public BigInteger shiftLeft(int n) {
@@ -2058,8 +2062,13 @@
             return ZERO;
         if (n==0)
             return this;
-        if (n<0)
-            return shiftRight(-n);
+        if (n<0) {
+            if (n == Integer.MIN_VALUE) {
+                throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
+            } else {
+                return shiftRight(-n);
+            }
+        }
 
         int nInts = n >>> 5;
         int nBits = n & 0x1f;
@@ -2097,13 +2106,20 @@
      *
      * @param  n shift distance, in bits.
      * @return {@code this >> n}
+     * @throws ArithmeticException if the shift distance is {@code
+     *         Integer.MIN_VALUE}.
      * @see #shiftLeft
      */
     public BigInteger shiftRight(int n) {
         if (n==0)
             return this;
-        if (n<0)
-            return shiftLeft(-n);
+        if (n<0) {
+            if (n == Integer.MIN_VALUE) {
+                throw new ArithmeticException("Shift distance of Integer.MIN_VALUE not supported.");
+            } else {
+                return shiftLeft(-n);
+            }
+        }
 
         int nInts = n >>> 5;
         int nBits = n & 0x1f;
@@ -2435,7 +2451,7 @@
     /**
      * Returns {@code true} if this BigInteger is probably prime,
      * {@code false} if it's definitely composite.  If
-     * {@code certainty} is {@code  <= 0}, {@code true} is
+     * {@code certainty} is &le; 0, {@code true} is
      * returned.
      *
      * @param  certainty a measure of the uncertainty that the caller is
--- a/src/share/classes/java/net/CookieHandler.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/net/CookieHandler.java	Wed Nov 25 11:08:25 2009 -0800
@@ -101,11 +101,21 @@
      * Gets all the applicable cookies from a cookie cache for the
      * specified uri in the request header.
      *
-     * HTTP protocol implementers should make sure that this method is
+     * <P>The {@code URI} passed as an argument specifies the intended use for
+     * the cookies. In particular the scheme should reflect whether the cookies
+     * will be sent over http, https or used in another context like javascript.
+     * The host part should reflect either the destination of the cookies or
+     * their origin in the case of javascript.</P>
+     * <P>It is up to the implementation to take into account the {@code URI} and
+     * the cookies attributes and security settings to determine which ones
+     * should be returned.</P>
+     *
+     * <P>HTTP protocol implementers should make sure that this method is
      * called after all request headers related to choosing cookies
-     * are added, and before the request is sent.
+     * are added, and before the request is sent.</P>
      *
-     * @param uri a <code>URI</code> to send cookies to in a request
+     * @param uri a <code>URI</code> representing the intended use for the
+     *            cookies
      * @param requestHeaders - a Map from request header
      *            field names to lists of field values representing
      *            the current request headers
--- a/src/share/classes/java/net/CookieManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/net/CookieManager.java	Wed Nov 25 11:08:25 2009 -0800
@@ -218,6 +218,13 @@
             // 'secure' cookies over unsecure links)
             if (pathMatches(path, cookie.getPath()) &&
                     (secureLink || !cookie.getSecure())) {
+                // Enforce httponly attribute
+                if (cookie.isHttpOnly()) {
+                    String s = uri.getScheme();
+                    if (!"http".equalsIgnoreCase(s) && !"https".equalsIgnoreCase(s)) {
+                        continue;
+                    }
+                }
                 // Let's check the authorize port list if it exists
                 String ports = cookie.getPortlist();
                 if (ports != null && !ports.isEmpty()) {
--- a/src/share/classes/java/security/MessageDigest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/security/MessageDigest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-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
@@ -414,16 +414,17 @@
      *
      * @return true if the digests are equal, false otherwise.
      */
-    public static boolean isEqual(byte digesta[], byte digestb[]) {
-        if (digesta.length != digestb.length)
+    public static boolean isEqual(byte[] digesta, byte[] digestb) {
+        if (digesta.length != digestb.length) {
             return false;
+        }
 
+        int result = 0;
+        // time-constant comparison
         for (int i = 0; i < digesta.length; i++) {
-            if (digesta[i] != digestb[i]) {
-                return false;
-            }
+            result |= digesta[i] ^ digestb[i];
         }
-        return true;
+        return result == 0;
     }
 
     /**
--- a/src/share/classes/java/util/Arrays.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/Arrays.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -29,1047 +29,353 @@
 
 /**
  * This class contains various methods for manipulating arrays (such as
- * sorting and searching).  This class also contains a static factory
+ * sorting and searching). This class also contains a static factory
  * that allows arrays to be viewed as lists.
  *
- * <p>The methods in this class all throw a <tt>NullPointerException</tt> if
- * the specified array reference is null, except where noted.
+ * <p>The methods in this class all throw a {@code NullPointerException},
+ * if the specified array reference is null, except where noted.
  *
  * <p>The documentation for the methods contained in this class includes
- * briefs description of the <i>implementations</i>.  Such descriptions should
+ * briefs description of the <i>implementations</i>. Such descriptions should
  * be regarded as <i>implementation notes</i>, rather than parts of the
- * <i>specification</i>.  Implementors should feel free to substitute other
- * algorithms, so long as the specification itself is adhered to.  (For
- * example, the algorithm used by <tt>sort(Object[])</tt> does not have to be
- * a mergesort, but it does have to be <i>stable</i>.)
+ * <i>specification</i>. Implementors should feel free to substitute other
+ * algorithms, so long as the specification itself is adhered to. (For
+ * example, the algorithm used by {@code sort(Object[])} does not have to be
+ * a MergeSort, but it does have to be <i>stable</i>.)
  *
  * <p>This class is a member of the
  * <a href="{@docRoot}/../technotes/guides/collections/index.html">
  * Java Collections Framework</a>.
  *
- * @author  Josh Bloch
- * @author  Neal Gafter
- * @author  John Rose
- * @since   1.2
+ * @author Josh Bloch
+ * @author Neal Gafter
+ * @author John Rose
+ * @since  1.2
  */
-
 public class Arrays {
-    // Suppresses default constructor, ensuring non-instantiability.
-    private Arrays() {
-    }
-
-    // Sorting
 
-    /**
-     * Sorts the specified array of longs into ascending numerical order.
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
-     *
-     * @param a the array to be sorted
+    // Suppresses default constructor, ensuring non-instantiability.
+    private Arrays() {}
+
+    /*
+     * Sorting of primitive type arrays.
      */
-    public static void sort(long[] a) {
-        sort1(a, 0, a.length);
-    }
 
     /**
-     * Sorts the specified range of the specified array of longs into
-     * ascending numerical order.  The range to be sorted extends from index
-     * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
-     * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)
-     *
-     * <p>The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * Sorts the specified array into ascending numerical order.
      *
-     * @param a the array to be sorted
-     * @param fromIndex the index of the first element (inclusive) to be
-     *        sorted
-     * @param toIndex the index of the last element (exclusive) to be sorted
-     * @throws IllegalArgumentException if <tt>fromIndex &gt; toIndex</tt>
-     * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex &lt; 0</tt> or
-     * <tt>toIndex &gt; a.length</tt>
-     */
-    public static void sort(long[] a, int fromIndex, int toIndex) {
-        rangeCheck(a.length, fromIndex, toIndex);
-        sort1(a, fromIndex, toIndex-fromIndex);
-    }
-
-    /**
-     * Sorts the specified array of ints into ascending numerical order.
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
      */
     public static void sort(int[] a) {
-        sort1(a, 0, a.length);
+        DualPivotQuicksort.sort(a);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     *
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(int[] a, int fromIndex, int toIndex) {
+        DualPivotQuicksort.sort(a, fromIndex, toIndex);
     }
 
     /**
-     * Sorts the specified range of the specified array of ints into
-     * ascending numerical order.  The range to be sorted extends from index
-     * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
-     * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)<p>
+     * Sorts the specified array into ascending numerical order.
      *
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
-     * @param fromIndex the index of the first element (inclusive) to be
-     *        sorted
-     * @param toIndex the index of the last element (exclusive) to be sorted
-     * @throws IllegalArgumentException if <tt>fromIndex &gt; toIndex</tt>
-     * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex &lt; 0</tt> or
-     *         <tt>toIndex &gt; a.length</tt>
      */
-    public static void sort(int[] a, int fromIndex, int toIndex) {
-        rangeCheck(a.length, fromIndex, toIndex);
-        sort1(a, fromIndex, toIndex-fromIndex);
+    public static void sort(long[] a) {
+        DualPivotQuicksort.sort(a);
     }
 
     /**
-     * Sorts the specified array of shorts into ascending numerical order.
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     *
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(long[] a, int fromIndex, int toIndex) {
+        DualPivotQuicksort.sort(a, fromIndex, toIndex);
+    }
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
      */
     public static void sort(short[] a) {
-        sort1(a, 0, a.length);
+        DualPivotQuicksort.sort(a);
     }
 
     /**
-     * Sorts the specified range of the specified array of shorts into
-     * ascending numerical order.  The range to be sorted extends from index
-     * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
-     * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)<p>
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
      *
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
-     * @param fromIndex the index of the first element (inclusive) to be
-     *        sorted
-     * @param toIndex the index of the last element (exclusive) to be sorted
-     * @throws IllegalArgumentException if <tt>fromIndex &gt; toIndex</tt>
-     * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex &lt; 0</tt> or
-     *         <tt>toIndex &gt; a.length</tt>
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     *
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
      */
     public static void sort(short[] a, int fromIndex, int toIndex) {
-        rangeCheck(a.length, fromIndex, toIndex);
-        sort1(a, fromIndex, toIndex-fromIndex);
+        DualPivotQuicksort.sort(a, fromIndex, toIndex);
     }
 
     /**
-     * Sorts the specified array of chars into ascending numerical order.
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * Sorts the specified array into ascending numerical order.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
      */
     public static void sort(char[] a) {
-        sort1(a, 0, a.length);
+        DualPivotQuicksort.sort(a);
     }
 
     /**
-     * Sorts the specified range of the specified array of chars into
-     * ascending numerical order.  The range to be sorted extends from index
-     * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
-     * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)<p>
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
      *
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
-     * @param fromIndex the index of the first element (inclusive) to be
-     *        sorted
-     * @param toIndex the index of the last element (exclusive) to be sorted
-     * @throws IllegalArgumentException if <tt>fromIndex &gt; toIndex</tt>
-     * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex &lt; 0</tt> or
-     *         <tt>toIndex &gt; a.length</tt>
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     *
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
      */
     public static void sort(char[] a, int fromIndex, int toIndex) {
-        rangeCheck(a.length, fromIndex, toIndex);
-        sort1(a, fromIndex, toIndex-fromIndex);
+        DualPivotQuicksort.sort(a, fromIndex, toIndex);
     }
 
     /**
-     * Sorts the specified array of bytes into ascending numerical order.
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * Sorts the specified array into ascending numerical order.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
      */
     public static void sort(byte[] a) {
-        sort1(a, 0, a.length);
-    }
-
-    /**
-     * Sorts the specified range of the specified array of bytes into
-     * ascending numerical order.  The range to be sorted extends from index
-     * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
-     * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)<p>
-     *
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
-     *
-     * @param a the array to be sorted
-     * @param fromIndex the index of the first element (inclusive) to be
-     *        sorted
-     * @param toIndex the index of the last element (exclusive) to be sorted
-     * @throws IllegalArgumentException if <tt>fromIndex &gt; toIndex</tt>
-     * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex &lt; 0</tt> or
-     *         <tt>toIndex &gt; a.length</tt>
-     */
-    public static void sort(byte[] a, int fromIndex, int toIndex) {
-        rangeCheck(a.length, fromIndex, toIndex);
-        sort1(a, fromIndex, toIndex-fromIndex);
-    }
-
-    /**
-     * Sorts the specified array of doubles into ascending numerical order.
-     * <p>
-     * The <code>&lt;</code> relation does not provide a total order on
-     * all floating-point values; although they are distinct numbers
-     * <code>-0.0 == 0.0</code> is <code>true</code> and a NaN value
-     * compares neither less than, greater than, nor equal to any
-     * floating-point value, even itself.  To allow the sort to
-     * proceed, instead of using the <code>&lt;</code> relation to
-     * determine ascending numerical order, this method uses the total
-     * order imposed by {@link Double#compareTo}.  This ordering
-     * differs from the <code>&lt;</code> relation in that
-     * <code>-0.0</code> is treated as less than <code>0.0</code> and
-     * NaN is considered greater than any other floating-point value.
-     * For the purposes of sorting, all NaN values are considered
-     * equivalent and equal.
-     * <p>
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
-     *
-     * @param a the array to be sorted
-     */
-    public static void sort(double[] a) {
-        sort2(a, 0, a.length);
+        DualPivotQuicksort.sort(a);
     }
 
     /**
-     * Sorts the specified range of the specified array of doubles into
-     * ascending numerical order.  The range to be sorted extends from index
-     * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
-     * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)
-     * <p>
-     * The <code>&lt;</code> relation does not provide a total order on
-     * all floating-point values; although they are distinct numbers
-     * <code>-0.0 == 0.0</code> is <code>true</code> and a NaN value
-     * compares neither less than, greater than, nor equal to any
-     * floating-point value, even itself.  To allow the sort to
-     * proceed, instead of using the <code>&lt;</code> relation to
-     * determine ascending numerical order, this method uses the total
-     * order imposed by {@link Double#compareTo}.  This ordering
-     * differs from the <code>&lt;</code> relation in that
-     * <code>-0.0</code> is treated as less than <code>0.0</code> and
-     * NaN is considered greater than any other floating-point value.
-     * For the purposes of sorting, all NaN values are considered
-     * equivalent and equal.
-     * <p>
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
-     * @param fromIndex the index of the first element (inclusive) to be
-     *        sorted
-     * @param toIndex the index of the last element (exclusive) to be sorted
-     * @throws IllegalArgumentException if <tt>fromIndex &gt; toIndex</tt>
-     * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex &lt; 0</tt> or
-     *         <tt>toIndex &gt; a.length</tt>
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     *
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
      */
-    public static void sort(double[] a, int fromIndex, int toIndex) {
-        rangeCheck(a.length, fromIndex, toIndex);
-        sort2(a, fromIndex, toIndex);
+    public static void sort(byte[] a, int fromIndex, int toIndex) {
+        DualPivotQuicksort.sort(a, fromIndex, toIndex);
     }
 
     /**
-     * Sorts the specified array of floats into ascending numerical order.
-     * <p>
-     * The <code>&lt;</code> relation does not provide a total order on
-     * all floating-point values; although they are distinct numbers
-     * <code>-0.0f == 0.0f</code> is <code>true</code> and a NaN value
-     * compares neither less than, greater than, nor equal to any
-     * floating-point value, even itself.  To allow the sort to
-     * proceed, instead of using the <code>&lt;</code> relation to
-     * determine ascending numerical order, this method uses the total
-     * order imposed by {@link Float#compareTo}.  This ordering
-     * differs from the <code>&lt;</code> relation in that
-     * <code>-0.0f</code> is treated as less than <code>0.0f</code> and
-     * NaN is considered greater than any other floating-point value.
-     * For the purposes of sorting, all NaN values are considered
-     * equivalent and equal.
-     * <p>
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * Sorts the specified array into ascending numerical order.
+     *
+     * <p>The {@code <} relation does not provide a total order on all float
+     * values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Float#compareTo}: {@code -0.0f} is treated as less than value
+     * {@code 0.0f} and {@code Float.NaN} is considered greater than any
+     * other value and all {@code Float.NaN} values are considered equal.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
      */
     public static void sort(float[] a) {
-        sort2(a, 0, a.length);
+        DualPivotQuicksort.sort(a);
     }
 
     /**
-     * Sorts the specified range of the specified array of floats into
-     * ascending numerical order.  The range to be sorted extends from index
-     * <tt>fromIndex</tt>, inclusive, to index <tt>toIndex</tt>, exclusive.
-     * (If <tt>fromIndex==toIndex</tt>, the range to be sorted is empty.)
-     * <p>
-     * The <code>&lt;</code> relation does not provide a total order on
-     * all floating-point values; although they are distinct numbers
-     * <code>-0.0f == 0.0f</code> is <code>true</code> and a NaN value
-     * compares neither less than, greater than, nor equal to any
-     * floating-point value, even itself.  To allow the sort to
-     * proceed, instead of using the <code>&lt;</code> relation to
-     * determine ascending numerical order, this method uses the total
-     * order imposed by {@link Float#compareTo}.  This ordering
-     * differs from the <code>&lt;</code> relation in that
-     * <code>-0.0f</code> is treated as less than <code>0.0f</code> and
-     * NaN is considered greater than any other floating-point value.
-     * For the purposes of sorting, all NaN values are considered
-     * equivalent and equal.
-     * <p>
-     * The sorting algorithm is a tuned quicksort, adapted from Jon
-     * L. Bentley and M. Douglas McIlroy's "Engineering a Sort Function",
-     * Software-Practice and Experience, Vol. 23(11) P. 1249-1265 (November
-     * 1993).  This algorithm offers n*log(n) performance on many data sets
-     * that cause other quicksorts to degrade to quadratic performance.
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * <p>The {@code <} relation does not provide a total order on all float
+     * values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Float#compareTo}: {@code -0.0f} is treated as less than value
+     * {@code 0.0f} and {@code Float.NaN} is considered greater than any
+     * other value and all {@code Float.NaN} values are considered equal.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
      *
      * @param a the array to be sorted
-     * @param fromIndex the index of the first element (inclusive) to be
-     *        sorted
-     * @param toIndex the index of the last element (exclusive) to be sorted
-     * @throws IllegalArgumentException if <tt>fromIndex &gt; toIndex</tt>
-     * @throws ArrayIndexOutOfBoundsException if <tt>fromIndex &lt; 0</tt> or
-     *         <tt>toIndex &gt; a.length</tt>
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     *
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
      */
     public static void sort(float[] a, int fromIndex, int toIndex) {
-        rangeCheck(a.length, fromIndex, toIndex);
-        sort2(a, fromIndex, toIndex);
-    }
-
-    private static void sort2(double a[], int fromIndex, int toIndex) {
-        final long NEG_ZERO_BITS = Double.doubleToLongBits(-0.0d);
-        /*
-         * The sort is done in three phases to avoid the expense of using
-         * NaN and -0.0 aware comparisons during the main sort.
-         */
-
-        /*
-         * Preprocessing phase:  Move any NaN's to end of array, count the
-         * number of -0.0's, and turn them into 0.0's.
-         */
-        int numNegZeros = 0;
-        int i = fromIndex, n = toIndex;
-        while(i < n) {
-            if (a[i] != a[i]) {
-                swap(a, i, --n);
-            } else {
-                if (a[i]==0 && Double.doubleToLongBits(a[i])==NEG_ZERO_BITS) {
-                    a[i] = 0.0d;
-                    numNegZeros++;
-                }
-                i++;
-            }
-        }
-
-        // Main sort phase: quicksort everything but the NaN's
-        sort1(a, fromIndex, n-fromIndex);
-
-        // Postprocessing phase: change 0.0's to -0.0's as required
-        if (numNegZeros != 0) {
-            int j = binarySearch0(a, fromIndex, n, 0.0d); // posn of ANY zero
-            do {
-                j--;
-            } while (j>=fromIndex && a[j]==0.0d);
-
-            // j is now one less than the index of the FIRST zero
-            for (int k=0; k<numNegZeros; k++)
-                a[++j] = -0.0d;
-        }
-    }
-
-
-    private static void sort2(float a[], int fromIndex, int toIndex) {
-        final int NEG_ZERO_BITS = Float.floatToIntBits(-0.0f);
-        /*
-         * The sort is done in three phases to avoid the expense of using
-         * NaN and -0.0 aware comparisons during the main sort.
-         */
-
-        /*
-         * Preprocessing phase:  Move any NaN's to end of array, count the
-         * number of -0.0's, and turn them into 0.0's.
-         */
-        int numNegZeros = 0;
-        int i = fromIndex, n = toIndex;
-        while(i < n) {
-            if (a[i] != a[i]) {
-                swap(a, i, --n);
-            } else {
-                if (a[i]==0 && Float.floatToIntBits(a[i])==NEG_ZERO_BITS) {
-                    a[i] = 0.0f;
-                    numNegZeros++;
-                }
-                i++;
-            }
-        }
-
-        // Main sort phase: quicksort everything but the NaN's
-        sort1(a, fromIndex, n-fromIndex);
-
-        // Postprocessing phase: change 0.0's to -0.0's as required
-        if (numNegZeros != 0) {
-            int j = binarySearch0(a, fromIndex, n, 0.0f); // posn of ANY zero
-            do {
-                j--;
-            } while (j>=fromIndex && a[j]==0.0f);
-
-            // j is now one less than the index of the FIRST zero
-            for (int k=0; k<numNegZeros; k++)
-                a[++j] = -0.0f;
-        }
-    }
-
-
-    /*
-     * The code for each of the seven primitive types is largely identical.
-     * C'est la vie.
-     */
-
-    /**
-     * Sorts the specified sub-array of longs into ascending order.
-     */
-    private static void sort1(long x[], int off, int len) {
-        // Insertion sort on smallest arrays
-        if (len < 7) {
-            for (int i=off; i<len+off; i++)
-                for (int j=i; j>off && x[j-1]>x[j]; j--)
-                    swap(x, j, j-1);
-            return;
-        }
-
-        // Choose a partition element, v
-        int m = off + (len >> 1);       // Small arrays, middle element
-        if (len > 7) {
-            int l = off;
-            int n = off + len - 1;
-            if (len > 40) {        // Big arrays, pseudomedian of 9
-                int s = len/8;
-                l = med3(x, l,     l+s, l+2*s);
-                m = med3(x, m-s,   m,   m+s);
-                n = med3(x, n-2*s, n-s, n);
-            }
-            m = med3(x, l, m, n); // Mid-size, med of 3
-        }
-        long v = x[m];
-
-        // Establish Invariant: v* (<v)* (>v)* v*
-        int a = off, b = a, c = off + len - 1, d = c;
-        while(true) {
-            while (b <= c && x[b] <= v) {
-                if (x[b] == v)
-                    swap(x, a++, b);
-                b++;
-            }
-            while (c >= b && x[c] >= v) {
-                if (x[c] == v)
-                    swap(x, c, d--);
-                c--;
-            }
-            if (b > c)
-                break;
-            swap(x, b++, c--);
-        }
-
-        // Swap partition elements back to middle
-        int s, n = off + len;
-        s = Math.min(a-off, b-a  );  vecswap(x, off, b-s, s);
-        s = Math.min(d-c,   n-d-1);  vecswap(x, b,   n-s, s);
-
-        // Recursively sort non-partition-elements
-        if ((s = b-a) > 1)
-            sort1(x, off, s);
-        if ((s = d-c) > 1)
-            sort1(x, n-s, s);
-    }
-
-    /**
-     * Swaps x[a] with x[b].
-     */
-    private static void swap(long x[], int a, int b) {
-        long t = x[a];
-        x[a] = x[b];
-        x[b] = t;
-    }
-
-    /**
-     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
-     */
-    private static void vecswap(long x[], int a, int b, int n) {
-        for (int i=0; i<n; i++, a++, b++)
-            swap(x, a, b);
-    }
-
-    /**
-     * Returns the index of the median of the three indexed longs.
-     */
-    private static int med3(long x[], int a, int b, int c) {
-        return (x[a] < x[b] ?
-                (x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
-                (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
-    }
-
-    /**
-     * Sorts the specified sub-array of integers into ascending order.
-     */
-    private static void sort1(int x[], int off, int len) {
-        // Insertion sort on smallest arrays
-        if (len < 7) {
-            for (int i=off; i<len+off; i++)
-                for (int j=i; j>off && x[j-1]>x[j]; j--)
-                    swap(x, j, j-1);
-            return;
-        }
-
-        // Choose a partition element, v
-        int m = off + (len >> 1);       // Small arrays, middle element
-        if (len > 7) {
-            int l = off;
-            int n = off + len - 1;
-            if (len > 40) {        // Big arrays, pseudomedian of 9
-                int s = len/8;
-                l = med3(x, l,     l+s, l+2*s);
-                m = med3(x, m-s,   m,   m+s);
-                n = med3(x, n-2*s, n-s, n);
-            }
-            m = med3(x, l, m, n); // Mid-size, med of 3
-        }
-        int v = x[m];
-
-        // Establish Invariant: v* (<v)* (>v)* v*
-        int a = off, b = a, c = off + len - 1, d = c;
-        while(true) {
-            while (b <= c && x[b] <= v) {
-                if (x[b] == v)
-                    swap(x, a++, b);
-                b++;
-            }
-            while (c >= b && x[c] >= v) {
-                if (x[c] == v)
-                    swap(x, c, d--);
-                c--;
-            }
-            if (b > c)
-                break;
-            swap(x, b++, c--);
-        }
-
-        // Swap partition elements back to middle
-        int s, n = off + len;
-        s = Math.min(a-off, b-a  );  vecswap(x, off, b-s, s);
-        s = Math.min(d-c,   n-d-1);  vecswap(x, b,   n-s, s);
-
-        // Recursively sort non-partition-elements
-        if ((s = b-a) > 1)
-            sort1(x, off, s);
-        if ((s = d-c) > 1)
-            sort1(x, n-s, s);
-    }
-
-    /**
-     * Swaps x[a] with x[b].
-     */
-    private static void swap(int x[], int a, int b) {
-        int t = x[a];
-        x[a] = x[b];
-        x[b] = t;
-    }
-
-    /**
-     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
-     */
-    private static void vecswap(int x[], int a, int b, int n) {
-        for (int i=0; i<n; i++, a++, b++)
-            swap(x, a, b);
-    }
-
-    /**
-     * Returns the index of the median of the three indexed integers.
-     */
-    private static int med3(int x[], int a, int b, int c) {
-        return (x[a] < x[b] ?
-                (x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
-                (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
-    }
-
-    /**
-     * Sorts the specified sub-array of shorts into ascending order.
-     */
-    private static void sort1(short x[], int off, int len) {
-        // Insertion sort on smallest arrays
-        if (len < 7) {
-            for (int i=off; i<len+off; i++)
-                for (int j=i; j>off && x[j-1]>x[j]; j--)
-                    swap(x, j, j-1);
-            return;
-        }
-
-        // Choose a partition element, v
-        int m = off + (len >> 1);       // Small arrays, middle element
-        if (len > 7) {
-            int l = off;
-            int n = off + len - 1;
-            if (len > 40) {        // Big arrays, pseudomedian of 9
-                int s = len/8;
-                l = med3(x, l,     l+s, l+2*s);
-                m = med3(x, m-s,   m,   m+s);
-                n = med3(x, n-2*s, n-s, n);
-            }
-            m = med3(x, l, m, n); // Mid-size, med of 3
-        }
-        short v = x[m];
-
-        // Establish Invariant: v* (<v)* (>v)* v*
-        int a = off, b = a, c = off + len - 1, d = c;
-        while(true) {
-            while (b <= c && x[b] <= v) {
-                if (x[b] == v)
-                    swap(x, a++, b);
-                b++;
-            }
-            while (c >= b && x[c] >= v) {
-                if (x[c] == v)
-                    swap(x, c, d--);
-                c--;
-            }
-            if (b > c)
-                break;
-            swap(x, b++, c--);
-        }
-
-        // Swap partition elements back to middle
-        int s, n = off + len;
-        s = Math.min(a-off, b-a  );  vecswap(x, off, b-s, s);
-        s = Math.min(d-c,   n-d-1);  vecswap(x, b,   n-s, s);
-
-        // Recursively sort non-partition-elements
-        if ((s = b-a) > 1)
-            sort1(x, off, s);
-        if ((s = d-c) > 1)
-            sort1(x, n-s, s);
+        DualPivotQuicksort.sort(a, fromIndex, toIndex);
     }
 
     /**
-     * Swaps x[a] with x[b].
-     */
-    private static void swap(short x[], int a, int b) {
-        short t = x[a];
-        x[a] = x[b];
-        x[b] = t;
-    }
-
-    /**
-     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
-     */
-    private static void vecswap(short x[], int a, int b, int n) {
-        for (int i=0; i<n; i++, a++, b++)
-            swap(x, a, b);
-    }
-
-    /**
-     * Returns the index of the median of the three indexed shorts.
-     */
-    private static int med3(short x[], int a, int b, int c) {
-        return (x[a] < x[b] ?
-                (x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
-                (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
-    }
-
-
-    /**
-     * Sorts the specified sub-array of chars into ascending order.
-     */
-    private static void sort1(char x[], int off, int len) {
-        // Insertion sort on smallest arrays
-        if (len < 7) {
-            for (int i=off; i<len+off; i++)
-                for (int j=i; j>off && x[j-1]>x[j]; j--)
-                    swap(x, j, j-1);
-            return;
-        }
-
-        // Choose a partition element, v
-        int m = off + (len >> 1);       // Small arrays, middle element
-        if (len > 7) {
-            int l = off;
-            int n = off + len - 1;
-            if (len > 40) {        // Big arrays, pseudomedian of 9
-                int s = len/8;
-                l = med3(x, l,     l+s, l+2*s);
-                m = med3(x, m-s,   m,   m+s);
-                n = med3(x, n-2*s, n-s, n);
-            }
-            m = med3(x, l, m, n); // Mid-size, med of 3
-        }
-        char v = x[m];
-
-        // Establish Invariant: v* (<v)* (>v)* v*
-        int a = off, b = a, c = off + len - 1, d = c;
-        while(true) {
-            while (b <= c && x[b] <= v) {
-                if (x[b] == v)
-                    swap(x, a++, b);
-                b++;
-            }
-            while (c >= b && x[c] >= v) {
-                if (x[c] == v)
-                    swap(x, c, d--);
-                c--;
-            }
-            if (b > c)
-                break;
-            swap(x, b++, c--);
-        }
-
-        // Swap partition elements back to middle
-        int s, n = off + len;
-        s = Math.min(a-off, b-a  );  vecswap(x, off, b-s, s);
-        s = Math.min(d-c,   n-d-1);  vecswap(x, b,   n-s, s);
-
-        // Recursively sort non-partition-elements
-        if ((s = b-a) > 1)
-            sort1(x, off, s);
-        if ((s = d-c) > 1)
-            sort1(x, n-s, s);
-    }
-
-    /**
-     * Swaps x[a] with x[b].
+     * Sorts the specified array into ascending numerical order.
+     *
+     * <p>The {@code <} relation does not provide a total order on all double
+     * values: {@code -0.0d == 0.0d} is {@code true} and a {@code Double.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Double#compareTo}: {@code -0.0d} is treated as less than value
+     * {@code 0.0d} and {@code Double.NaN} is considered greater than any
+     * other value and all {@code Double.NaN} values are considered equal.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
+     *
+     * @param a the array to be sorted
      */
-    private static void swap(char x[], int a, int b) {
-        char t = x[a];
-        x[a] = x[b];
-        x[b] = t;
-    }
-
-    /**
-     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
-     */
-    private static void vecswap(char x[], int a, int b, int n) {
-        for (int i=0; i<n; i++, a++, b++)
-            swap(x, a, b);
-    }
-
-    /**
-     * Returns the index of the median of the three indexed chars.
-     */
-    private static int med3(char x[], int a, int b, int c) {
-        return (x[a] < x[b] ?
-                (x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
-                (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
-    }
-
-
-    /**
-     * Sorts the specified sub-array of bytes into ascending order.
-     */
-    private static void sort1(byte x[], int off, int len) {
-        // Insertion sort on smallest arrays
-        if (len < 7) {
-            for (int i=off; i<len+off; i++)
-                for (int j=i; j>off && x[j-1]>x[j]; j--)
-                    swap(x, j, j-1);
-            return;
-        }
-
-        // Choose a partition element, v
-        int m = off + (len >> 1);       // Small arrays, middle element
-        if (len > 7) {
-            int l = off;
-            int n = off + len - 1;
-            if (len > 40) {        // Big arrays, pseudomedian of 9
-                int s = len/8;
-                l = med3(x, l,     l+s, l+2*s);
-                m = med3(x, m-s,   m,   m+s);
-                n = med3(x, n-2*s, n-s, n);
-            }
-            m = med3(x, l, m, n); // Mid-size, med of 3
-        }
-        byte v = x[m];
-
-        // Establish Invariant: v* (<v)* (>v)* v*
-        int a = off, b = a, c = off + len - 1, d = c;
-        while(true) {
-            while (b <= c && x[b] <= v) {
-                if (x[b] == v)
-                    swap(x, a++, b);
-                b++;
-            }
-            while (c >= b && x[c] >= v) {
-                if (x[c] == v)
-                    swap(x, c, d--);
-                c--;
-            }
-            if (b > c)
-                break;
-            swap(x, b++, c--);
-        }
-
-        // Swap partition elements back to middle
-        int s, n = off + len;
-        s = Math.min(a-off, b-a  );  vecswap(x, off, b-s, s);
-        s = Math.min(d-c,   n-d-1);  vecswap(x, b,   n-s, s);
-
-        // Recursively sort non-partition-elements
-        if ((s = b-a) > 1)
-            sort1(x, off, s);
-        if ((s = d-c) > 1)
-            sort1(x, n-s, s);
-    }
-
-    /**
-     * Swaps x[a] with x[b].
-     */
-    private static void swap(byte x[], int a, int b) {
-        byte t = x[a];
-        x[a] = x[b];
-        x[b] = t;
+    public static void sort(double[] a) {
+        DualPivotQuicksort.sort(a);
     }
 
     /**
-     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
-     */
-    private static void vecswap(byte x[], int a, int b, int n) {
-        for (int i=0; i<n; i++, a++, b++)
-            swap(x, a, b);
-    }
-
-    /**
-     * Returns the index of the median of the three indexed bytes.
-     */
-    private static int med3(byte x[], int a, int b, int c) {
-        return (x[a] < x[b] ?
-                (x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
-                (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
-    }
-
-
-    /**
-     * Sorts the specified sub-array of doubles into ascending order.
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * <p>The {@code <} relation does not provide a total order on all double
+     * values: {@code -0.0d == 0.0d} is {@code true} and a {@code Double.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Double#compareTo}: {@code -0.0d} is treated as less than value
+     * {@code 0.0d} and {@code Double.NaN} is considered greater than any
+     * other value and all {@code Double.NaN} values are considered equal.
+     *
+     * <p>Implementation note: The sorting algorithm is a Dual-Pivot Quicksort
+     * by Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. This algorithm
+     * offers O(n log(n)) performance on many data sets that cause other
+     * quicksorts to degrade to quadratic performance, and is typically
+     * faster than traditional (one-pivot) Quicksort implementations.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     *
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
      */
-    private static void sort1(double x[], int off, int len) {
-        // Insertion sort on smallest arrays
-        if (len < 7) {
-            for (int i=off; i<len+off; i++)
-                for (int j=i; j>off && x[j-1]>x[j]; j--)
-                    swap(x, j, j-1);
-            return;
-        }
-
-        // Choose a partition element, v
-        int m = off + (len >> 1);       // Small arrays, middle element
-        if (len > 7) {
-            int l = off;
-            int n = off + len - 1;
-            if (len > 40) {        // Big arrays, pseudomedian of 9
-                int s = len/8;
-                l = med3(x, l,     l+s, l+2*s);
-                m = med3(x, m-s,   m,   m+s);
-                n = med3(x, n-2*s, n-s, n);
-            }
-            m = med3(x, l, m, n); // Mid-size, med of 3
-        }
-        double v = x[m];
-
-        // Establish Invariant: v* (<v)* (>v)* v*
-        int a = off, b = a, c = off + len - 1, d = c;
-        while(true) {
-            while (b <= c && x[b] <= v) {
-                if (x[b] == v)
-                    swap(x, a++, b);
-                b++;
-            }
-            while (c >= b && x[c] >= v) {
-                if (x[c] == v)
-                    swap(x, c, d--);
-                c--;
-            }
-            if (b > c)
-                break;
-            swap(x, b++, c--);
-        }
-
-        // Swap partition elements back to middle
-        int s, n = off + len;
-        s = Math.min(a-off, b-a  );  vecswap(x, off, b-s, s);
-        s = Math.min(d-c,   n-d-1);  vecswap(x, b,   n-s, s);
-
-        // Recursively sort non-partition-elements
-        if ((s = b-a) > 1)
-            sort1(x, off, s);
-        if ((s = d-c) > 1)
-            sort1(x, n-s, s);
-    }
-
-    /**
-     * Swaps x[a] with x[b].
-     */
-    private static void swap(double x[], int a, int b) {
-        double t = x[a];
-        x[a] = x[b];
-        x[b] = t;
-    }
-
-    /**
-     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
-     */
-    private static void vecswap(double x[], int a, int b, int n) {
-        for (int i=0; i<n; i++, a++, b++)
-            swap(x, a, b);
+    public static void sort(double[] a, int fromIndex, int toIndex) {
+        DualPivotQuicksort.sort(a, fromIndex, toIndex);
     }
 
-    /**
-     * Returns the index of the median of the three indexed doubles.
-     */
-    private static int med3(double x[], int a, int b, int c) {
-        return (x[a] < x[b] ?
-                (x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
-                (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
-    }
-
-
-    /**
-     * Sorts the specified sub-array of floats into ascending order.
+    /*
+     * Sorting of complex type arrays.
+     *
      */
-    private static void sort1(float x[], int off, int len) {
-        // Insertion sort on smallest arrays
-        if (len < 7) {
-            for (int i=off; i<len+off; i++)
-                for (int j=i; j>off && x[j-1]>x[j]; j--)
-                    swap(x, j, j-1);
-            return;
-        }
-
-        // Choose a partition element, v
-        int m = off + (len >> 1);       // Small arrays, middle element
-        if (len > 7) {
-            int l = off;
-            int n = off + len - 1;
-            if (len > 40) {        // Big arrays, pseudomedian of 9
-                int s = len/8;
-                l = med3(x, l,     l+s, l+2*s);
-                m = med3(x, m-s,   m,   m+s);
-                n = med3(x, n-2*s, n-s, n);
-            }
-            m = med3(x, l, m, n); // Mid-size, med of 3
-        }
-        float v = x[m];
-
-        // Establish Invariant: v* (<v)* (>v)* v*
-        int a = off, b = a, c = off + len - 1, d = c;
-        while(true) {
-            while (b <= c && x[b] <= v) {
-                if (x[b] == v)
-                    swap(x, a++, b);
-                b++;
-            }
-            while (c >= b && x[c] >= v) {
-                if (x[c] == v)
-                    swap(x, c, d--);
-                c--;
-            }
-            if (b > c)
-                break;
-            swap(x, b++, c--);
-        }
-
-        // Swap partition elements back to middle
-        int s, n = off + len;
-        s = Math.min(a-off, b-a  );  vecswap(x, off, b-s, s);
-        s = Math.min(d-c,   n-d-1);  vecswap(x, b,   n-s, s);
-
-        // Recursively sort non-partition-elements
-        if ((s = b-a) > 1)
-            sort1(x, off, s);
-        if ((s = d-c) > 1)
-            sort1(x, n-s, s);
-    }
-
-    /**
-     * Swaps x[a] with x[b].
-     */
-    private static void swap(float x[], int a, int b) {
-        float t = x[a];
-        x[a] = x[b];
-        x[b] = t;
-    }
-
-    /**
-     * Swaps x[a .. (a+n-1)] with x[b .. (b+n-1)].
-     */
-    private static void vecswap(float x[], int a, int b, int n) {
-        for (int i=0; i<n; i++, a++, b++)
-            swap(x, a, b);
-    }
-
-    /**
-     * Returns the index of the median of the three indexed floats.
-     */
-    private static int med3(float x[], int a, int b, int c) {
-        return (x[a] < x[b] ?
-                (x[b] < x[c] ? b : x[a] < x[c] ? c : a) :
-                (x[b] > x[c] ? b : x[a] > x[c] ? c : a));
-    }
 
     /**
      * Old merge sort implementation can be selected (for
      * compatibility with broken comparators) using a system property.
      * Cannot be a static boolean in the enclosing class due to
-     * circular dependencies.  To be removed in a future release.
+     * circular dependencies. To be removed in a future release.
      */
     static final class LegacyMergeSort {
         private static final boolean userRequested =
@@ -1235,7 +541,7 @@
 
     /**
      * Tuning parameter: list size at or below which insertion sort will be
-     * used in preference to mergesort or quicksort.
+     * used in preference to mergesort.
      * To be removed in a future release.
      */
     private static final int INSERTIONSORT_THRESHOLD = 7;
@@ -1474,17 +780,20 @@
     }
 
     /**
-     * Check that fromIndex and toIndex are in range, and throw an
-     * appropriate exception if they aren't.
+     * Checks that {@code fromIndex} and {@code toIndex} are in
+     * the range and throws an appropriate exception, if they aren't.
      */
-    private static void rangeCheck(int arrayLen, int fromIndex, int toIndex) {
-        if (fromIndex > toIndex)
-            throw new IllegalArgumentException("fromIndex(" + fromIndex +
-                       ") > toIndex(" + toIndex+")");
-        if (fromIndex < 0)
+    private static void rangeCheck(int length, int fromIndex, int toIndex) {
+        if (fromIndex > toIndex) {
+            throw new IllegalArgumentException(
+                "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
+        }
+        if (fromIndex < 0) {
             throw new ArrayIndexOutOfBoundsException(fromIndex);
-        if (toIndex > arrayLen)
+        }
+        if (toIndex > length) {
             throw new ArrayIndexOutOfBoundsException(toIndex);
+        }
     }
 
     // Searching
@@ -1987,21 +1296,21 @@
 
     /**
      * Searches the specified array of floats for the specified value using
-     * the binary search algorithm.  The array must be sorted
-     * (as by the {@link #sort(float[])} method) prior to making this call.  If
-     * it is not sorted, the results are undefined.  If the array contains
+     * the binary search algorithm. The array must be sorted
+     * (as by the {@link #sort(float[])} method) prior to making this call. If
+     * it is not sorted, the results are undefined. If the array contains
      * multiple elements with the specified value, there is no guarantee which
-     * one will be found.  This method considers all NaN values to be
+     * one will be found. This method considers all NaN values to be
      * equivalent and equal.
      *
      * @param a the array to be searched
      * @param key the value to be searched for
      * @return index of the search key, if it is contained in the array;
-     *         otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The
+     *         otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The
      *         <i>insertion point</i> is defined as the point at which the
      *         key would be inserted into the array: the index of the first
      *         element greater than the key, or <tt>a.length</tt> if all
-     *         elements in the array are less than the specified key.  Note
+     *         elements in the array are less than the specified key. Note
      *         that this guarantees that the return value will be &gt;= 0 if
      *         and only if the key is found.
      */
@@ -2015,10 +1324,10 @@
      * the binary search algorithm.
      * The range must be sorted
      * (as by the {@link #sort(float[], int, int)} method)
-     * prior to making this call.  If
-     * it is not sorted, the results are undefined.  If the range contains
+     * prior to making this call. If
+     * it is not sorted, the results are undefined. If the range contains
      * multiple elements with the specified value, there is no guarantee which
-     * one will be found.  This method considers all NaN values to be
+     * one will be found. This method considers all NaN values to be
      * equivalent and equal.
      *
      * @param a the array to be searched
@@ -2028,12 +1337,12 @@
      * @param key the value to be searched for
      * @return index of the search key, if it is contained in the array
      *         within the specified range;
-     *         otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>.  The
+     *         otherwise, <tt>(-(<i>insertion point</i>) - 1)</tt>. The
      *         <i>insertion point</i> is defined as the point at which the
      *         key would be inserted into the array: the index of the first
      *         element in the range greater than the key,
      *         or <tt>toIndex</tt> if all
-     *         elements in the range are less than the specified key.  Note
+     *         elements in the range are less than the specified key. Note
      *         that this guarantees that the return value will be &gt;= 0 if
      *         and only if the key is found.
      * @throws IllegalArgumentException
@@ -2076,10 +1385,9 @@
         return -(low + 1);  // key not found.
     }
 
-
     /**
      * Searches the specified array for the specified object using the binary
-     * search algorithm.  The array must be sorted into ascending order
+     * search algorithm. The array must be sorted into ascending order
      * according to the
      * {@linkplain Comparable natural ordering}
      * of its elements (as by the
@@ -2269,7 +1577,6 @@
             int mid = (low + high) >>> 1;
             T midVal = a[mid];
             int cmp = c.compare(midVal, key);
-
             if (cmp < 0)
                 low = mid + 1;
             else if (cmp > 0)
@@ -2280,7 +1587,6 @@
         return -(low + 1);  // key not found.
     }
 
-
     // Equality Testing
 
     /**
@@ -2527,7 +1833,6 @@
         return true;
     }
 
-
     /**
      * Returns <tt>true</tt> if the two specified arrays of Objects are
      * <i>equal</i> to one another.  The two arrays are considered equal if
@@ -2562,7 +1867,6 @@
         return true;
     }
 
-
     // Filling
 
     /**
@@ -2885,8 +2189,8 @@
             a[i] = val;
     }
 
+    // Cloning
 
-    // Cloning
     /**
      * Copies the specified array, truncating or padding with nulls (if necessary)
      * so the copy has the specified length.  For all indices that are
@@ -3495,7 +2799,6 @@
         return copy;
     }
 
-
     // Misc
 
     /**
@@ -3928,6 +3231,7 @@
      * @param a2 the other array to be tested for equality
      * @return <tt>true</tt> if the two arrays are equal
      * @see #equals(Object[],Object[])
+     * @see Objects#deepEquals(Object, Object)
      * @since 1.5
      */
     public static boolean deepEquals(Object[] a1, Object[] a2) {
@@ -3949,27 +3253,7 @@
                 return false;
 
             // Figure out whether the two elements are equal
-            boolean eq;
-            if (e1 instanceof Object[] && e2 instanceof Object[])
-                eq = deepEquals ((Object[]) e1, (Object[]) e2);
-            else if (e1 instanceof byte[] && e2 instanceof byte[])
-                eq = equals((byte[]) e1, (byte[]) e2);
-            else if (e1 instanceof short[] && e2 instanceof short[])
-                eq = equals((short[]) e1, (short[]) e2);
-            else if (e1 instanceof int[] && e2 instanceof int[])
-                eq = equals((int[]) e1, (int[]) e2);
-            else if (e1 instanceof long[] && e2 instanceof long[])
-                eq = equals((long[]) e1, (long[]) e2);
-            else if (e1 instanceof char[] && e2 instanceof char[])
-                eq = equals((char[]) e1, (char[]) e2);
-            else if (e1 instanceof float[] && e2 instanceof float[])
-                eq = equals((float[]) e1, (float[]) e2);
-            else if (e1 instanceof double[] && e2 instanceof double[])
-                eq = equals((double[]) e1, (double[]) e2);
-            else if (e1 instanceof boolean[] && e2 instanceof boolean[])
-                eq = equals((boolean[]) e1, (boolean[]) e2);
-            else
-                eq = e1.equals(e2);
+            boolean eq = deepEquals0(e1, e2);
 
             if (!eq)
                 return false;
@@ -3977,6 +3261,32 @@
         return true;
     }
 
+    static boolean deepEquals0(Object e1, Object e2) {
+        assert e1 != null;
+        boolean eq;
+        if (e1 instanceof Object[] && e2 instanceof Object[])
+            eq = deepEquals ((Object[]) e1, (Object[]) e2);
+        else if (e1 instanceof byte[] && e2 instanceof byte[])
+            eq = equals((byte[]) e1, (byte[]) e2);
+        else if (e1 instanceof short[] && e2 instanceof short[])
+            eq = equals((short[]) e1, (short[]) e2);
+        else if (e1 instanceof int[] && e2 instanceof int[])
+            eq = equals((int[]) e1, (int[]) e2);
+        else if (e1 instanceof long[] && e2 instanceof long[])
+            eq = equals((long[]) e1, (long[]) e2);
+        else if (e1 instanceof char[] && e2 instanceof char[])
+            eq = equals((char[]) e1, (char[]) e2);
+        else if (e1 instanceof float[] && e2 instanceof float[])
+            eq = equals((float[]) e1, (float[]) e2);
+        else if (e1 instanceof double[] && e2 instanceof double[])
+            eq = equals((double[]) e1, (double[]) e2);
+        else if (e1 instanceof boolean[] && e2 instanceof boolean[])
+            eq = equals((boolean[]) e1, (boolean[]) e2);
+        else
+            eq = e1.equals(e2);
+        return eq;
+    }
+
     /**
      * Returns a string representation of the contents of the specified array.
      * The string representation consists of a list of the array's elements,
@@ -4173,6 +3483,7 @@
     public static String toString(float[] a) {
         if (a == null)
             return "null";
+
         int iMax = a.length - 1;
         if (iMax == -1)
             return "[]";
@@ -4236,6 +3547,7 @@
     public static String toString(Object[] a) {
         if (a == null)
             return "null";
+
         int iMax = a.length - 1;
         if (iMax == -1)
             return "[]";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/DualPivotQuicksort.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,2051 @@
+/*
+ * 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 java.util;
+
+/**
+ * This class implements the Dual-Pivot Quicksort algorithm by
+ * Vladimir Yaroslavskiy, Jon Bentley, and Joshua Bloch. The algorithm
+ * offers O(n log(n)) performance on many data sets that cause other
+ * quicksorts to degrade to quadratic performance, and is typically
+ * faster than traditional (one-pivot) Quicksort implementations.
+ *
+ * @author Vladimir Yaroslavskiy
+ * @author Jon Bentley
+ * @author Josh Bloch
+ *
+ * @version 2009.11.16 m765.827.v12a
+ */
+final class DualPivotQuicksort {
+
+    /**
+     * Suppresses default constructor.
+     */
+    private DualPivotQuicksort() {}
+
+    /*
+     * Tuning parameters.
+     */
+
+    /**
+     * If the length of an array to be sorted is less than this
+     * constant, insertion sort is used in preference to Quicksort.
+     */
+    private static final int INSERTION_SORT_THRESHOLD = 32;
+
+    /**
+     * If the length of a byte array to be sorted is greater than
+     * this constant, counting sort is used in preference to Quicksort.
+     */
+    private static final int COUNTING_SORT_THRESHOLD_FOR_BYTE = 128;
+
+    /**
+     * If the length of a short or char array to be sorted is greater
+     * than this constant, counting sort is used in preference to Quicksort.
+     */
+    private static final int COUNTING_SORT_THRESHOLD_FOR_SHORT_OR_CHAR = 32768;
+
+    /*
+     * Sorting methods for 7 primitive types.
+     */
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * @param a the array to be sorted
+     */
+    public static void sort(int[] a) {
+        doSort(a, 0, a.length - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(int[] a, int fromIndex, int toIndex) {
+        rangeCheck(a.length, fromIndex, toIndex);
+        doSort(a, fromIndex, toIndex - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. This
+     * method differs from the public {@code sort} method in that the
+     * {@code right} index is inclusive, and it does no range checking on
+     * {@code left} or {@code right}.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void doSort(int[] a, int left, int right) {
+        // Use insertion sort on tiny arrays
+        if (right - left + 1 < INSERTION_SORT_THRESHOLD) {
+            for (int k = left + 1; k <= right; k++) {
+                int ak = a[k];
+                int j;
+                for (j = k - 1; j >= left && ak < a[j]; j--) {
+                    a[j + 1] = a[j];
+                }
+                a[j + 1] = ak;
+            }
+        } else { // Use Dual-Pivot Quicksort on large arrays
+            dualPivotQuicksort(a, left, right);
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order by the
+     * Dual-Pivot Quicksort algorithm.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void dualPivotQuicksort(int[] a, int left, int right) {
+        // Compute indices of five evenly spaced elements
+        int sixth = (right - left + 1) / 6;
+        int e1 = left  + sixth;
+        int e5 = right - sixth;
+        int e3 = (left + right) >>> 1; // The midpoint
+        int e4 = e3 + sixth;
+        int e2 = e3 - sixth;
+
+        // Sort these elements using a 5-element sorting network
+        int ae1 = a[e1], ae2 = a[e2], ae3 = a[e3], ae4 = a[e4], ae5 = a[e5];
+
+        if (ae1 > ae2) { int t = ae1; ae1 = ae2; ae2 = t; }
+        if (ae4 > ae5) { int t = ae4; ae4 = ae5; ae5 = t; }
+        if (ae1 > ae3) { int t = ae1; ae1 = ae3; ae3 = t; }
+        if (ae2 > ae3) { int t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae1 > ae4) { int t = ae1; ae1 = ae4; ae4 = t; }
+        if (ae3 > ae4) { int t = ae3; ae3 = ae4; ae4 = t; }
+        if (ae2 > ae5) { int t = ae2; ae2 = ae5; ae5 = t; }
+        if (ae2 > ae3) { int t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae4 > ae5) { int t = ae4; ae4 = ae5; ae5 = t; }
+
+        a[e1] = ae1; a[e3] = ae3; a[e5] = ae5;
+
+        /*
+         * Use the second and fourth of the five sorted elements as pivots.
+         * These values are inexpensive approximations of the first and
+         * second terciles of the array. Note that pivot1 <= pivot2.
+         *
+         * The pivots are stored in local variables, and the first and
+         * the last of the sorted elements are moved to the locations
+         * formerly occupied by the pivots. When partitioning is complete,
+         * the pivots are swapped back into their final positions, and
+         * excluded from subsequent sorting.
+         */
+        int pivot1 = ae2; a[e2] = a[left];
+        int pivot2 = ae4; a[e4] = a[right];
+
+        /*
+         * Partitioning
+         *
+         *   left part         center part                  right part
+         * ------------------------------------------------------------
+         * [ < pivot1  |  pivot1 <= && <= pivot2  |   ?   |  > pivot2 ]
+         * ------------------------------------------------------------
+         *              ^                          ^     ^
+         *              |                          |     |
+         *             less                        k   great
+         */
+
+        // Pointers
+        int less  = left  + 1; // The index of first element of center part
+        int great = right - 1; // The index before first element of right part
+
+        boolean pivotsDiffer = pivot1 != pivot2;
+
+        if (pivotsDiffer) {
+            /*
+             * Invariants:
+             *              all in (left, less)   < pivot1
+             *    pivot1 <= all in [less, k)     <= pivot2
+             *              all in (great, right) > pivot2
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                int ak = a[k];
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else if (ak > pivot2) {
+                    while (a[great] > pivot2) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) < pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        } else { // Pivots are equal
+            /*
+             * Partition degenerates to the traditional 3-way
+             * (or "Dutch National Flag") partition:
+             *
+             *   left part   center part            right part
+             * -------------------------------------------------
+             * [  < pivot  |  == pivot  |    ?    |  > pivot   ]
+             * -------------------------------------------------
+             *
+             *              ^            ^       ^
+             *              |            |       |
+             *             less          k     great
+             *
+             * Invariants:
+             *
+             *   all in (left, less)   < pivot
+             *   all in [less, k)     == pivot
+             *   all in (great, right) > pivot
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                int ak = a[k];
+                if (ak == pivot1) {
+                    continue;
+                }
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else { // a[k] > pivot
+                    while (a[great] > pivot1) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        }
+
+        // Swap pivots into their final positions
+        a[left]  = a[less  - 1]; a[less  - 1] = pivot1;
+        a[right] = a[great + 1]; a[great + 1] = pivot2;
+
+        // Sort left and right parts recursively, excluding known pivot values
+        doSort(a, left,   less - 2);
+        doSort(a, great + 2, right);
+
+        /*
+         * If pivot1 == pivot2, all elements from center
+         * part are equal and, therefore, already sorted
+         */
+        if (!pivotsDiffer) {
+            return;
+        }
+
+        /*
+         * If center part is too large (comprises > 5/6 of
+         * the array), swap internal pivot values to ends
+         */
+        if (less < e1 && e5 < great) {
+            while (a[less] == pivot1) {
+                less++;
+            }
+            while (a[great] == pivot2) {
+                great--;
+            }
+            for (int k = less + 1; k <= great; ) {
+                int ak = a[k];
+                if (ak == pivot1) {
+                    a[k++] = a[less];
+                    a[less++] = pivot1;
+                } else if (ak == pivot2) {
+                    a[k] = a[great];
+                    a[great--] = pivot2;
+                } else {
+                    k++;
+                }
+            }
+        }
+
+        // Sort center part recursively, excluding known pivot values
+        doSort(a, less, great);
+    }
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * @param a the array to be sorted
+     */
+    public static void sort(long[] a) {
+        doSort(a, 0, a.length - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(long[] a, int fromIndex, int toIndex) {
+        rangeCheck(a.length, fromIndex, toIndex);
+        doSort(a, fromIndex, toIndex - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. This
+     * method differs from the public {@code sort} method in that the
+     * {@code right} index is inclusive, and it does no range checking on
+     * {@code left} or {@code right}.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void doSort(long[] a, int left, int right) {
+        // Use insertion sort on tiny arrays
+        if (right - left + 1 < INSERTION_SORT_THRESHOLD) {
+            for (int k = left + 1; k <= right; k++) {
+                long ak = a[k];
+                int j;
+                for (j = k - 1; j >= left && ak < a[j]; j--) {
+                    a[j + 1] = a[j];
+                }
+                a[j + 1] = ak;
+            }
+        } else { // Use Dual-Pivot Quicksort on large arrays
+            dualPivotQuicksort(a, left, right);
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order by the
+     * Dual-Pivot Quicksort algorithm.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void dualPivotQuicksort(long[] a, int left, int right) {
+        // Compute indices of five evenly spaced elements
+        int sixth = (right - left + 1) / 6;
+        int e1 = left  + sixth;
+        int e5 = right - sixth;
+        int e3 = (left + right) >>> 1; // The midpoint
+        int e4 = e3 + sixth;
+        int e2 = e3 - sixth;
+
+        // Sort these elements using a 5-element sorting network
+        long ae1 = a[e1], ae2 = a[e2], ae3 = a[e3], ae4 = a[e4], ae5 = a[e5];
+
+        if (ae1 > ae2) { long t = ae1; ae1 = ae2; ae2 = t; }
+        if (ae4 > ae5) { long t = ae4; ae4 = ae5; ae5 = t; }
+        if (ae1 > ae3) { long t = ae1; ae1 = ae3; ae3 = t; }
+        if (ae2 > ae3) { long t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae1 > ae4) { long t = ae1; ae1 = ae4; ae4 = t; }
+        if (ae3 > ae4) { long t = ae3; ae3 = ae4; ae4 = t; }
+        if (ae2 > ae5) { long t = ae2; ae2 = ae5; ae5 = t; }
+        if (ae2 > ae3) { long t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae4 > ae5) { long t = ae4; ae4 = ae5; ae5 = t; }
+
+        a[e1] = ae1; a[e3] = ae3; a[e5] = ae5;
+
+        /*
+         * Use the second and fourth of the five sorted elements as pivots.
+         * These values are inexpensive approximations of the first and
+         * second terciles of the array. Note that pivot1 <= pivot2.
+         *
+         * The pivots are stored in local variables, and the first and
+         * the last of the sorted elements are moved to the locations
+         * formerly occupied by the pivots. When partitioning is complete,
+         * the pivots are swapped back into their final positions, and
+         * excluded from subsequent sorting.
+         */
+        long pivot1 = ae2; a[e2] = a[left];
+        long pivot2 = ae4; a[e4] = a[right];
+
+        /*
+         * Partitioning
+         *
+         *   left part         center part                  right part
+         * ------------------------------------------------------------
+         * [ < pivot1  |  pivot1 <= && <= pivot2  |   ?   |  > pivot2 ]
+         * ------------------------------------------------------------
+         *              ^                          ^     ^
+         *              |                          |     |
+         *             less                        k   great
+         */
+
+        // Pointers
+        int less  = left  + 1; // The index of first element of center part
+        int great = right - 1; // The index before first element of right part
+
+        boolean pivotsDiffer = pivot1 != pivot2;
+
+        if (pivotsDiffer) {
+            /*
+             * Invariants:
+             *              all in (left, less)   < pivot1
+             *    pivot1 <= all in [less, k)     <= pivot2
+             *              all in (great, right) > pivot2
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                long ak = a[k];
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else if (ak > pivot2) {
+                    while (a[great] > pivot2) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        } else { // Pivots are equal
+            /*
+             * Partition degenerates to the traditional 3-way
+             * (or "Dutch National Flag") partition:
+             *
+             *   left part   center part            right part
+             * -------------------------------------------------
+             * [  < pivot  |  == pivot  |    ?    |  > pivot   ]
+             * -------------------------------------------------
+             *
+             *              ^            ^       ^
+             *              |            |       |
+             *             less          k     great
+             *
+             * Invariants:
+             *
+             *   all in (left, less)   < pivot
+             *   all in [less, k)     == pivot
+             *   all in (great, right) > pivot
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                long ak = a[k];
+                if (ak == pivot1) {
+                    continue;
+                }
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else { // a[k] > pivot
+                    while (a[great] > pivot1) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        }
+
+        // Swap pivots into their final positions
+        a[left]  = a[less  - 1]; a[less  - 1] = pivot1;
+        a[right] = a[great + 1]; a[great + 1] = pivot2;
+
+        // Sort left and right parts recursively, excluding known pivot values
+        doSort(a, left,   less - 2);
+        doSort(a, great + 2, right);
+
+        /*
+         * If pivot1 == pivot2, all elements from center
+         * part are equal and, therefore, already sorted
+         */
+        if (!pivotsDiffer) {
+            return;
+        }
+
+        /*
+         * If center part is too large (comprises > 5/6 of
+         * the array), swap internal pivot values to ends
+         */
+        if (less < e1 && e5 < great) {
+            while (a[less] == pivot1) {
+                less++;
+            }
+            while (a[great] == pivot2) {
+                great--;
+            }
+            for (int k = less + 1; k <= great; ) {
+                long ak = a[k];
+                if (ak == pivot1) {
+                    a[k++] = a[less];
+                    a[less++] = pivot1;
+                } else if (ak == pivot2) {
+                    a[k] = a[great];
+                    a[great--] = pivot2;
+                } else {
+                    k++;
+                }
+            }
+        }
+
+        // Sort center part recursively, excluding known pivot values
+        doSort(a, less, great);
+    }
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * @param a the array to be sorted
+     */
+    public static void sort(short[] a) {
+        doSort(a, 0, a.length - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(short[] a, int fromIndex, int toIndex) {
+        rangeCheck(a.length, fromIndex, toIndex);
+        doSort(a, fromIndex, toIndex - 1);
+    }
+
+    /** The number of distinct short values. */
+    private static final int NUM_SHORT_VALUES = 1 << 16;
+
+    /**
+     * Sorts the specified range of the array into ascending order. This
+     * method differs from the public {@code sort} method in that the
+     * {@code right} index is inclusive, and it does no range checking on
+     * {@code left} or {@code right}.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void doSort(short[] a, int left, int right) {
+        // Use insertion sort on tiny arrays
+        if (right - left + 1 < INSERTION_SORT_THRESHOLD) {
+            for (int k = left + 1; k <= right; k++) {
+                short ak = a[k];
+                int j;
+                for (j = k - 1; j >= left && ak < a[j]; j--) {
+                    a[j + 1] = a[j];
+                }
+                a[j + 1] = ak;
+            }
+        } else if (right-left+1 > COUNTING_SORT_THRESHOLD_FOR_SHORT_OR_CHAR) {
+            // Use counting sort on huge arrays
+            int[] count = new int[NUM_SHORT_VALUES];
+
+            for (int i = left; i <= right; i++) {
+                count[a[i] - Short.MIN_VALUE]++;
+            }
+            for (int i = 0, k = left; i < count.length && k <= right; i++) {
+                short value = (short) (i + Short.MIN_VALUE);
+
+                for (int s = count[i]; s > 0; s--) {
+                    a[k++] = value;
+               }
+            }
+        } else { // Use Dual-Pivot Quicksort on large arrays
+            dualPivotQuicksort(a, left, right);
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order by the
+     * Dual-Pivot Quicksort algorithm.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void dualPivotQuicksort(short[] a, int left, int right) {
+        // Compute indices of five evenly spaced elements
+        int sixth = (right - left + 1) / 6;
+        int e1 = left  + sixth;
+        int e5 = right - sixth;
+        int e3 = (left + right) >>> 1; // The midpoint
+        int e4 = e3 + sixth;
+        int e2 = e3 - sixth;
+
+        // Sort these elements using a 5-element sorting network
+        short ae1 = a[e1], ae2 = a[e2], ae3 = a[e3], ae4 = a[e4], ae5 = a[e5];
+
+        if (ae1 > ae2) { short t = ae1; ae1 = ae2; ae2 = t; }
+        if (ae4 > ae5) { short t = ae4; ae4 = ae5; ae5 = t; }
+        if (ae1 > ae3) { short t = ae1; ae1 = ae3; ae3 = t; }
+        if (ae2 > ae3) { short t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae1 > ae4) { short t = ae1; ae1 = ae4; ae4 = t; }
+        if (ae3 > ae4) { short t = ae3; ae3 = ae4; ae4 = t; }
+        if (ae2 > ae5) { short t = ae2; ae2 = ae5; ae5 = t; }
+        if (ae2 > ae3) { short t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae4 > ae5) { short t = ae4; ae4 = ae5; ae5 = t; }
+
+        a[e1] = ae1; a[e3] = ae3; a[e5] = ae5;
+
+        /*
+         * Use the second and fourth of the five sorted elements as pivots.
+         * These values are inexpensive approximations of the first and
+         * second terciles of the array. Note that pivot1 <= pivot2.
+         *
+         * The pivots are stored in local variables, and the first and
+         * the last of the sorted elements are moved to the locations
+         * formerly occupied by the pivots. When partitioning is complete,
+         * the pivots are swapped back into their final positions, and
+         * excluded from subsequent sorting.
+         */
+        short pivot1 = ae2; a[e2] = a[left];
+        short pivot2 = ae4; a[e4] = a[right];
+
+        /*
+         * Partitioning
+         *
+         *   left part         center part                  right part
+         * ------------------------------------------------------------
+         * [ < pivot1  |  pivot1 <= && <= pivot2  |   ?   |  > pivot2 ]
+         * ------------------------------------------------------------
+         *              ^                          ^     ^
+         *              |                          |     |
+         *             less                        k   great
+         */
+
+        // Pointers
+        int less  = left  + 1; // The index of first element of center part
+        int great = right - 1; // The index before first element of right part
+
+        boolean pivotsDiffer = pivot1 != pivot2;
+
+        if (pivotsDiffer) {
+            /*
+             * Invariants:
+             *              all in (left, less)   < pivot1
+             *    pivot1 <= all in [less, k)     <= pivot2
+             *              all in (great, right) > pivot2
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                short ak = a[k];
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else if (ak > pivot2) {
+                    while (a[great] > pivot2) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        } else { // Pivots are equal
+            /*
+             * Partition degenerates to the traditional 3-way
+             * (or "Dutch National Flag") partition:
+             *
+             *   left part   center part            right part
+             * -------------------------------------------------
+             * [  < pivot  |  == pivot  |    ?    |  > pivot   ]
+             * -------------------------------------------------
+             *
+             *              ^            ^       ^
+             *              |            |       |
+             *             less          k     great
+             *
+             * Invariants:
+             *
+             *   all in (left, less)   < pivot
+             *   all in [less, k)     == pivot
+             *   all in (great, right) > pivot
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                short ak = a[k];
+                if (ak == pivot1) {
+                    continue;
+                }
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else { // a[k] > pivot
+                    while (a[great] > pivot1) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        }
+
+        // Swap pivots into their final positions
+        a[left]  = a[less  - 1]; a[less  - 1] = pivot1;
+        a[right] = a[great + 1]; a[great + 1] = pivot2;
+
+        // Sort left and right parts recursively, excluding known pivot values
+        doSort(a, left,   less - 2);
+        doSort(a, great + 2, right);
+
+        /*
+         * If pivot1 == pivot2, all elements from center
+         * part are equal and, therefore, already sorted
+         */
+        if (!pivotsDiffer) {
+            return;
+        }
+
+        /*
+         * If center part is too large (comprises > 5/6 of
+         * the array), swap internal pivot values to ends
+         */
+        if (less < e1 && e5 < great) {
+            while (a[less] == pivot1) {
+                less++;
+            }
+            while (a[great] == pivot2) {
+                great--;
+            }
+            for (int k = less + 1; k <= great; ) {
+                short ak = a[k];
+                if (ak == pivot1) {
+                    a[k++] = a[less];
+                    a[less++] = pivot1;
+                } else if (ak == pivot2) {
+                    a[k] = a[great];
+                    a[great--] = pivot2;
+                } else {
+                    k++;
+                }
+            }
+        }
+
+        // Sort center part recursively, excluding known pivot values
+        doSort(a, less, great);
+    }
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * @param a the array to be sorted
+     */
+    public static void sort(char[] a) {
+        doSort(a, 0, a.length - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(char[] a, int fromIndex, int toIndex) {
+        rangeCheck(a.length, fromIndex, toIndex);
+        doSort(a, fromIndex, toIndex - 1);
+    }
+
+    /** The number of distinct char values. */
+    private static final int NUM_CHAR_VALUES = 1 << 16;
+
+    /**
+     * Sorts the specified range of the array into ascending order. This
+     * method differs from the public {@code sort} method in that the
+     * {@code right} index is inclusive, and it does no range checking on
+     * {@code left} or {@code right}.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void doSort(char[] a, int left, int right) {
+        // Use insertion sort on tiny arrays
+        if (right - left + 1 < INSERTION_SORT_THRESHOLD) {
+            for (int k = left + 1; k <= right; k++) {
+                char ak = a[k];
+                int j;
+                for (j = k - 1; j >= left && ak < a[j]; j--) {
+                    a[j + 1] = a[j];
+                }
+                a[j + 1] = ak;
+            }
+        } else if (right-left+1 > COUNTING_SORT_THRESHOLD_FOR_SHORT_OR_CHAR) {
+            // Use counting sort on huge arrays
+            int[] count = new int[NUM_CHAR_VALUES];
+
+            for (int i = left; i <= right; i++) {
+                count[a[i]]++;
+            }
+            for (int i = 0, k = left; i < count.length && k <= right; i++) {
+                for (int s = count[i]; s > 0; s--) {
+                    a[k++] = (char) i;
+               }
+            }
+        } else { // Use Dual-Pivot Quicksort on large arrays
+            dualPivotQuicksort(a, left, right);
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order by the
+     * Dual-Pivot Quicksort algorithm.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void dualPivotQuicksort(char[] a, int left, int right) {
+        // Compute indices of five evenly spaced elements
+        int sixth = (right - left + 1) / 6;
+        int e1 = left  + sixth;
+        int e5 = right - sixth;
+        int e3 = (left + right) >>> 1; // The midpoint
+        int e4 = e3 + sixth;
+        int e2 = e3 - sixth;
+
+        // Sort these elements using a 5-element sorting network
+        char ae1 = a[e1], ae2 = a[e2], ae3 = a[e3], ae4 = a[e4], ae5 = a[e5];
+
+        if (ae1 > ae2) { char t = ae1; ae1 = ae2; ae2 = t; }
+        if (ae4 > ae5) { char t = ae4; ae4 = ae5; ae5 = t; }
+        if (ae1 > ae3) { char t = ae1; ae1 = ae3; ae3 = t; }
+        if (ae2 > ae3) { char t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae1 > ae4) { char t = ae1; ae1 = ae4; ae4 = t; }
+        if (ae3 > ae4) { char t = ae3; ae3 = ae4; ae4 = t; }
+        if (ae2 > ae5) { char t = ae2; ae2 = ae5; ae5 = t; }
+        if (ae2 > ae3) { char t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae4 > ae5) { char t = ae4; ae4 = ae5; ae5 = t; }
+
+        a[e1] = ae1; a[e3] = ae3; a[e5] = ae5;
+
+        /*
+         * Use the second and fourth of the five sorted elements as pivots.
+         * These values are inexpensive approximations of the first and
+         * second terciles of the array. Note that pivot1 <= pivot2.
+         *
+         * The pivots are stored in local variables, and the first and
+         * the last of the sorted elements are moved to the locations
+         * formerly occupied by the pivots. When partitioning is complete,
+         * the pivots are swapped back into their final positions, and
+         * excluded from subsequent sorting.
+         */
+        char pivot1 = ae2; a[e2] = a[left];
+        char pivot2 = ae4; a[e4] = a[right];
+
+        /*
+         * Partitioning
+         *
+         *   left part         center part                  right part
+         * ------------------------------------------------------------
+         * [ < pivot1  |  pivot1 <= && <= pivot2  |   ?   |  > pivot2 ]
+         * ------------------------------------------------------------
+         *              ^                          ^     ^
+         *              |                          |     |
+         *             less                        k   great
+         */
+
+        // Pointers
+        int less  = left  + 1; // The index of first element of center part
+        int great = right - 1; // The index before first element of right part
+
+        boolean pivotsDiffer = pivot1 != pivot2;
+
+        if (pivotsDiffer) {
+            /*
+             * Invariants:
+             *              all in (left, less)   < pivot1
+             *    pivot1 <= all in [less, k)     <= pivot2
+             *              all in (great, right) > pivot2
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                char ak = a[k];
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else if (ak > pivot2) {
+                    while (a[great] > pivot2) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        } else { // Pivots are equal
+            /*
+             * Partition degenerates to the traditional 3-way
+             * (or "Dutch National Flag") partition:
+             *
+             *   left part   center part            right part
+             * -------------------------------------------------
+             * [  < pivot  |  == pivot  |    ?    |  > pivot   ]
+             * -------------------------------------------------
+             *
+             *              ^            ^       ^
+             *              |            |       |
+             *             less          k     great
+             *
+             * Invariants:
+             *
+             *   all in (left, less)   < pivot
+             *   all in [less, k)     == pivot
+             *   all in (great, right) > pivot
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                char ak = a[k];
+                if (ak == pivot1) {
+                    continue;
+                }
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else { // a[k] > pivot
+                    while (a[great] > pivot1) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        }
+
+        // Swap pivots into their final positions
+        a[left]  = a[less  - 1]; a[less  - 1] = pivot1;
+        a[right] = a[great + 1]; a[great + 1] = pivot2;
+
+        // Sort left and right parts recursively, excluding known pivot values
+        doSort(a, left,   less - 2);
+        doSort(a, great + 2, right);
+
+        /*
+         * If pivot1 == pivot2, all elements from center
+         * part are equal and, therefore, already sorted
+         */
+        if (!pivotsDiffer) {
+            return;
+        }
+
+        /*
+         * If center part is too large (comprises > 5/6 of
+         * the array), swap internal pivot values to ends
+         */
+        if (less < e1 && e5 < great) {
+            while (a[less] == pivot1) {
+                less++;
+            }
+            while (a[great] == pivot2) {
+                great--;
+            }
+            for (int k = less + 1; k <= great; ) {
+                char ak = a[k];
+                if (ak == pivot1) {
+                    a[k++] = a[less];
+                    a[less++] = pivot1;
+                } else if (ak == pivot2) {
+                    a[k] = a[great];
+                    a[great--] = pivot2;
+                } else {
+                    k++;
+                }
+            }
+        }
+
+        // Sort center part recursively, excluding known pivot values
+        doSort(a, less, great);
+    }
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * @param a the array to be sorted
+     */
+    public static void sort(byte[] a) {
+        doSort(a, 0, a.length - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(byte[] a, int fromIndex, int toIndex) {
+        rangeCheck(a.length, fromIndex, toIndex);
+        doSort(a, fromIndex, toIndex - 1);
+    }
+
+    /** The number of distinct byte values. */
+    private static final int NUM_BYTE_VALUES = 1 << 8;
+
+    /**
+     * Sorts the specified range of the array into ascending order. This
+     * method differs from the public {@code sort} method in that the
+     * {@code right} index is inclusive, and it does no range checking on
+     * {@code left} or {@code right}.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void doSort(byte[] a, int left, int right) {
+        // Use insertion sort on tiny arrays
+        if (right - left + 1 < INSERTION_SORT_THRESHOLD) {
+            for (int k = left + 1; k <= right; k++) {
+                byte ak = a[k];
+                int j;
+                for (j = k - 1; j >= left && ak < a[j]; j--) {
+                    a[j + 1] = a[j];
+                }
+                a[j + 1] = ak;
+            }
+        } else if (right - left + 1 > COUNTING_SORT_THRESHOLD_FOR_BYTE) {
+            // Use counting sort on huge arrays
+            int[] count = new int[NUM_BYTE_VALUES];
+
+            for (int i = left; i <= right; i++) {
+                count[a[i] - Byte.MIN_VALUE]++;
+            }
+            for (int i = 0, k = left; i < count.length && k <= right; i++) {
+                byte value = (byte) (i + Byte.MIN_VALUE);
+
+                for (int s = count[i]; s > 0; s--) {
+                    a[k++] = value;
+               }
+            }
+        } else { // Use Dual-Pivot Quicksort on large arrays
+            dualPivotQuicksort(a, left, right);
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order by the
+     * Dual-Pivot Quicksort algorithm.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void dualPivotQuicksort(byte[] a, int left, int right) {
+        // Compute indices of five evenly spaced elements
+        int sixth = (right - left + 1) / 6;
+        int e1 = left  + sixth;
+        int e5 = right - sixth;
+        int e3 = (left + right) >>> 1; // The midpoint
+        int e4 = e3 + sixth;
+        int e2 = e3 - sixth;
+
+        // Sort these elements using a 5-element sorting network
+        byte ae1 = a[e1], ae2 = a[e2], ae3 = a[e3], ae4 = a[e4], ae5 = a[e5];
+
+        if (ae1 > ae2) { byte t = ae1; ae1 = ae2; ae2 = t; }
+        if (ae4 > ae5) { byte t = ae4; ae4 = ae5; ae5 = t; }
+        if (ae1 > ae3) { byte t = ae1; ae1 = ae3; ae3 = t; }
+        if (ae2 > ae3) { byte t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae1 > ae4) { byte t = ae1; ae1 = ae4; ae4 = t; }
+        if (ae3 > ae4) { byte t = ae3; ae3 = ae4; ae4 = t; }
+        if (ae2 > ae5) { byte t = ae2; ae2 = ae5; ae5 = t; }
+        if (ae2 > ae3) { byte t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae4 > ae5) { byte t = ae4; ae4 = ae5; ae5 = t; }
+
+        a[e1] = ae1; a[e3] = ae3; a[e5] = ae5;
+
+        /*
+         * Use the second and fourth of the five sorted elements as pivots.
+         * These values are inexpensive approximations of the first and
+         * second terciles of the array. Note that pivot1 <= pivot2.
+         *
+         * The pivots are stored in local variables, and the first and
+         * the last of the sorted elements are moved to the locations
+         * formerly occupied by the pivots. When partitioning is complete,
+         * the pivots are swapped back into their final positions, and
+         * excluded from subsequent sorting.
+         */
+        byte pivot1 = ae2; a[e2] = a[left];
+        byte pivot2 = ae4; a[e4] = a[right];
+
+        /*
+         * Partitioning
+         *
+         *   left part         center part                  right part
+         * ------------------------------------------------------------
+         * [ < pivot1  |  pivot1 <= && <= pivot2  |   ?   |  > pivot2 ]
+         * ------------------------------------------------------------
+         *              ^                          ^     ^
+         *              |                          |     |
+         *             less                        k   great
+         */
+
+        // Pointers
+        int less  = left  + 1; // The index of first element of center part
+        int great = right - 1; // The index before first element of right part
+
+        boolean pivotsDiffer = pivot1 != pivot2;
+
+        if (pivotsDiffer) {
+            /*
+             * Invariants:
+             *              all in (left, less)   < pivot1
+             *    pivot1 <= all in [less, k)     <= pivot2
+             *              all in (great, right) > pivot2
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                byte ak = a[k];
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else if (ak > pivot2) {
+                    while (a[great] > pivot2) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        } else { // Pivots are equal
+            /*
+             * Partition degenerates to the traditional 3-way
+             * (or "Dutch National Flag") partition:
+             *
+             *   left part   center part            right part
+             * -------------------------------------------------
+             * [  < pivot  |  == pivot  |    ?    |  > pivot   ]
+             * -------------------------------------------------
+             *
+             *              ^            ^       ^
+             *              |            |       |
+             *             less          k     great
+             *
+             * Invariants:
+             *
+             *   all in (left, less)   < pivot
+             *   all in [less, k)     == pivot
+             *   all in (great, right) > pivot
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                byte ak = a[k];
+                if (ak == pivot1) {
+                    continue;
+                }
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else { // a[k] > pivot
+                    while (a[great] > pivot1) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        }
+
+        // Swap pivots into their final positions
+        a[left]  = a[less  - 1]; a[less  - 1] = pivot1;
+        a[right] = a[great + 1]; a[great + 1] = pivot2;
+
+        // Sort left and right parts recursively, excluding known pivot values
+        doSort(a, left,   less - 2);
+        doSort(a, great + 2, right);
+
+        /*
+         * If pivot1 == pivot2, all elements from center
+         * part are equal and, therefore, already sorted
+         */
+        if (!pivotsDiffer) {
+            return;
+        }
+
+        /*
+         * If center part is too large (comprises > 5/6 of
+         * the array), swap internal pivot values to ends
+         */
+        if (less < e1 && e5 < great) {
+            while (a[less] == pivot1) {
+                less++;
+            }
+            while (a[great] == pivot2) {
+                great--;
+            }
+            for (int k = less + 1; k <= great; ) {
+                byte ak = a[k];
+                if (ak == pivot1) {
+                    a[k++] = a[less];
+                    a[less++] = pivot1;
+                } else if (ak == pivot2) {
+                    a[k] = a[great];
+                    a[great--] = pivot2;
+                } else {
+                    k++;
+                }
+            }
+        }
+
+        // Sort center part recursively, excluding known pivot values
+        doSort(a, less, great);
+    }
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * <p>The {@code <} relation does not provide a total order on all float
+     * values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Float#compareTo}: {@code -0.0f} is treated as less than value
+     * {@code 0.0f} and {@code Float.NaN} is considered greater than any
+     * other value and all {@code Float.NaN} values are considered equal.
+     *
+     * @param a the array to be sorted
+     */
+    public static void sort(float[] a) {
+        sortNegZeroAndNaN(a, 0, a.length - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * <p>The {@code <} relation does not provide a total order on all float
+     * values: {@code -0.0f == 0.0f} is {@code true} and a {@code Float.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Float#compareTo}: {@code -0.0f} is treated as less than value
+     * {@code 0.0f} and {@code Float.NaN} is considered greater than any
+     * other value and all {@code Float.NaN} values are considered equal.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(float[] a, int fromIndex, int toIndex) {
+        rangeCheck(a.length, fromIndex, toIndex);
+        sortNegZeroAndNaN(a, fromIndex, toIndex - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The
+     * sort is done in three phases to avoid expensive comparisons in the
+     * inner loop. The comparisons would be expensive due to anomalies
+     * associated with negative zero {@code -0.0f} and {@code Float.NaN}.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void sortNegZeroAndNaN(float[] a, int left, int right) {
+        /*
+         * Phase 1: Count negative zeros and move NaNs to end of array
+         */
+        final int NEGATIVE_ZERO = Float.floatToIntBits(-0.0f);
+        int numNegativeZeros = 0;
+        int n = right;
+
+        for (int k = left; k <= n; k++) {
+            float ak = a[k];
+            if (ak == 0.0f && NEGATIVE_ZERO == Float.floatToIntBits(ak)) {
+                a[k] = 0.0f;
+                numNegativeZeros++;
+            } else if (ak != ak) { // i.e., ak is NaN
+                a[k--] = a[n];
+                a[n--] = Float.NaN;
+            }
+        }
+
+        /*
+         * Phase 2: Sort everything except NaNs (which are already in place)
+         */
+        doSort(a, left, n);
+
+        /*
+         * Phase 3: Turn positive zeros back into negative zeros as appropriate
+         */
+        if (numNegativeZeros == 0) {
+            return;
+        }
+
+        // Find first zero element
+        int zeroIndex = findAnyZero(a, left, n);
+
+        for (int i = zeroIndex - 1; i >= left && a[i] == 0.0f; i--) {
+            zeroIndex = i;
+        }
+
+        // Turn the right number of positive zeros back into negative zeros
+        for (int i = zeroIndex, m = zeroIndex + numNegativeZeros; i < m; i++) {
+            a[i] = -0.0f;
+        }
+    }
+
+    /**
+     * Returns the index of some zero element in the specified range via
+     * binary search. The range is assumed to be sorted, and must contain
+     * at least one zero.
+     *
+     * @param a the array to be searched
+     * @param low the index of the first element, inclusive, to be searched
+     * @param high the index of the last element, inclusive, to be searched
+     */
+    private static int findAnyZero(float[] a, int low, int high) {
+        while (true) {
+            int middle = (low + high) >>> 1;
+            float middleValue = a[middle];
+
+            if (middleValue < 0.0f) {
+                low = middle + 1;
+            } else if (middleValue > 0.0f) {
+                high = middle - 1;
+            } else { // middleValue == 0.0f
+                return middle;
+            }
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. This
+     * method differs from the public {@code sort} method in three ways:
+     * {@code right} index is inclusive, it does no range checking on
+     * {@code left} or {@code right}, and it does not handle negative
+     * zeros or NaNs in the array.
+     *
+     * @param a the array to be sorted, which must not contain -0.0f or NaN
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void doSort(float[] a, int left, int right) {
+        // Use insertion sort on tiny arrays
+        if (right - left + 1 < INSERTION_SORT_THRESHOLD) {
+            for (int k = left + 1; k <= right; k++) {
+                float ak = a[k];
+                int j;
+                for (j = k - 1; j >= left && ak < a[j]; j--) {
+                    a[j + 1] = a[j];
+                }
+                a[j + 1] = ak;
+            }
+        } else { // Use Dual-Pivot Quicksort on large arrays
+            dualPivotQuicksort(a, left, right);
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order by the
+     * Dual-Pivot Quicksort algorithm.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void dualPivotQuicksort(float[] a, int left, int right) {
+        // Compute indices of five evenly spaced elements
+        int sixth = (right - left + 1) / 6;
+        int e1 = left  + sixth;
+        int e5 = right - sixth;
+        int e3 = (left + right) >>> 1; // The midpoint
+        int e4 = e3 + sixth;
+        int e2 = e3 - sixth;
+
+        // Sort these elements using a 5-element sorting network
+        float ae1 = a[e1], ae2 = a[e2], ae3 = a[e3], ae4 = a[e4], ae5 = a[e5];
+
+        if (ae1 > ae2) { float t = ae1; ae1 = ae2; ae2 = t; }
+        if (ae4 > ae5) { float t = ae4; ae4 = ae5; ae5 = t; }
+        if (ae1 > ae3) { float t = ae1; ae1 = ae3; ae3 = t; }
+        if (ae2 > ae3) { float t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae1 > ae4) { float t = ae1; ae1 = ae4; ae4 = t; }
+        if (ae3 > ae4) { float t = ae3; ae3 = ae4; ae4 = t; }
+        if (ae2 > ae5) { float t = ae2; ae2 = ae5; ae5 = t; }
+        if (ae2 > ae3) { float t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae4 > ae5) { float t = ae4; ae4 = ae5; ae5 = t; }
+
+        a[e1] = ae1; a[e3] = ae3; a[e5] = ae5;
+
+        /*
+         * Use the second and fourth of the five sorted elements as pivots.
+         * These values are inexpensive approximations of the first and
+         * second terciles of the array. Note that pivot1 <= pivot2.
+         *
+         * The pivots are stored in local variables, and the first and
+         * the last of the sorted elements are moved to the locations
+         * formerly occupied by the pivots. When partitioning is complete,
+         * the pivots are swapped back into their final positions, and
+         * excluded from subsequent sorting.
+         */
+        float pivot1 = ae2; a[e2] = a[left];
+        float pivot2 = ae4; a[e4] = a[right];
+
+        /*
+         * Partitioning
+         *
+         *   left part         center part                  right part
+         * ------------------------------------------------------------
+         * [ < pivot1  |  pivot1 <= && <= pivot2  |   ?   |  > pivot2 ]
+         * ------------------------------------------------------------
+         *              ^                          ^     ^
+         *              |                          |     |
+         *             less                        k   great
+         */
+
+        // Pointers
+        int less  = left  + 1; // The index of first element of center part
+        int great = right - 1; // The index before first element of right part
+
+        boolean pivotsDiffer = pivot1 != pivot2;
+
+        if (pivotsDiffer) {
+            /*
+             * Invariants:
+             *              all in (left, less)   < pivot1
+             *    pivot1 <= all in [less, k)     <= pivot2
+             *              all in (great, right) > pivot2
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                float ak = a[k];
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else if (ak > pivot2) {
+                    while (a[great] > pivot2) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        } else { // Pivots are equal
+            /*
+             * Partition degenerates to the traditional 3-way
+             * (or "Dutch National Flag") partition:
+             *
+             *   left part   center part            right part
+             * -------------------------------------------------
+             * [  < pivot  |  == pivot  |    ?    |  > pivot   ]
+             * -------------------------------------------------
+             *
+             *              ^            ^       ^
+             *              |            |       |
+             *             less          k     great
+             *
+             * Invariants:
+             *
+             *   all in (left, less)   < pivot
+             *   all in [less, k)     == pivot
+             *   all in (great, right) > pivot
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                float ak = a[k];
+                if (ak == pivot1) {
+                    continue;
+                }
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else { // a[k] > pivot
+                    while (a[great] > pivot1) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        }
+
+        // Swap pivots into their final positions
+        a[left]  = a[less  - 1]; a[less  - 1] = pivot1;
+        a[right] = a[great + 1]; a[great + 1] = pivot2;
+
+        // Sort left and right parts recursively, excluding known pivot values
+        doSort(a, left,   less - 2);
+        doSort(a, great + 2, right);
+
+        /*
+         * If pivot1 == pivot2, all elements from center
+         * part are equal and, therefore, already sorted
+         */
+        if (!pivotsDiffer) {
+            return;
+        }
+
+        /*
+         * If center part is too large (comprises > 5/6 of
+         * the array), swap internal pivot values to ends
+         */
+        if (less < e1 && e5 < great) {
+            while (a[less] == pivot1) {
+                less++;
+            }
+            while (a[great] == pivot2) {
+                great--;
+            }
+            for (int k = less + 1; k <= great; ) {
+                float ak = a[k];
+                if (ak == pivot1) {
+                    a[k++] = a[less];
+                    a[less++] = pivot1;
+                } else if (ak == pivot2) {
+                    a[k] = a[great];
+                    a[great--] = pivot2;
+                } else {
+                    k++;
+                }
+            }
+        }
+
+        // Sort center part recursively, excluding known pivot values
+        doSort(a, less, great);
+    }
+
+    /**
+     * Sorts the specified array into ascending numerical order.
+     *
+     * <p>The {@code <} relation does not provide a total order on all double
+     * values: {@code -0.0d == 0.0d} is {@code true} and a {@code Double.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Double#compareTo}: {@code -0.0d} is treated as less than value
+     * {@code 0.0d} and {@code Double.NaN} is considered greater than any
+     * other value and all {@code Double.NaN} values are considered equal.
+     *
+     * @param a the array to be sorted
+     */
+    public static void sort(double[] a) {
+        sortNegZeroAndNaN(a, 0, a.length - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The range
+     * to be sorted extends from the index {@code fromIndex}, inclusive, to
+     * the index {@code toIndex}, exclusive. If {@code fromIndex == toIndex},
+     * the range to be sorted is empty.
+     *
+     * <p>The {@code <} relation does not provide a total order on all double
+     * values: {@code -0.0d == 0.0d} is {@code true} and a {@code Double.NaN}
+     * value compares neither less than, greater than, nor equal to any value,
+     * even itself. This method uses the total order imposed by the method
+     * {@link Double#compareTo}: {@code -0.0d} is treated as less than value
+     * {@code 0.0d} and {@code Double.NaN} is considered greater than any
+     * other value and all {@code Double.NaN} values are considered equal.
+     *
+     * @param a the array to be sorted
+     * @param fromIndex the index of the first element, inclusive, to be sorted
+     * @param toIndex the index of the last element, exclusive, to be sorted
+     * @throws IllegalArgumentException if {@code fromIndex > toIndex}
+     * @throws ArrayIndexOutOfBoundsException
+     *     if {@code fromIndex < 0} or {@code toIndex > a.length}
+     */
+    public static void sort(double[] a, int fromIndex, int toIndex) {
+        rangeCheck(a.length, fromIndex, toIndex);
+        sortNegZeroAndNaN(a, fromIndex, toIndex - 1);
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. The
+     * sort is done in three phases to avoid expensive comparisons in the
+     * inner loop. The comparisons would be expensive due to anomalies
+     * associated with negative zero {@code -0.0d} and {@code Double.NaN}.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void sortNegZeroAndNaN(double[] a, int left, int right) {
+        /*
+         * Phase 1: Count negative zeros and move NaNs to end of array
+         */
+        final long NEGATIVE_ZERO = Double.doubleToLongBits(-0.0d);
+        int numNegativeZeros = 0;
+        int n = right;
+
+        for (int k = left; k <= n; k++) {
+            double ak = a[k];
+            if (ak == 0.0d && NEGATIVE_ZERO == Double.doubleToLongBits(ak)) {
+                a[k] = 0.0d;
+                numNegativeZeros++;
+            } else if (ak != ak) { // i.e., ak is NaN
+                a[k--] = a[n];
+                a[n--] = Double.NaN;
+            }
+        }
+
+        /*
+         * Phase 2: Sort everything except NaNs (which are already in place)
+         */
+        doSort(a, left, n);
+
+        /*
+         * Phase 3: Turn positive zeros back into negative zeros as appropriate
+         */
+        if (numNegativeZeros == 0) {
+            return;
+        }
+
+        // Find first zero element
+        int zeroIndex = findAnyZero(a, left, n);
+
+        for (int i = zeroIndex - 1; i >= left && a[i] == 0.0d; i--) {
+            zeroIndex = i;
+        }
+
+        // Turn the right number of positive zeros back into negative zeros
+        for (int i = zeroIndex, m = zeroIndex + numNegativeZeros; i < m; i++) {
+            a[i] = -0.0d;
+        }
+    }
+
+    /**
+     * Returns the index of some zero element in the specified range via
+     * binary search. The range is assumed to be sorted, and must contain
+     * at least one zero.
+     *
+     * @param a the array to be searched
+     * @param low the index of the first element, inclusive, to be searched
+     * @param high the index of the last element, inclusive, to be searched
+     */
+    private static int findAnyZero(double[] a, int low, int high) {
+        while (true) {
+            int middle = (low + high) >>> 1;
+            double middleValue = a[middle];
+
+            if (middleValue < 0.0d) {
+                low = middle + 1;
+            } else if (middleValue > 0.0d) {
+                high = middle - 1;
+            } else { // middleValue == 0.0d
+                return middle;
+            }
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order. This
+     * method differs from the public {@code sort} method in three ways:
+     * {@code right} index is inclusive, it does no range checking on
+     * {@code left} or {@code right}, and it does not handle negative
+     * zeros or NaNs in the array.
+     *
+     * @param a the array to be sorted, which must not contain -0.0d and NaN
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void doSort(double[] a, int left, int right) {
+        // Use insertion sort on tiny arrays
+        if (right - left + 1 < INSERTION_SORT_THRESHOLD) {
+            for (int k = left + 1; k <= right; k++) {
+                double ak = a[k];
+                int j;
+                for (j = k - 1; j >= left && ak < a[j]; j--) {
+                    a[j + 1] = a[j];
+                }
+                a[j + 1] = ak;
+            }
+        } else { // Use Dual-Pivot Quicksort on large arrays
+            dualPivotQuicksort(a, left, right);
+        }
+    }
+
+    /**
+     * Sorts the specified range of the array into ascending order by the
+     * Dual-Pivot Quicksort algorithm.
+     *
+     * @param a the array to be sorted
+     * @param left the index of the first element, inclusive, to be sorted
+     * @param right the index of the last element, inclusive, to be sorted
+     */
+    private static void dualPivotQuicksort(double[] a, int left, int right) {
+        // Compute indices of five evenly spaced elements
+        int sixth = (right - left + 1) / 6;
+        int e1 = left  + sixth;
+        int e5 = right - sixth;
+        int e3 = (left + right) >>> 1; // The midpoint
+        int e4 = e3 + sixth;
+        int e2 = e3 - sixth;
+
+        // Sort these elements using a 5-element sorting network
+        double ae1 = a[e1], ae2 = a[e2], ae3 = a[e3], ae4 = a[e4], ae5 = a[e5];
+
+        if (ae1 > ae2) { double t = ae1; ae1 = ae2; ae2 = t; }
+        if (ae4 > ae5) { double t = ae4; ae4 = ae5; ae5 = t; }
+        if (ae1 > ae3) { double t = ae1; ae1 = ae3; ae3 = t; }
+        if (ae2 > ae3) { double t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae1 > ae4) { double t = ae1; ae1 = ae4; ae4 = t; }
+        if (ae3 > ae4) { double t = ae3; ae3 = ae4; ae4 = t; }
+        if (ae2 > ae5) { double t = ae2; ae2 = ae5; ae5 = t; }
+        if (ae2 > ae3) { double t = ae2; ae2 = ae3; ae3 = t; }
+        if (ae4 > ae5) { double t = ae4; ae4 = ae5; ae5 = t; }
+
+        a[e1] = ae1; a[e3] = ae3; a[e5] = ae5;
+
+        /*
+         * Use the second and fourth of the five sorted elements as pivots.
+         * These values are inexpensive approximations of the first and
+         * second terciles of the array. Note that pivot1 <= pivot2.
+         *
+         * The pivots are stored in local variables, and the first and
+         * the last of the sorted elements are moved to the locations
+         * formerly occupied by the pivots. When partitioning is complete,
+         * the pivots are swapped back into their final positions, and
+         * excluded from subsequent sorting.
+         */
+        double pivot1 = ae2; a[e2] = a[left];
+        double pivot2 = ae4; a[e4] = a[right];
+
+        /*
+         * Partitioning
+         *
+         *   left part         center part                  right part
+         * ------------------------------------------------------------
+         * [ < pivot1  |  pivot1 <= && <= pivot2  |   ?   |  > pivot2 ]
+         * ------------------------------------------------------------
+         *              ^                          ^     ^
+         *              |                          |     |
+         *             less                        k   great
+         */
+
+        // Pointers
+        int less  = left  + 1; // The index of first element of center part
+        int great = right - 1; // The index before first element of right part
+
+        boolean pivotsDiffer = pivot1 != pivot2;
+
+        if (pivotsDiffer) {
+            /*
+             * Invariants:
+             *              all in (left, less)   < pivot1
+             *    pivot1 <= all in [less, k)     <= pivot2
+             *              all in (great, right) > pivot2
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                double ak = a[k];
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else if (ak > pivot2) {
+                    while (a[great] > pivot2) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        } else { // Pivots are equal
+            /*
+             * Partition degenerates to the traditional 3-way
+             * (or "Dutch National Flag") partition:
+             *
+             *   left part   center part            right part
+             * -------------------------------------------------
+             * [  < pivot  |  == pivot  |    ?    |  > pivot   ]
+             * -------------------------------------------------
+             *
+             *              ^            ^       ^
+             *              |            |       |
+             *             less          k     great
+             *
+             * Invariants:
+             *
+             *   all in (left, less)   < pivot
+             *   all in [less, k)     == pivot
+             *   all in (great, right) > pivot
+             *
+             * Pointer k is the first index of ?-part
+             */
+            outer:
+            for (int k = less; k <= great; k++) {
+                double ak = a[k];
+                if (ak == pivot1) {
+                    continue;
+                }
+                if (ak < pivot1) {
+                    if (k > less) {
+                        a[k] = a[less];
+                        a[less] = ak;
+                    }
+                    less++;
+                } else { // a[k] > pivot
+                    while (a[great] > pivot1) {
+                        if (k == great--) {
+                            break outer;
+                        }
+                    }
+                    a[k] = a[great];
+                    a[great--] = ak;
+
+                    if ((ak = a[k]) <  pivot1) {
+                        a[k] = a[less];
+                        a[less++] = ak;
+                    }
+                }
+            }
+        }
+
+        // Swap pivots into their final positions
+        a[left]  = a[less  - 1]; a[less  - 1] = pivot1;
+        a[right] = a[great + 1]; a[great + 1] = pivot2;
+
+        // Sort left and right parts recursively, excluding known pivot values
+        doSort(a, left,   less - 2);
+        doSort(a, great + 2, right);
+
+        /*
+         * If pivot1 == pivot2, all elements from center
+         * part are equal and, therefore, already sorted
+         */
+        if (!pivotsDiffer) {
+            return;
+        }
+
+        /*
+         * If center part is too large (comprises > 5/6 of
+         * the array), swap internal pivot values to ends
+         */
+        if (less < e1 && e5 < great) {
+            while (a[less] == pivot1) {
+                less++;
+            }
+            while (a[great] == pivot2) {
+                great--;
+            }
+            for (int k = less + 1; k <= great; ) {
+                double ak = a[k];
+                if (ak == pivot1) {
+                    a[k++] = a[less];
+                    a[less++] = pivot1;
+                } else if (ak == pivot2) {
+                    a[k] = a[great];
+                    a[great--] = pivot2;
+                } else {
+                    k++;
+                }
+            }
+        }
+
+        // Sort center part recursively, excluding known pivot values
+        doSort(a, less, great);
+    }
+
+    /**
+     * Checks that {@code fromIndex} and {@code toIndex} are in
+     * the range and throws an appropriate exception, if they aren't.
+     */
+    private static void rangeCheck(int length, int fromIndex, int toIndex) {
+        if (fromIndex > toIndex) {
+            throw new IllegalArgumentException(
+                "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
+        }
+        if (fromIndex < 0) {
+            throw new ArrayIndexOutOfBoundsException(fromIndex);
+        }
+        if (toIndex > length) {
+            throw new ArrayIndexOutOfBoundsException(toIndex);
+        }
+    }
+}
--- a/src/share/classes/java/util/Formatter.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/Formatter.java	Wed Nov 25 11:08:25 2009 -0800
@@ -2485,55 +2485,45 @@
 
     private static Pattern fsPattern = Pattern.compile(formatSpecifier);
 
-    // Look for format specifiers in the format string.
+    /**
+     * Finds format specifiers in the format string.
+     */
     private FormatString[] parse(String s) {
-        ArrayList al = new ArrayList();
+        ArrayList<FormatString> al = new ArrayList<FormatString>();
         Matcher m = fsPattern.matcher(s);
-        int i = 0;
-        while (i < s.length()) {
+        for (int i = 0, len = s.length(); i < len; ) {
             if (m.find(i)) {
                 // Anything between the start of the string and the beginning
                 // of the format specifier is either fixed text or contains
                 // an invalid format string.
                 if (m.start() != i) {
                     // Make sure we didn't miss any invalid format specifiers
-                    checkText(s.substring(i, m.start()));
+                    checkText(s, i, m.start());
                     // Assume previous characters were fixed text
                     al.add(new FixedString(s.substring(i, m.start())));
                 }
 
-                // Expect 6 groups in regular expression
-                String[] sa = new String[6];
-                for (int j = 0; j < m.groupCount(); j++)
-                    {
-                    sa[j] = m.group(j + 1);
-//                  System.out.print(sa[j] + " ");
-                    }
-//              System.out.println();
-                al.add(new FormatSpecifier(this, sa));
+                al.add(new FormatSpecifier(m));
                 i = m.end();
             } else {
                 // No more valid format specifiers.  Check for possible invalid
                 // format specifiers.
-                checkText(s.substring(i));
+                checkText(s, i, len);
                 // The rest of the string is fixed text
                 al.add(new FixedString(s.substring(i)));
                 break;
             }
         }
-//      FormatString[] fs = new FormatString[al.size()];
-//      for (int j = 0; j < al.size(); j++)
-//          System.out.println(((FormatString) al.get(j)).toString());
-        return (FormatString[]) al.toArray(new FormatString[0]);
+        return al.toArray(new FormatString[al.size()]);
     }
 
-    private void checkText(String s) {
-        int idx;
-        // If there are any '%' in the given string, we got a bad format
-        // specifier.
-        if ((idx = s.indexOf('%')) != -1) {
-            char c = (idx > s.length() - 2 ? '%' : s.charAt(idx + 1));
-            throw new UnknownFormatConversionException(String.valueOf(c));
+    private static void checkText(String s, int start, int end) {
+        for (int i = start; i < end; i++) {
+            // Any '%' found in the region starts an invalid format specifier.
+            if (s.charAt(i) == '%') {
+                char c = (i == end - 1) ? '%' : s.charAt(i + 1);
+                throw new UnknownFormatConversionException(String.valueOf(c));
+            }
         }
     }
 
@@ -2562,8 +2552,6 @@
         private boolean dt = false;
         private char c;
 
-        private Formatter formatter;
-
         // cache the line separator
         private String ls;
 
@@ -2650,21 +2638,22 @@
             return c;
         }
 
-        FormatSpecifier(Formatter formatter, String[] sa) {
-            this.formatter = formatter;
-            int idx = 0;
-
-            index(sa[idx++]);
-            flags(sa[idx++]);
-            width(sa[idx++]);
-            precision(sa[idx++]);
-
-            if (sa[idx] != null) {
+        FormatSpecifier(Matcher m) {
+            int idx = 1;
+
+            index(m.group(idx++));
+            flags(m.group(idx++));
+            width(m.group(idx++));
+            precision(m.group(idx++));
+
+            String tT = m.group(idx++);
+            if (tT != null) {
                 dt = true;
-                if (sa[idx].equals("T"))
+                if (tT.equals("T"))
                     f.add(Flags.UPPERCASE);
             }
-            conversion(sa[++idx]);
+
+            conversion(m.group(idx));
 
             if (dt)
                 checkDateTime();
@@ -2819,9 +2808,9 @@
 
         private void printString(Object arg, Locale l) throws IOException {
             if (arg instanceof Formattable) {
-                Formatter fmt = formatter;
-                if (formatter.locale() != l)
-                    fmt = new Formatter(formatter.out(), l);
+                Formatter fmt = Formatter.this;
+                if (fmt.locale() != l)
+                    fmt = new Formatter(fmt.out(), l);
                 ((Formattable)arg).formatTo(fmt, f.valueOf(), width, precision);
             } else {
                 if (f.contains(Flags.ALTERNATE))
--- a/src/share/classes/java/util/LinkedList.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/LinkedList.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,22 +26,22 @@
 package java.util;
 
 /**
- * Linked list implementation of the <tt>List</tt> interface.  Implements all
+ * Linked list implementation of the {@code List} interface.  Implements all
  * optional list operations, and permits all elements (including
- * <tt>null</tt>).  In addition to implementing the <tt>List</tt> interface,
- * the <tt>LinkedList</tt> class provides uniformly named methods to
- * <tt>get</tt>, <tt>remove</tt> and <tt>insert</tt> an element at the
+ * {@code null}).  In addition to implementing the {@code List} interface,
+ * the {@code LinkedList} class provides uniformly named methods to
+ * {@code get}, {@code remove} and {@code insert} an element at the
  * beginning and end of the list.  These operations allow linked lists to be
  * used as a stack, {@linkplain Queue queue}, or {@linkplain Deque
- * double-ended queue}. <p>
+ * double-ended queue}.
  *
- * The class implements the <tt>Deque</tt> interface, providing
- * first-in-first-out queue operations for <tt>add</tt>,
- * <tt>poll</tt>, along with other stack and deque operations.<p>
+ * <p>The class implements the {@code Deque} interface, providing
+ * first-in-first-out queue operations for {@code add},
+ * {@code poll}, along with other stack and deque operations.
  *
- * All of the operations perform as could be expected for a doubly-linked
+ * <p>All of the operations perform as could be expected for a doubly-linked
  * list.  Operations that index into the list will traverse the list from
- * the beginning or the end, whichever is closer to the specified index.<p>
+ * the beginning or the end, whichever is closer to the specified index.
  *
  * <p><strong>Note that this implementation is not synchronized.</strong>
  * If multiple threads access a linked list concurrently, and at least
@@ -58,11 +58,11 @@
  * unsynchronized access to the list:<pre>
  *   List list = Collections.synchronizedList(new LinkedList(...));</pre>
  *
- * <p>The iterators returned by this class's <tt>iterator</tt> and
- * <tt>listIterator</tt> methods are <i>fail-fast</i>: if the list is
+ * <p>The iterators returned by this class's {@code iterator} and
+ * {@code listIterator} methods are <i>fail-fast</i>: if the list is
  * structurally modified at any time after the iterator is created, in
- * any way except through the Iterator's own <tt>remove</tt> or
- * <tt>add</tt> methods, the iterator will throw a {@link
+ * any way except through the Iterator's own {@code remove} or
+ * {@code add} methods, the iterator will throw a {@link
  * ConcurrentModificationException}.  Thus, in the face of concurrent
  * modification, the iterator fails quickly and cleanly, rather than
  * risking arbitrary, non-deterministic behavior at an undetermined
@@ -71,7 +71,7 @@
  * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed
  * as it is, generally speaking, impossible to make any hard guarantees in the
  * presence of unsynchronized concurrent modification.  Fail-fast iterators
- * throw <tt>ConcurrentModificationException</tt> on a best-effort basis.
+ * throw {@code ConcurrentModificationException} on a best-effort basis.
  * Therefore, it would be wrong to write a program that depended on this
  * exception for its correctness:   <i>the fail-fast behavior of iterators
  * should be used only to detect bugs.</i>
@@ -83,7 +83,6 @@
  * @author  Josh Bloch
  * @see     List
  * @see     ArrayList
- * @see     Vector
  * @since 1.2
  * @param <E> the type of elements held in this collection
  */
@@ -92,14 +91,26 @@
     extends AbstractSequentialList<E>
     implements List<E>, Deque<E>, Cloneable, java.io.Serializable
 {
-    private transient Entry<E> header = new Entry<E>(null, null, null);
-    private transient int size = 0;
+    transient int size = 0;
+
+    /**
+     * Pointer to first node.
+     * Invariant: (first == null && last == null) ||
+     *            (first.prev == null && first.item != null)
+     */
+    transient Node<E> first;
+
+    /**
+     * Pointer to last node.
+     * Invariant: (first == null && last == null) ||
+     *            (last.next == null && last.item != null)
+     */
+    transient Node<E> last;
 
     /**
      * Constructs an empty list.
      */
     public LinkedList() {
-        header.next = header.previous = header;
     }
 
     /**
@@ -116,16 +127,129 @@
     }
 
     /**
+     * Links e as first element.
+     */
+    private void linkFirst(E e) {
+        final Node<E> f = first;
+        final Node<E> newNode = new Node<E>(null, e, f);
+        first = newNode;
+        if (f == null)
+            last = newNode;
+        else
+            f.prev = newNode;
+        size++;
+        modCount++;
+    }
+
+    /**
+     * Links e as last element.
+     */
+    void linkLast(E e) {
+        final Node<E> l = last;
+        final Node<E> newNode = new Node<E>(l, e, null);
+        last = newNode;
+        if (l == null)
+            first = newNode;
+        else
+            l.next = newNode;
+        size++;
+        modCount++;
+    }
+
+    /**
+     * Inserts element e before non-null Node succ.
+     */
+    void linkBefore(E e, Node<E> succ) {
+        // assert succ != null;
+        final Node<E> pred = succ.prev;
+        final Node<E> newNode = new Node<E>(pred, e, succ);
+        succ.prev = newNode;
+        if (pred == null)
+            first = newNode;
+        else
+            pred.next = newNode;
+        size++;
+        modCount++;
+    }
+
+    /**
+     * Unlinks non-null first node f.
+     */
+    private E unlinkFirst(Node<E> f) {
+        // assert f == first && f != null;
+        final E element = f.item;
+        final Node<E> next = f.next;
+        f.item = null;
+        f.next = null; // help GC
+        first = next;
+        if (next == null)
+            last = null;
+        else
+            next.prev = null;
+        size--;
+        modCount++;
+        return element;
+    }
+
+    /**
+     * Unlinks non-null last node l.
+     */
+    private E unlinkLast(Node<E> l) {
+        // assert l == last && l != null;
+        final E element = l.item;
+        final Node<E> prev = l.prev;
+        l.item = null;
+        l.prev = null; // help GC
+        last = prev;
+        if (prev == null)
+            first = null;
+        else
+            prev.next = null;
+        size--;
+        modCount++;
+        return element;
+    }
+
+    /**
+     * Unlinks non-null node x.
+     */
+    E unlink(Node<E> x) {
+        // assert x != null;
+        final E element = x.item;
+        final Node<E> next = x.next;
+        final Node<E> prev = x.prev;
+
+        if (prev == null) {
+            first = next;
+        } else {
+            prev.next = next;
+            x.prev = null;
+        }
+
+        if (next == null) {
+            last = prev;
+        } else {
+            next.prev = prev;
+            x.next = null;
+        }
+
+        x.item = null;
+        size--;
+        modCount++;
+        return element;
+    }
+
+    /**
      * Returns the first element in this list.
      *
      * @return the first element in this list
      * @throws NoSuchElementException if this list is empty
      */
     public E getFirst() {
-        if (size==0)
+        final Node<E> f = first;
+        if (f == null)
             throw new NoSuchElementException();
-
-        return header.next.element;
+        return f.item;
     }
 
     /**
@@ -135,10 +259,10 @@
      * @throws NoSuchElementException if this list is empty
      */
     public E getLast()  {
-        if (size==0)
+        final Node<E> l = last;
+        if (l == null)
             throw new NoSuchElementException();
-
-        return header.previous.element;
+        return l.item;
     }
 
     /**
@@ -148,7 +272,10 @@
      * @throws NoSuchElementException if this list is empty
      */
     public E removeFirst() {
-        return remove(header.next);
+        final Node<E> f = first;
+        if (f == null)
+            throw new NoSuchElementException();
+        return unlinkFirst(f);
     }
 
     /**
@@ -158,7 +285,10 @@
      * @throws NoSuchElementException if this list is empty
      */
     public E removeLast() {
-        return remove(header.previous);
+        final Node<E> l = last;
+        if (l == null)
+            throw new NoSuchElementException();
+        return unlinkLast(l);
     }
 
     /**
@@ -167,7 +297,7 @@
      * @param e the element to add
      */
     public void addFirst(E e) {
-        addBefore(e, header.next);
+        linkFirst(e);
     }
 
     /**
@@ -178,17 +308,17 @@
      * @param e the element to add
      */
     public void addLast(E e) {
-        addBefore(e, header);
+        linkLast(e);
     }
 
     /**
-     * Returns <tt>true</tt> if this list contains the specified element.
-     * More formally, returns <tt>true</tt> if and only if this list contains
-     * at least one element <tt>e</tt> such that
+     * Returns {@code true} if this list contains the specified element.
+     * More formally, returns {@code true} if and only if this list contains
+     * at least one element {@code e} such that
      * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
      *
      * @param o element whose presence in this list is to be tested
-     * @return <tt>true</tt> if this list contains the specified element
+     * @return {@code true} if this list contains the specified element
      */
     public boolean contains(Object o) {
         return indexOf(o) != -1;
@@ -209,10 +339,10 @@
      * <p>This method is equivalent to {@link #addLast}.
      *
      * @param e element to be appended to this list
-     * @return <tt>true</tt> (as specified by {@link Collection#add})
+     * @return {@code true} (as specified by {@link Collection#add})
      */
     public boolean add(E e) {
-        addBefore(e, header);
+        linkLast(e);
         return true;
     }
 
@@ -220,27 +350,27 @@
      * Removes the first occurrence of the specified element from this list,
      * if it is present.  If this list does not contain the element, it is
      * unchanged.  More formally, removes the element with the lowest index
-     * <tt>i</tt> such that
+     * {@code i} such that
      * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>
-     * (if such an element exists).  Returns <tt>true</tt> if this list
+     * (if such an element exists).  Returns {@code true} if this list
      * contained the specified element (or equivalently, if this list
      * changed as a result of the call).
      *
      * @param o element to be removed from this list, if present
-     * @return <tt>true</tt> if this list contained the specified element
+     * @return {@code true} if this list contained the specified element
      */
     public boolean remove(Object o) {
-        if (o==null) {
-            for (Entry<E> e = header.next; e != header; e = e.next) {
-                if (e.element==null) {
-                    remove(e);
+        if (o == null) {
+            for (Node<E> x = first; x != null; x = x.next) {
+                if (x.item == null) {
+                    unlink(x);
                     return true;
                 }
             }
         } else {
-            for (Entry<E> e = header.next; e != header; e = e.next) {
-                if (o.equals(e.element)) {
-                    remove(e);
+            for (Node<E> x = first; x != null; x = x.next) {
+                if (o.equals(x.item)) {
+                    unlink(x);
                     return true;
                 }
             }
@@ -257,7 +387,7 @@
      * this list, and it's nonempty.)
      *
      * @param c collection containing elements to be added to this list
-     * @return <tt>true</tt> if this list changed as a result of the call
+     * @return {@code true} if this list changed as a result of the call
      * @throws NullPointerException if the specified collection is null
      */
     public boolean addAll(Collection<? extends E> c) {
@@ -275,45 +405,66 @@
      * @param index index at which to insert the first element
      *              from the specified collection
      * @param c collection containing elements to be added to this list
-     * @return <tt>true</tt> if this list changed as a result of the call
+     * @return {@code true} if this list changed as a result of the call
      * @throws IndexOutOfBoundsException {@inheritDoc}
      * @throws NullPointerException if the specified collection is null
      */
     public boolean addAll(int index, Collection<? extends E> c) {
-        if (index < 0 || index > size)
-            throw new IndexOutOfBoundsException("Index: "+index+
-                                                ", Size: "+size);
+        checkPositionIndex(index);
+
         Object[] a = c.toArray();
         int numNew = a.length;
-        if (numNew==0)
+        if (numNew == 0)
             return false;
-        modCount++;
+
+        Node<E> pred, succ;
+        if (index == size) {
+            succ = null;
+            pred = last;
+        } else {
+            succ = node(index);
+            pred = succ.prev;
+        }
 
-        Entry<E> successor = (index==size ? header : entry(index));
-        Entry<E> predecessor = successor.previous;
-        for (int i=0; i<numNew; i++) {
-            Entry<E> e = new Entry<E>((E)a[i], successor, predecessor);
-            predecessor.next = e;
-            predecessor = e;
+        for (Object o : a) {
+            @SuppressWarnings("unchecked") E e = (E) o;
+            Node<E> newNode = new Node<E>(pred, e, null);
+            if (pred == null)
+                first = newNode;
+            else
+                pred.next = newNode;
+            pred = newNode;
         }
-        successor.previous = predecessor;
+
+        if (succ == null) {
+            last = pred;
+        } else {
+            pred.next = succ;
+            succ.prev = pred;
+        }
 
         size += numNew;
+        modCount++;
         return true;
     }
 
     /**
      * Removes all of the elements from this list.
+     * The list will be empty after this call returns.
      */
     public void clear() {
-        Entry<E> e = header.next;
-        while (e != header) {
-            Entry<E> next = e.next;
-            e.next = e.previous = null;
-            e.element = null;
-            e = next;
+        // Clearing all of the links between nodes is "unnecessary", but:
+        // - helps a generational GC if the discarded nodes inhabit
+        //   more than one generation
+        // - is sure to free memory even if there is a reachable Iterator
+        for (Node<E> x = first; x != null; ) {
+            Node<E> next = x.next;
+            x.item = null;
+            x.next = null;
+            x.prev = null;
+            x = next;
         }
-        header.next = header.previous = header;
+        first = last = null;
         size = 0;
         modCount++;
     }
@@ -329,7 +480,8 @@
      * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public E get(int index) {
-        return entry(index).element;
+        checkElementIndex(index);
+        return node(index).item;
     }
 
     /**
@@ -342,9 +494,10 @@
      * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public E set(int index, E element) {
-        Entry<E> e = entry(index);
-        E oldVal = e.element;
-        e.element = element;
+        checkElementIndex(index);
+        Node<E> x = node(index);
+        E oldVal = x.item;
+        x.item = element;
         return oldVal;
     }
 
@@ -358,7 +511,12 @@
      * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public void add(int index, E element) {
-        addBefore(element, (index==size ? header : entry(index)));
+        checkPositionIndex(index);
+
+        if (index == size)
+            linkLast(element);
+        else
+            linkBefore(element, node(index));
     }
 
     /**
@@ -371,34 +529,69 @@
      * @throws IndexOutOfBoundsException {@inheritDoc}
      */
     public E remove(int index) {
-        return remove(entry(index));
+        checkElementIndex(index);
+        return unlink(node(index));
+    }
+
+    /**
+     * Tells if the argument is the index of an existing element.
+     */
+    private boolean isElementIndex(int index) {
+        return index >= 0 && index < size;
+    }
+
+    /**
+     * Tells if the argument is the index of a valid position for an
+     * iterator or an add operation.
+     */
+    private boolean isPositionIndex(int index) {
+        return index >= 0 && index <= size;
     }
 
     /**
-     * Returns the indexed entry.
+     * Constructs an IndexOutOfBoundsException detail message.
+     * Of the many possible refactorings of the error handling code,
+     * this "outlining" performs best with both server and client VMs.
      */
-    private Entry<E> entry(int index) {
-        if (index < 0 || index >= size)
-            throw new IndexOutOfBoundsException("Index: "+index+
-                                                ", Size: "+size);
-        Entry<E> e = header;
-        if (index < (size >> 1)) {
-            for (int i = 0; i <= index; i++)
-                e = e.next;
-        } else {
-            for (int i = size; i > index; i--)
-                e = e.previous;
-        }
-        return e;
+    private String outOfBoundsMsg(int index) {
+        return "Index: "+index+", Size: "+size;
+    }
+
+    private void checkElementIndex(int index) {
+        if (!isElementIndex(index))
+            throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
+    }
+
+    private void checkPositionIndex(int index) {
+        if (!isPositionIndex(index))
+            throw new IndexOutOfBoundsException(outOfBoundsMsg(index));
     }
 
+    /**
+     * Returns the (non-null) Node at the specified element index.
+     */
+    Node<E> node(int index) {
+        // assert isElementIndex(index);
+
+        if (index < (size >> 1)) {
+            Node<E> x = first;
+            for (int i = 0; i < index; i++)
+                x = x.next;
+            return x;
+        } else {
+            Node<E> x = last;
+            for (int i = size - 1; i > index; i--)
+                x = x.prev;
+            return x;
+        }
+    }
 
     // Search Operations
 
     /**
      * Returns the index of the first occurrence of the specified element
      * in this list, or -1 if this list does not contain the element.
-     * More formally, returns the lowest index <tt>i</tt> such that
+     * More formally, returns the lowest index {@code i} such that
      * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
      * or -1 if there is no such index.
      *
@@ -408,15 +601,15 @@
      */
     public int indexOf(Object o) {
         int index = 0;
-        if (o==null) {
-            for (Entry e = header.next; e != header; e = e.next) {
-                if (e.element==null)
+        if (o == null) {
+            for (Node<E> x = first; x != null; x = x.next) {
+                if (x.item == null)
                     return index;
                 index++;
             }
         } else {
-            for (Entry e = header.next; e != header; e = e.next) {
-                if (o.equals(e.element))
+            for (Node<E> x = first; x != null; x = x.next) {
+                if (o.equals(x.item))
                     return index;
                 index++;
             }
@@ -427,7 +620,7 @@
     /**
      * Returns the index of the last occurrence of the specified element
      * in this list, or -1 if this list does not contain the element.
-     * More formally, returns the highest index <tt>i</tt> such that
+     * More formally, returns the highest index {@code i} such that
      * <tt>(o==null&nbsp;?&nbsp;get(i)==null&nbsp;:&nbsp;o.equals(get(i)))</tt>,
      * or -1 if there is no such index.
      *
@@ -437,16 +630,16 @@
      */
     public int lastIndexOf(Object o) {
         int index = size;
-        if (o==null) {
-            for (Entry e = header.previous; e != header; e = e.previous) {
+        if (o == null) {
+            for (Node<E> x = last; x != null; x = x.prev) {
                 index--;
-                if (e.element==null)
+                if (x.item == null)
                     return index;
             }
         } else {
-            for (Entry e = header.previous; e != header; e = e.previous) {
+            for (Node<E> x = last; x != null; x = x.prev) {
                 index--;
-                if (o.equals(e.element))
+                if (o.equals(x.item))
                     return index;
             }
         }
@@ -457,17 +650,18 @@
 
     /**
      * Retrieves, but does not remove, the head (first element) of this list.
-     * @return the head of this list, or <tt>null</tt> if this list is empty
+     *
+     * @return the head of this list, or {@code null} if this list is empty
      * @since 1.5
      */
     public E peek() {
-        if (size==0)
-            return null;
-        return getFirst();
+        final Node<E> f = first;
+        return (f == null) ? null : f.item;
     }
 
     /**
      * Retrieves, but does not remove, the head (first element) of this list.
+     *
      * @return the head of this list
      * @throws NoSuchElementException if this list is empty
      * @since 1.5
@@ -477,14 +671,14 @@
     }
 
     /**
-     * Retrieves and removes the head (first element) of this list
-     * @return the head of this list, or <tt>null</tt> if this list is empty
+     * Retrieves and removes the head (first element) of this list.
+     *
+     * @return the head of this list, or {@code null} if this list is empty
      * @since 1.5
      */
     public E poll() {
-        if (size==0)
-            return null;
-        return removeFirst();
+        final Node<E> f = first;
+        return (f == null) ? null : unlinkFirst(f);
     }
 
     /**
@@ -502,7 +696,7 @@
      * Adds the specified element as the tail (last element) of this list.
      *
      * @param e the element to add
-     * @return <tt>true</tt> (as specified by {@link Queue#offer})
+     * @return {@code true} (as specified by {@link Queue#offer})
      * @since 1.5
      */
     public boolean offer(E e) {
@@ -514,7 +708,7 @@
      * Inserts the specified element at the front of this list.
      *
      * @param e the element to insert
-     * @return <tt>true</tt> (as specified by {@link Deque#offerFirst})
+     * @return {@code true} (as specified by {@link Deque#offerFirst})
      * @since 1.6
      */
     public boolean offerFirst(E e) {
@@ -526,7 +720,7 @@
      * Inserts the specified element at the end of this list.
      *
      * @param e the element to insert
-     * @return <tt>true</tt> (as specified by {@link Deque#offerLast})
+     * @return {@code true} (as specified by {@link Deque#offerLast})
      * @since 1.6
      */
     public boolean offerLast(E e) {
@@ -536,58 +730,54 @@
 
     /**
      * Retrieves, but does not remove, the first element of this list,
-     * or returns <tt>null</tt> if this list is empty.
+     * or returns {@code null} if this list is empty.
      *
-     * @return the first element of this list, or <tt>null</tt>
+     * @return the first element of this list, or {@code null}
      *         if this list is empty
      * @since 1.6
      */
     public E peekFirst() {
-        if (size==0)
-            return null;
-        return getFirst();
-    }
+        final Node<E> f = first;
+        return (f == null) ? null : f.item;
+     }
 
     /**
      * Retrieves, but does not remove, the last element of this list,
-     * or returns <tt>null</tt> if this list is empty.
+     * or returns {@code null} if this list is empty.
      *
-     * @return the last element of this list, or <tt>null</tt>
+     * @return the last element of this list, or {@code null}
      *         if this list is empty
      * @since 1.6
      */
     public E peekLast() {
-        if (size==0)
-            return null;
-        return getLast();
+        final Node<E> l = last;
+        return (l == null) ? null : l.item;
     }
 
     /**
      * Retrieves and removes the first element of this list,
-     * or returns <tt>null</tt> if this list is empty.
+     * or returns {@code null} if this list is empty.
      *
-     * @return the first element of this list, or <tt>null</tt> if
+     * @return the first element of this list, or {@code null} if
      *     this list is empty
      * @since 1.6
      */
     public E pollFirst() {
-        if (size==0)
-            return null;
-        return removeFirst();
+        final Node<E> f = first;
+        return (f == null) ? null : unlinkFirst(f);
     }
 
     /**
      * Retrieves and removes the last element of this list,
-     * or returns <tt>null</tt> if this list is empty.
+     * or returns {@code null} if this list is empty.
      *
-     * @return the last element of this list, or <tt>null</tt> if
+     * @return the last element of this list, or {@code null} if
      *     this list is empty
      * @since 1.6
      */
     public E pollLast() {
-        if (size==0)
-            return null;
-        return removeLast();
+        final Node<E> l = last;
+        return (l == null) ? null : unlinkLast(l);
     }
 
     /**
@@ -624,7 +814,7 @@
      * does not contain the element, it is unchanged.
      *
      * @param o element to be removed from this list, if present
-     * @return <tt>true</tt> if the list contained the specified element
+     * @return {@code true} if the list contained the specified element
      * @since 1.6
      */
     public boolean removeFirstOccurrence(Object o) {
@@ -637,21 +827,21 @@
      * does not contain the element, it is unchanged.
      *
      * @param o element to be removed from this list, if present
-     * @return <tt>true</tt> if the list contained the specified element
+     * @return {@code true} if the list contained the specified element
      * @since 1.6
      */
     public boolean removeLastOccurrence(Object o) {
-        if (o==null) {
-            for (Entry<E> e = header.previous; e != header; e = e.previous) {
-                if (e.element==null) {
-                    remove(e);
+        if (o == null) {
+            for (Node<E> x = last; x != null; x = x.prev) {
+                if (x.item == null) {
+                    unlink(x);
                     return true;
                 }
             }
         } else {
-            for (Entry<E> e = header.previous; e != header; e = e.previous) {
-                if (o.equals(e.element)) {
-                    remove(e);
+            for (Node<E> x = last; x != null; x = x.prev) {
+                if (o.equals(x.item)) {
+                    unlink(x);
                     return true;
                 }
             }
@@ -662,76 +852,68 @@
     /**
      * Returns a list-iterator of the elements in this list (in proper
      * sequence), starting at the specified position in the list.
-     * Obeys the general contract of <tt>List.listIterator(int)</tt>.<p>
+     * Obeys the general contract of {@code List.listIterator(int)}.<p>
      *
      * The list-iterator is <i>fail-fast</i>: if the list is structurally
      * modified at any time after the Iterator is created, in any way except
-     * through the list-iterator's own <tt>remove</tt> or <tt>add</tt>
+     * through the list-iterator's own {@code remove} or {@code add}
      * methods, the list-iterator will throw a
-     * <tt>ConcurrentModificationException</tt>.  Thus, in the face of
+     * {@code ConcurrentModificationException}.  Thus, in the face of
      * concurrent modification, the iterator fails quickly and cleanly, rather
      * than risking arbitrary, non-deterministic behavior at an undetermined
      * time in the future.
      *
      * @param index index of the first element to be returned from the
-     *              list-iterator (by a call to <tt>next</tt>)
+     *              list-iterator (by a call to {@code next})
      * @return a ListIterator of the elements in this list (in proper
      *         sequence), starting at the specified position in the list
      * @throws IndexOutOfBoundsException {@inheritDoc}
      * @see List#listIterator(int)
      */
     public ListIterator<E> listIterator(int index) {
+        checkPositionIndex(index);
         return new ListItr(index);
     }
 
     private class ListItr implements ListIterator<E> {
-        private Entry<E> lastReturned = header;
-        private Entry<E> next;
+        private Node<E> lastReturned = null;
+        private Node<E> next;
         private int nextIndex;
         private int expectedModCount = modCount;
 
         ListItr(int index) {
-            if (index < 0 || index > size)
-                throw new IndexOutOfBoundsException("Index: "+index+
-                                                    ", Size: "+size);
-            if (index < (size >> 1)) {
-                next = header.next;
-                for (nextIndex=0; nextIndex<index; nextIndex++)
-                    next = next.next;
-            } else {
-                next = header;
-                for (nextIndex=size; nextIndex>index; nextIndex--)
-                    next = next.previous;
-            }
+            // assert isPositionIndex(index);
+            next = (index == size) ? null : node(index);
+            nextIndex = index;
         }
 
         public boolean hasNext() {
-            return nextIndex != size;
+            return nextIndex < size;
         }
 
         public E next() {
             checkForComodification();
-            if (nextIndex == size)
+            if (!hasNext())
                 throw new NoSuchElementException();
 
             lastReturned = next;
             next = next.next;
             nextIndex++;
-            return lastReturned.element;
+            return lastReturned.item;
         }
 
         public boolean hasPrevious() {
-            return nextIndex != 0;
+            return nextIndex > 0;
         }
 
         public E previous() {
-            if (nextIndex == 0)
+            checkForComodification();
+            if (!hasPrevious())
                 throw new NoSuchElementException();
 
-            lastReturned = next = next.previous;
+            lastReturned = next = (next == null) ? last : next.prev;
             nextIndex--;
-            checkForComodification();
-            return lastReturned.element;
+            return lastReturned.item;
         }
 
         public int nextIndex() {
@@ -739,36 +921,38 @@
         }
 
         public int previousIndex() {
-            return nextIndex-1;
+            return nextIndex - 1;
         }
 
         public void remove() {
             checkForComodification();
-            Entry<E> lastNext = lastReturned.next;
-            try {
-                LinkedList.this.remove(lastReturned);
-            } catch (NoSuchElementException e) {
+            if (lastReturned == null)
                 throw new IllegalStateException();
-            }
-            if (next==lastReturned)
+
+            Node<E> lastNext = lastReturned.next;
+            unlink(lastReturned);
+            if (next == lastReturned)
                 next = lastNext;
             else
                 nextIndex--;
-            lastReturned = header;
+            lastReturned = null;
             expectedModCount++;
         }
 
         public void set(E e) {
-            if (lastReturned == header)
+            if (lastReturned == null)
                 throw new IllegalStateException();
             checkForComodification();
-            lastReturned.element = e;
+            lastReturned.item = e;
         }
 
         public void add(E e) {
             checkForComodification();
-            lastReturned = header;
-            addBefore(e, next);
+            lastReturned = null;
+            if (next == null)
+                linkLast(e);
+            else
+                linkBefore(e, next);
             nextIndex++;
             expectedModCount++;
         }
@@ -779,39 +963,16 @@
         }
     }
 
-    private static class Entry<E> {
-        E element;
-        Entry<E> next;
-        Entry<E> previous;
-
-        Entry(E element, Entry<E> next, Entry<E> previous) {
-            this.element = element;
-            this.next = next;
-            this.previous = previous;
-        }
-    }
+    private static class Node<E> {
+        E item;
+        Node<E> next;
+        Node<E> prev;
 
-    private Entry<E> addBefore(E e, Entry<E> entry) {
-        Entry<E> newEntry = new Entry<E>(e, entry, entry.previous);
-        newEntry.previous.next = newEntry;
-        newEntry.next.previous = newEntry;
-        size++;
-        modCount++;
-        return newEntry;
-    }
-
-    private E remove(Entry<E> e) {
-        if (e == header)
-            throw new NoSuchElementException();
-
-        E result = e.element;
-        e.previous.next = e.next;
-        e.next.previous = e.previous;
-        e.next = e.previous = null;
-        e.element = null;
-        size--;
-        modCount++;
-        return result;
+        Node(Node<E> prev, E element, Node<E> next) {
+            this.item = element;
+            this.next = next;
+            this.prev = prev;
+        }
     }
 
     /**
@@ -821,9 +982,11 @@
         return new DescendingIterator();
     }
 
-    /** Adapter to provide descending iterators via ListItr.previous */
-    private class DescendingIterator implements Iterator {
-        final ListItr itr = new ListItr(size());
+    /**
+     * Adapter to provide descending iterators via ListItr.previous
+     */
+    private class DescendingIterator implements Iterator<E> {
+        private final ListItr itr = new ListItr(size());
         public boolean hasNext() {
             return itr.hasPrevious();
         }
@@ -835,29 +998,32 @@
         }
     }
 
-    /**
-     * Returns a shallow copy of this <tt>LinkedList</tt>. (The elements
-     * themselves are not cloned.)
-     *
-     * @return a shallow copy of this <tt>LinkedList</tt> instance
-     */
-    public Object clone() {
-        LinkedList<E> clone = null;
+    @SuppressWarnings("unchecked")
+    private LinkedList<E> superClone() {
         try {
-            clone = (LinkedList<E>) super.clone();
+            return (LinkedList<E>) super.clone();
         } catch (CloneNotSupportedException e) {
             throw new InternalError();
         }
+    }
+
+    /**
+     * Returns a shallow copy of this {@code LinkedList}. (The elements
+     * themselves are not cloned.)
+     *
+     * @return a shallow copy of this {@code LinkedList} instance
+     */
+    public Object clone() {
+        LinkedList<E> clone = superClone();
 
         // Put clone into "virgin" state
-        clone.header = new Entry<E>(null, null, null);
-        clone.header.next = clone.header.previous = clone.header;
+        clone.first = clone.last = null;
         clone.size = 0;
         clone.modCount = 0;
 
         // Initialize clone with our elements
-        for (Entry<E> e = header.next; e != header; e = e.next)
-            clone.add(e.element);
+        for (Node<E> x = first; x != null; x = x.next)
+            clone.add(x.item);
 
         return clone;
     }
@@ -879,8 +1045,8 @@
     public Object[] toArray() {
         Object[] result = new Object[size];
         int i = 0;
-        for (Entry<E> e = header.next; e != header; e = e.next)
-            result[i++] = e.element;
+        for (Node<E> x = first; x != null; x = x.next)
+            result[i++] = x.item;
         return result;
     }
 
@@ -894,7 +1060,7 @@
      *
      * <p>If the list fits in the specified array with room to spare (i.e.,
      * the array has more elements than the list), the element in the array
-     * immediately following the end of the list is set to <tt>null</tt>.
+     * immediately following the end of the list is set to {@code null}.
      * (This is useful in determining the length of the list <i>only</i> if
      * the caller knows that the list does not contain any null elements.)
      *
@@ -903,15 +1069,15 @@
      * precise control over the runtime type of the output array, and may,
      * under certain circumstances, be used to save allocation costs.
      *
-     * <p>Suppose <tt>x</tt> is a list known to contain only strings.
+     * <p>Suppose {@code x} is a list known to contain only strings.
      * The following code can be used to dump the list into a newly
-     * allocated array of <tt>String</tt>:
+     * allocated array of {@code String}:
      *
      * <pre>
      *     String[] y = x.toArray(new String[0]);</pre>
      *
-     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
-     * <tt>toArray()</tt>.
+     * Note that {@code toArray(new Object[0])} is identical in function to
+     * {@code toArray()}.
      *
      * @param a the array into which the elements of the list are to
      *          be stored, if it is big enough; otherwise, a new array of the
@@ -922,14 +1088,15 @@
      *         this list
      * @throws NullPointerException if the specified array is null
      */
+    @SuppressWarnings("unchecked")
     public <T> T[] toArray(T[] a) {
         if (a.length < size)
             a = (T[])java.lang.reflect.Array.newInstance(
                                 a.getClass().getComponentType(), size);
         int i = 0;
         Object[] result = a;
-        for (Entry<E> e = header.next; e != header; e = e.next)
-            result[i++] = e.element;
+        for (Node<E> x = first; x != null; x = x.next)
+            result[i++] = x.item;
 
         if (a.length > size)
             a[size] = null;
@@ -940,8 +1107,8 @@
     private static final long serialVersionUID = 876323262645176354L;
 
     /**
-     * Save the state of this <tt>LinkedList</tt> instance to a stream (that
-     * is, serialize it).
+     * Saves the state of this {@code LinkedList} instance to a stream
+     * (that is, serializes it).
      *
      * @serialData The size of the list (the number of elements it
      *             contains) is emitted (int), followed by all of its
@@ -956,14 +1123,15 @@
         s.writeInt(size);
 
         // Write out all elements in the proper order.
-        for (Entry e = header.next; e != header; e = e.next)
-            s.writeObject(e.element);
+        for (Node<E> x = first; x != null; x = x.next)
+            s.writeObject(x.item);
     }
 
     /**
-     * Reconstitute this <tt>LinkedList</tt> instance from a stream (that is
-     * deserialize it).
+     * Reconstitutes this {@code LinkedList} instance from a stream
+     * (that is, deserializes it).
      */
+    @SuppressWarnings("unchecked")
     private void readObject(java.io.ObjectInputStream s)
         throws java.io.IOException, ClassNotFoundException {
         // Read in any hidden serialization magic
@@ -972,12 +1140,8 @@
         // Read in size
         int size = s.readInt();
 
-        // Initialize header
-        header = new Entry<E>(null, null, null);
-        header.next = header.previous = header;
-
         // Read in all elements in the proper order.
-        for (int i=0; i<size; i++)
-            addBefore((E)s.readObject(), header);
+        for (int i = 0; i < size; i++)
+            linkLast((E)s.readObject());
     }
 }
--- a/src/share/classes/java/util/Objects.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/Objects.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,7 +33,7 @@
  *
  * @since 1.7
  */
-public class Objects {
+public final class Objects {
     private Objects() {
         throw new AssertionError("No java.util.Objects instances for you!");
     }
@@ -57,6 +57,32 @@
         return (a == b) || (a != null && a.equals(b));
     }
 
+   /**
+    * Returns {@code true} if the arguments are deeply equal to each other
+    * and {@code false} otherwise.
+    *
+    * Two {@code null} values are deeply equal.  If both arguments are
+    * arrays, the algorithm in {@link Arrays#deepEquals(Object[],
+    * Object[]) Arrays.deepEquals} is used to determine equality.
+    * Otherwise, equality is determined by using the {@link
+    * Object#equals equals} method of the first argument.
+    *
+    * @param a an object
+    * @param b an object to be compared with {@code a} for deep equality
+    * @return {@code true} if the arguments are deeply equal to each other
+    * and {@code false} otherwise
+    * @see Arrays#deepEquals(Object[], Object[])
+    * @see Objects#equals(Object, Object)
+    */
+    public static boolean deepEquals(Object a, Object b) {
+        if (a == b)
+            return true;
+        else if (a == null || b == null)
+            return false;
+        else
+            return Arrays.deepEquals0(a, b);
+    }
+
     /**
      * Returns the hash code of a non-{@code null} argument and 0 for
      * a {@code null} argument.
@@ -70,6 +96,36 @@
         return o != null ? o.hashCode() : 0;
     }
 
+   /**
+    * Generates a hash code for a sequence of input values. The hash
+    * code is generated as if all the input values were placed into an
+    * array, and that array were hashed by calling {@link
+    * Arrays#hashCode(Object[])}.
+    *
+    * <p>This method is useful for implementing {@link
+    * Object#hashCode()} on objects containing multiple fields. For
+    * example, if an object that has three fields, {@code x}, {@code
+    * y}, and {@code z}, one could write:
+    *
+    * <blockquote><pre>
+    * &#064;Override public int hashCode() {
+    *     return Objects.hash(x, y, z);
+    * }
+    * </pre></blockquote>
+    *
+    * <b>Warning: When a single object reference is supplied, the returned
+    * value does not equal the hash code of that object reference.</b> This
+    * value can be computed by calling {@link #hashCode(Object)}.
+    *
+    * @param values the values to be hashed
+    * @return a hash value of the sequence of input values
+    * @see Arrays#hashCode
+    * @see List#hashCode
+    */
+    public static int hash(Object... values) {
+        return Arrays.hashCode(values);
+    }
+
     /**
      * Returns the result of calling {@code toString} for a non-{@code
      * null} argument and {@code "null"} for a {@code null} argument.
@@ -85,6 +141,23 @@
     }
 
     /**
+     * Returns the result of calling {@code toString} on the first
+     * argument if the first argument is not {@code null} and returns
+     * the second argument otherwise.
+     *
+     * @param o an object
+     * @param nullDefault string to return if the first argument is
+     *        {@code null}
+     * @return the result of calling {@code toString} on the first
+     * argument if it is not {@code null} and the second argument
+     * otherwise.
+     * @see Objects#toString(Object)
+     */
+    public static String toString(Object o, String nullDefault) {
+        return (o != null) ? o.toString() : nullDefault;
+    }
+
+    /**
      * Returns 0 if the arguments are identical and {@code
      * c.compare(a, b)} otherwise.
      * Consequently, if both arguments are {@code null} 0
--- a/src/share/classes/java/util/jar/JarFile.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/jar/JarFile.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -297,6 +297,7 @@
                     String name = names[i].toUpperCase(Locale.ENGLISH);
                     if (name.endsWith(".DSA") ||
                         name.endsWith(".RSA") ||
+                        name.endsWith(".EC") ||
                         name.endsWith(".SF")) {
                         // Assume since we found a signature-related file
                         // that the jar is signed and that we therefore
--- a/src/share/classes/java/util/jar/JarVerifier.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/jar/JarVerifier.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -50,7 +50,7 @@
     private Hashtable verifiedSigners;
 
     /* a table mapping names to code signers, for jar entries that have
-       passed the .SF/.DSA -> MANIFEST check */
+       passed the .SF/.DSA/.EC -> MANIFEST check */
     private Hashtable sigFileSigners;
 
     /* a hash table to hold .SF bytes */
@@ -111,7 +111,7 @@
         /*
          * Assumptions:
          * 1. The manifest should be the first entry in the META-INF directory.
-         * 2. The .SF/.DSA files follow the manifest, before any normal entries
+         * 2. The .SF/.DSA/.EC files follow the manifest, before any normal entries
          * 3. Any of the following will throw a SecurityException:
          *    a. digest mismatch between a manifest section and
          *       the SF section.
@@ -129,7 +129,7 @@
                 }
 
                 if (SignatureFileVerifier.isBlockOrSF(uname)) {
-                    /* We parse only DSA or RSA PKCS7 blocks. */
+                    /* We parse only DSA, RSA or EC PKCS7 blocks. */
                     parsingBlockOrSF = true;
                     baos.reset();
                     mev.setEntry(null, je);
--- a/src/share/classes/java/util/logging/LogManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/logging/LogManager.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1039,12 +1039,16 @@
 
     /**
      * Returns <tt>LoggingMXBean</tt> for managing loggers.
-     * The <tt>LoggingMXBean</tt> can also obtained from the
-     * {@link java.lang.management.ManagementFactory#getPlatformMBeanServer
-     * platform <tt>MBeanServer</tt>} method.
+     * An alternative way to manage loggers is using
+     * the {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
+     * ManagementFactory.getPlatformMXBeans} method as follows:
+     * <pre>
+     *     List&lt{@link PlatformLoggingMXBean}&gt result = ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class);
+     * </pre>
      *
      * @return a {@link LoggingMXBean} object.
      *
+     * @see PlatformLoggingMXBean
      * @see java.lang.management.ManagementFactory
      * @since 1.5
      */
--- a/src/share/classes/java/util/logging/Logging.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/logging/Logging.java	Wed Nov 25 11:08:25 2009 -0800
@@ -29,8 +29,6 @@
 import java.util.List;
 import java.util.ArrayList;
 
-import javax.management.ObjectName;
-
 /**
  * Logging is the implementation class of LoggingMXBean.
  *
@@ -116,8 +114,4 @@
             return p.getName();
         }
     }
-
-    public ObjectName getObjectName() {
-        return ObjectName.valueOf(LogManager.LOGGING_MXBEAN_NAME);
-    }
 }
--- a/src/share/classes/java/util/logging/LoggingMXBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/logging/LoggingMXBean.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,7 +25,6 @@
 
 package java.util.logging;
 
-import java.lang.management.PlatformManagedObject;
 
 /**
  * The management interface for the logging facility.
@@ -35,27 +34,26 @@
  * <a href="../../lang/management/ManagementFactory.html#MXBean">MXBean</a>
  * can be obtained by calling
  * the {@link LogManager#getLoggingMXBean} method or from the
- * {@link java.lang.management.ManagementFactory#getPlatformMBeanServer
- * platform <tt>MBeanServer</tt>} method.
+ * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
+ * platform <tt>MBeanServer</tt>}.
  *
- * <p>The {@link javax.management.ObjectName ObjectName} for uniquely
+ * The {@link javax.management.ObjectName ObjectName} for uniquely
  * identifying the <tt>LoggingMXBean</tt> within an MBeanServer is:
  * <blockquote>
  *    {@link LogManager#LOGGING_MXBEAN_NAME
  *           <tt>java.util.logging:type=Logging</tt>}
  * </blockquote>
  *
- * It can be obtained by calling the
- * {@link PlatformManagedObject#getObjectName} method.
- *
- * @see java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
+ * The instance registered in the platform <tt>MBeanServer</tt> with
+ * this {@code ObjectName} is also a {@link PlatformLoggingMXBean}.
  *
  * @author  Ron Mann
  * @author  Mandy Chung
  * @since   1.5
  *
+ * @see PlatformLoggingMXBean
  */
-public interface LoggingMXBean extends PlatformManagedObject {
+public interface LoggingMXBean {
 
     /**
      * Returns the list of currently registered loggers. This method
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/logging/LoggingProxyImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,102 @@
+/*
+ * 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 java.util.logging;
+
+import sun.util.logging.LoggingProxy;
+
+/**
+ * Implementation of LoggingProxy when java.util.logging classes exist.
+ */
+class LoggingProxyImpl implements LoggingProxy {
+    static final LoggingProxy INSTANCE = new LoggingProxyImpl();
+
+    private LoggingProxyImpl() { }
+
+    @Override
+    public Object getLogger(String name) {
+        return Logger.getLogger(name);
+    }
+
+    @Override
+    public Object getLevel(Object logger) {
+        return ((Logger) logger).getLevel();
+    }
+
+    @Override
+    public void setLevel(Object logger, Object newLevel) {
+        ((Logger) logger).setLevel((Level) newLevel);
+    }
+
+    @Override
+    public boolean isLoggable(Object logger, Object level) {
+        return ((Logger) logger).isLoggable((Level) level);
+    }
+
+    @Override
+    public void log(Object logger, Object level, String msg) {
+        ((Logger) logger).log((Level) level, msg);
+    }
+
+    @Override
+    public void log(Object logger, Object level, String msg, Throwable t) {
+        ((Logger) logger).log((Level) level, msg, t);
+    }
+
+    @Override
+    public void log(Object logger, Object level, String msg, Object... params) {
+        ((Logger) logger).log((Level) level, msg, params);
+    }
+
+    @Override
+    public java.util.List<String> getLoggerNames() {
+        return LogManager.getLoggingMXBean().getLoggerNames();
+    }
+
+    @Override
+    public String getLoggerLevel(String loggerName) {
+        return LogManager.getLoggingMXBean().getLoggerLevel(loggerName);
+    }
+
+    @Override
+    public void setLoggerLevel(String loggerName, String levelName) {
+        LogManager.getLoggingMXBean().setLoggerLevel(loggerName, levelName);
+    }
+
+    @Override
+    public String getParentLoggerName(String loggerName) {
+        return LogManager.getLoggingMXBean().getParentLoggerName(loggerName);
+    }
+
+    @Override
+    public Object parseLevel(String levelName) {
+        return Level.parse(levelName);
+    }
+
+    @Override
+    public String getLevelName(Object level) {
+        return ((Level) level).getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/java/util/logging/PlatformLoggingMXBean.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,60 @@
+/*
+ * 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 java.util.logging;
+
+import java.lang.management.PlatformManagedObject;
+
+/**
+ * The {@linkplain PlatformManagedObject platform managed object} for the
+ * logging facility.  This interface simply unifies {@link LoggingMXBean}
+ * {@link PlatformManagedObject};
+ * and it does not specify any new operations.
+ *
+ * <p>The {@link java.lang.management.ManagementFactory#getPlatformMXBeans(Class)
+ * ManagementFactory.getPlatformMXBeans} method can be used to obtain
+ * the {@code PlatformLoggingMXBean} object as follows:
+ * <pre>
+ *     ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class);
+ * </pre>
+ * or from the {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer
+ * platform <tt>MBeanServer</tt>}.
+ *
+ * The {@link javax.management.ObjectName ObjectName} for uniquely
+ * identifying the <tt>LoggingMXBean</tt> within an MBeanServer is:
+ * <blockquote>
+ *           <tt>java.util.logging:type=Logging</tt>
+ * </blockquote>
+ *
+ * The {@link PlatformManagedObject#getObjectName} method
+ * can be used to obtain its {@code ObjectName}.
+ *
+ * @See java.lang.management.PlatformManagedObject
+ *
+ * @author  Mandy Chung
+ * @since   1.7
+ */
+public interface PlatformLoggingMXBean extends LoggingMXBean, PlatformManagedObject {
+}
--- a/src/share/classes/java/util/regex/Matcher.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/regex/Matcher.java	Wed Nov 25 11:08:25 2009 -0800
@@ -688,7 +688,7 @@
      *
      * <p> The replacement string may contain references to subsequences
      * captured during the previous match: Each occurrence of
-     * <tt>$</tt>&lt;<i>name</i>&gt; or <tt>$</tt><i>g</i>
+     * <tt>${</tt><i>name</i><tt>}</tt> or <tt>$</tt><i>g</i>
      * will be replaced by the result of evaluating the corresponding
      * {@link #group(String) group(name)} or {@link #group(int) group(g)</tt>}
      * respectively. For  <tt>$</tt><i>g</i><tt></tt>,
@@ -770,7 +770,7 @@
                 // more appropriate.
                 nextChar = replacement.charAt(cursor);
                 int refNum = -1;
-                if (nextChar == '<') {
+                if (nextChar == '{') {
                     cursor++;
                     StringBuilder gsb = new StringBuilder();
                     while (cursor < replacement.length()) {
@@ -787,13 +787,17 @@
                     if (gsb.length() == 0)
                         throw new IllegalArgumentException(
                             "named capturing group has 0 length name");
-                    if (nextChar != '>')
+                    if (nextChar != '}')
                         throw new IllegalArgumentException(
-                            "named capturing group is missing trailing '>'");
+                            "named capturing group is missing trailing '}'");
                     String gname = gsb.toString();
+                    if (ASCII.isDigit(gname.charAt(0)))
+                        throw new IllegalArgumentException(
+                            "capturing group name {" + gname +
+                            "} starts with digit character");
                     if (!parentPattern.namedGroups().containsKey(gname))
                         throw new IllegalArgumentException(
-                            "No group with name <" + gname + ">");
+                            "No group with name {" + gname + "}");
                     refNum = parentPattern.namedGroups().get(gname);
                     cursor++;
                 } else {
--- a/src/share/classes/java/util/regex/Pattern.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/regex/Pattern.java	Wed Nov 25 11:08:25 2009 -0800
@@ -484,7 +484,7 @@
  * <h5> Group name </h5>
  * <p>A capturing group can also be assigned a "name", a <tt>named-capturing group</tt>,
  * and then be back-referenced later by the "name". Group names are composed of
- * the following characters:
+ * the following characters. The first character must be a <tt>letter</tt>.
  *
  * <ul>
  *   <li> The uppercase letters <tt>'A'</tt> through <tt>'Z'</tt>
@@ -2567,7 +2567,7 @@
                 break;
             case '<':   // (?<xxx)  look behind
                 ch = read();
-                if (ASCII.isLower(ch) || ASCII.isUpper(ch) || ASCII.isDigit(ch)) {
+                if (ASCII.isLower(ch) || ASCII.isUpper(ch)) {
                     // named captured group
                     String name = groupname(ch);
                     if (namedGroups().containsKey(name))
--- a/src/share/classes/java/util/zip/Deflater.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/zip/Deflater.java	Wed Nov 25 11:08:25 2009 -0800
@@ -122,6 +122,33 @@
      */
     public static final int DEFAULT_STRATEGY = 0;
 
+    /**
+     * Compression flush mode used to achieve best compression result.
+     *
+     * @see Deflater#deflate(byte[], int, int, int)
+     * @since 1.7
+     */
+    public static final int NO_FLUSH = 0;
+
+    /**
+     * Compression flush mode used to flush out all pending output; may
+     * degrade compression for some compression algorithms.
+     *
+     * @see Deflater#deflate(byte[], int, int, int)
+     * @since 1.7
+     */
+    public static final int SYNC_FLUSH = 2;
+
+    /**
+     * Compression flush mode used to flush out all pending output and
+     * reset the deflater. Using this mode too often can seriously degrade
+     * compression.
+     *
+     * @see Deflater#deflate(byte[], int, int, int)
+     * @since 1.7
+     */
+    public static final int FULL_FLUSH = 3;
+
     static {
         /* Zip library is loaded from System.initializeSystemClass */
         initIDs();
@@ -289,35 +316,100 @@
     }
 
     /**
-     * Fills specified buffer with compressed data. Returns actual number
-     * of bytes of compressed data. A return value of 0 indicates that
-     * needsInput() should be called in order to determine if more input
-     * data is required.
+     * Compresses the input data and fills specified buffer with compressed
+     * data. Returns actual number of bytes of compressed data. A return value
+     * of 0 indicates that {@link needsInput() needsInput} should be called
+     * in order to determine if more input data is required.
+     *
+     * <p>This method uses {@link #NO_FLUSH} as its compression flush mode.
+     * An invocation of this method of the form {@code deflater.deflate(b, off, len)}
+     * yields the same result as the invocation of
+     * {@code deflater.deflate(b, off, len, Deflater.NO_FLUSH)}.
+     *
      * @param b the buffer for the compressed data
      * @param off the start offset of the data
      * @param len the maximum number of bytes of compressed data
-     * @return the actual number of bytes of compressed data
+     * @return the actual number of bytes of compressed data written to the
+     *         output buffer
+     */
+    public int deflate(byte[] b, int off, int len) {
+        return deflate(b, off, len, NO_FLUSH);
+    }
+
+    /**
+     * Compresses the input data and fills specified buffer with compressed
+     * data. Returns actual number of bytes of compressed data. A return value
+     * of 0 indicates that {@link needsInput() needsInput} should be called
+     * in order to determine if more input data is required.
+     *
+     * <p>This method uses {@link #NO_FLUSH} as its compression flush mode.
+     * An invocation of this method of the form {@code deflater.deflate(b)}
+     * yields the same result as the invocation of
+     * {@code deflater.deflate(b, 0, b.length, Deflater.NO_FLUSH)}.
+     *
+     * @param b the buffer for the compressed data
+     * @return the actual number of bytes of compressed data written to the
+     *         output buffer
      */
-    public synchronized int deflate(byte[] b, int off, int len) {
+    public int deflate(byte[] b) {
+        return deflate(b, 0, b.length, NO_FLUSH);
+    }
+
+    /**
+     * Compresses the input data and fills the specified buffer with compressed
+     * data. Returns actual number of bytes of data compressed.
+     *
+     * <p>Compression flush mode is one of the following three modes:
+     *
+     * <ul>
+     * <li>{@link #NO_FLUSH}: allows the deflater to decide how much data
+     * to accumulate, before producing output, in order to achieve the best
+     * compression (should be used in normal use scenario). A return value
+     * of 0 in this flush mode indicates that {@link #needsInput()} should
+     * be called in order to determine if more input data is required.
+     *
+     * <li>{@link #SYNC_FLUSH}: all pending output in the deflater is flushed,
+     * to the specified output buffer, so that an inflater that works on
+     * compressed data can get all input data available so far (In particular
+     * the {@link #needsInput()} returns {@code true} after this invocation
+     * if enough output space is provided). Flushing with {@link #SYNC_FLUSH}
+     * may degrade compression for some compression algorithms and so it
+     * should be used only when necessary.
+     *
+     * <li>{@link #FULL_FLUSH}: all pending output is flushed out as with
+     * {@link #SYNC_FLUSH}. The compression state is reset so that the inflater
+     * that works on the compressed output data can restart from this point
+     * if previous compressed data has been damaged or if random access is
+     * desired. Using {@link #FULL_FLUSH} too often can seriously degrade
+     * compression.
+     * </ul>
+     *
+     * <p>In the case of {@link #FULL_FLUSH} or {@link #SYNC_FLUSH}, if
+     * the return value is {@code len}, the space available in output
+     * buffer {@code b}, this method should be invoked again with the same
+     * {@code flush} parameter and more output space.
+     *
+     * @param b the buffer for the compressed data
+     * @param off the start offset of the data
+     * @param len the maximum number of bytes of compressed data
+     * @param flush the compression flush mode
+     * @return the actual number of bytes of compressed data written to
+     *         the output buffer
+     *
+     * @throws IllegalArgumentException if the flush mode is invalid
+     * @since 1.7
+     */
+    public synchronized int deflate(byte[] b, int off, int len, int flush) {
         if (b == null) {
             throw new NullPointerException();
         }
         if (off < 0 || len < 0 || off > b.length - len) {
             throw new ArrayIndexOutOfBoundsException();
         }
-        return deflateBytes(b, off, len);
-    }
-
-    /**
-     * Fills specified buffer with compressed data. Returns actual number
-     * of bytes of compressed data. A return value of 0 indicates that
-     * needsInput() should be called in order to determine if more input
-     * data is required.
-     * @param b the buffer for the compressed data
-     * @return the actual number of bytes of compressed data
-     */
-    public int deflate(byte[] b) {
-        return deflate(b, 0, b.length);
+        if (flush == NO_FLUSH || flush == SYNC_FLUSH ||
+            flush == FULL_FLUSH)
+            return deflateBytes(b, off, len, flush);
+        throw new IllegalArgumentException();
     }
 
     /**
@@ -420,7 +512,7 @@
     private native static long init(int level, int strategy, boolean nowrap);
     private native static void setDictionary(long strm, byte[] b, int off,
                                              int len);
-    private native int deflateBytes(byte[] b, int off, int len);
+    private native int deflateBytes(byte[] b, int off, int len, int flush);
     private native static int getAdler(long strm);
     private native static long getBytesRead(long strm);
     private native static long getBytesWritten(long strm);
--- a/src/share/classes/java/util/zip/DeflaterOutputStream.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/java/util/zip/DeflaterOutputStream.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-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
@@ -56,15 +56,29 @@
 
     private boolean closed = false;
 
+    private final boolean syncFlush;
+
     /**
-     * Creates a new output stream with the specified compressor and
-     * buffer size.
+     * Creates a new output stream with the specified compressor,
+     * buffer size and flush mode.
+
      * @param out the output stream
      * @param def the compressor ("deflater")
      * @param size the output buffer size
-     * @exception IllegalArgumentException if size is <= 0
+     * @param syncFlush
+     *        if {@code true} the {@link flush()} method of this
+     *        instance flushes the compressor with flush mode
+     *        {@link Deflater#SYNC_FLUSH} before flushing the output
+     *        stream, otherwise only flushes the output stream
+     *
+     * @throws IllegalArgumentException if size is <= 0
+     *
+     * @since 1.7
      */
-    public DeflaterOutputStream(OutputStream out, Deflater def, int size) {
+    public DeflaterOutputStream(OutputStream out,
+                                Deflater def,
+                                int size,
+                                boolean syncFlush) {
         super(out);
         if (out == null || def == null) {
             throw new NullPointerException();
@@ -72,27 +86,93 @@
             throw new IllegalArgumentException("buffer size <= 0");
         }
         this.def = def;
-        buf = new byte[size];
+        this.buf = new byte[size];
+        this.syncFlush = syncFlush;
+    }
+
+
+    /**
+     * Creates a new output stream with the specified compressor and
+     * buffer size.
+     *
+     * <p>The new output stream instance is created as if by invoking
+     * the 4-argument constructor DeflaterOutputStream(out, def, size, false).
+     *
+     * @param out the output stream
+     * @param def the compressor ("deflater")
+     * @param size the output buffer size
+     * @exception IllegalArgumentException if size is <= 0
+     */
+    public DeflaterOutputStream(OutputStream out, Deflater def, int size) {
+        this(out, def, size, false);
     }
 
     /**
+     * Creates a new output stream with the specified compressor, flush
+     * mode and a default buffer size.
+     *
+     * @param out the output stream
+     * @param def the compressor ("deflater")
+     * @param syncFlush
+     *        if {@code true} the {@link flush()} method of this
+     *        instance flushes the compressor with flush mode
+     *        {@link Deflater#SYNC_FLUSH} before flushing the output
+     *        stream, otherwise only flushes the output stream
+     *
+     * @since 1.7
+     */
+    public DeflaterOutputStream(OutputStream out,
+                                Deflater def,
+                                boolean syncFlush) {
+        this(out, def, 512, syncFlush);
+    }
+
+
+    /**
      * Creates a new output stream with the specified compressor and
      * a default buffer size.
+     *
+     * <p>The new output stream instance is created as if by invoking
+     * the 3-argument constructor DeflaterOutputStream(out, def, false).
+     *
      * @param out the output stream
      * @param def the compressor ("deflater")
      */
     public DeflaterOutputStream(OutputStream out, Deflater def) {
-        this(out, def, 512);
+        this(out, def, 512, false);
     }
 
     boolean usesDefaultDeflater = false;
 
+
+    /**
+     * Creates a new output stream with a default compressor, a default
+     * buffer size and the specified flush mode.
+     *
+     * @param out the output stream
+     * @param syncFlush
+     *        if {@code true} the {@link flush()} method of this
+     *        instance flushes the compressor with flush mode
+     *        {@link Deflater#SYNC_FLUSH} before flushing the output
+     *        stream, otherwise only flushes the output stream
+     *
+     * @since 1.7
+     */
+    public DeflaterOutputStream(OutputStream out, boolean syncFlush) {
+        this(out, new Deflater(), 512, syncFlush);
+        usesDefaultDeflater = true;
+    }
+
     /**
      * Creates a new output stream with a default compressor and buffer size.
+     *
+     * <p>The new output stream instance is created as if by invoking
+     * the 2-argument constructor DeflaterOutputStream(out, false).
+     *
      * @param out the output stream
      */
     public DeflaterOutputStream(OutputStream out) {
-        this(out, new Deflater());
+        this(out, false);
         usesDefaultDeflater = true;
     }
 
@@ -178,4 +258,32 @@
             out.write(buf, 0, len);
         }
     }
+
+    /**
+     * Flushes the compressed output stream.
+     *
+     * If {@link DeflaterOutputStream(OutputStream, Deflater, int, boolean)
+     * syncFlush} is {@code true} when this compressed output stream is
+     * constructed this method flushes the underlying {@code compressor}
+     * first with the flush mode {@link Deflater#SYNC_FLUSH} to force
+     * all pending data to be flushed out to the output stream and then
+     * flushes the output stream. Otherwise this method only flushes the
+     * output stream without flushing the {@code compressor}.
+     *
+     * @throws IOException if an I/O error has occurred
+     *
+     * @since 1.7
+     */
+    public void flush() throws IOException {
+        if (syncFlush && !def.finished()) {
+            int len = 0;
+            while ((len = def.deflate(buf, 0, buf.length, Deflater.SYNC_FLUSH)) > 0)
+            {
+                out.write(buf, 0, len);
+                if (len < buf.length)
+                    break;
+            }
+        }
+        out.flush();
+    }
 }
--- a/src/share/classes/javax/management/AndQueryExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/AndQueryExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -104,26 +104,4 @@
     public String toString() {
         return "(" + exp1 + ") and (" + exp2 + ")";
     }
-
-    @Override
-    String toQueryString() {
-        // Parentheses are only added if needed to disambiguate.
-        return parens(exp1) + " and " + parens(exp2);
-   }
-
-   // Add parens if needed to disambiguate an expression such as
-   // Query.and(Query.or(a, b), c).  We need to return
-   // (a or b) and c
-   // in such a case, because
-   // a or b and c
-   // would mean
-   // a or (b and c)
-   private static String parens(QueryExp exp) {
-       String s = Query.toString(exp);
-       if (exp instanceof OrQueryExp)
-           return "(" + s + ")";
-       else
-           return s;
-   }
-
 }
--- a/src/share/classes/javax/management/AttributeList.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/AttributeList.java	Wed Nov 25 11:08:25 2009 -0800
@@ -138,56 +138,6 @@
     }
 
     /**
-     * <p>Constructs an {@code AttributeList} containing the elements of
-     * the {@code Map} specified, in the order in which they appear in the
-     * {@code Map}'s {@link Map#entrySet entrySet}.  For each <em>{@code
-     * key}</em> and <em>{@code value}</em> in the {@code Map}, the constructed
-     * {@code AttributeList} will contain {@link Attribute#Attribute
-     * Attribute(<em>key</em>, <em>value</em>)}.</p>
-     *
-     * @param map the {@code Map} defining the elements of the new
-     * {@code AttributeList}.
-     */
-    public AttributeList(Map<String, ?> map) {
-        for (Map.Entry<String, ?> entry : map.entrySet())
-            add(new Attribute(entry.getKey(), entry.getValue()));
-        typeSafe = true;
-    }
-
-    /**
-     * <p>Return a {@code Map} that is a snapshot of the values in this
-     * {@code AttributeList}.  Each key in the {@code Map} is the {@linkplain
-     * Attribute#getName() name} of an {@code Attribute} in the list, and each
-     * value is the corresponding {@linkplain Attribute#getValue() value} of
-     * that {@code Attribute}.  The {@code AttributeList} and the {@code Map}
-     * are unrelated after the call, that is, changes to one do not affect the
-     * other.</p>
-     *
-     * <p>If the {@code AttributeList} contains more than one {@code Attribute}
-     * with the same name, then the {@code Map} will contain an entry
-     * for that name where the value is that of the last of those {@code
-     * Attribute}s.</p>
-     *
-     * @return the new {@code Map}.
-     *
-     * @throws IllegalArgumentException if this {@code AttributeList} contains
-     * an element that is not an {@code Attribute}.
-     */
-    public Map<String, Object> toMap() {
-        Map<String, Object> map = new LinkedHashMap<String, Object>();
-
-        // We can't call adding(this) because we're not necessarily typeSafe
-        if (tainted)
-            throw new IllegalArgumentException("AttributeList contains non-Attribute");
-
-        for (Object x : this) {
-            Attribute a = (Attribute) x;
-            map.put(a.getName(), a.getValue());
-        }
-        return map;
-    }
-
-    /**
      * Return a view of this list as a {@code List<Attribute>}.
      * Changes to the returned value are reflected by changes
      * to the original {@code AttributeList} and vice versa.
--- a/src/share/classes/javax/management/AttributeValueExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/AttributeValueExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -51,8 +51,6 @@
      */
     private String attr;
 
-    private transient int dotIndex;
-
     /**
      * An <code>AttributeValueExp</code> with a null attribute.
      * @deprecated An instance created with this constructor cannot be
@@ -71,18 +69,6 @@
      */
     public AttributeValueExp(String attr) {
         this.attr = attr;
-        setDotIndex();
-    }
-
-    private void setDotIndex() {
-        if (attr != null)
-            dotIndex = attr.indexOf('.');
-    }
-
-    private void readObject(ObjectInputStream in)
-    throws ClassNotFoundException, IOException {
-        in.defaultReadObject();
-        setDotIndex();
     }
 
     /**
@@ -134,7 +120,7 @@
      */
     @Override
     public String toString()  {
-        return QueryParser.quoteId(attr);
+        return attr;
     }
 
 
@@ -160,18 +146,6 @@
      * If the attempt to access the attribute generates an exception,
      * return null.</p>
      *
-     * <p>Let <em>n</em> be the {@linkplain #getAttributeName attribute
-     * name}. Then this method proceeds as follows. First it calls
-     * {@link MBeanServer#getAttribute getAttribute(name, <em>n</em>)}. If that
-     * generates an {@link AttributeNotFoundException}, and if <em>n</em>
-     * contains at least one dot ({@code .}), then the method calls {@code
-     * getAttribute(name, }<em>n</em>{@code .substring(0, }<em>n</em>{@code
-     * .indexOf('.')))}; in other words it calls {@code getAttribute}
-     * with the substring of <em>n</em> before the first dot. Then it
-     * extracts a component from the retrieved value, as described in the <a
-     * href="monitor/package-summary.html#complex">documentation for the {@code
-     * monitor} package</a>.</p>
-     *
      * <p>The MBean Server used is the one returned by {@link
      * QueryEval#getMBeanServer()}.</p>
      *
@@ -186,34 +160,9 @@
 
             MBeanServer server = QueryEval.getMBeanServer();
 
-            try {
             return server.getAttribute(name, attr);
-            } catch (AttributeNotFoundException e) {
-                if (dotIndex < 0)
-                    throw e;
-            }
-
-            String toGet = attr.substring(0, dotIndex);
-
-            Object value = server.getAttribute(name, toGet);
-
-            return extractElement(value, attr.substring(dotIndex + 1));
         } catch (Exception re) {
             return null;
         }
     }
-
-    private Object extractElement(Object value, String elementWithDots)
-    throws AttributeNotFoundException {
-        while (true) {
-            int dot = elementWithDots.indexOf('.');
-            String element = (dot < 0) ?
-                elementWithDots : elementWithDots.substring(0, dot);
-            value = Introspector.elementFromComplex(value, element);
-            if (dot < 0)
-                return value;
-            elementWithDots = elementWithDots.substring(dot + 1);
-        }
-    }
-
 }
--- a/src/share/classes/javax/management/BetweenQueryExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/BetweenQueryExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -139,9 +139,4 @@
     public String toString()  {
         return "(" + exp1 + ") between (" + exp2 + ") and (" + exp3 + ")";
     }
-
-    @Override
-    String toQueryString() {
-        return exp1 + " between " + exp2 + " and " + exp3;
-    }
 }
--- a/src/share/classes/javax/management/BinaryOpValueExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/BinaryOpValueExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -253,7 +253,5 @@
     @Deprecated
     public void setMBeanServer(MBeanServer s) {
         super.setMBeanServer(s);
+     }
  }
-
-
- }
--- a/src/share/classes/javax/management/BinaryRelQueryExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/BinaryRelQueryExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -192,11 +192,6 @@
         return "(" + exp1 + ") " + relOpString() + " (" + exp2 + ")";
     }
 
-    @Override
-    String toQueryString() {
-        return exp1 + " " + relOpString() + " " + exp2;
-    }
-
     private String relOpString() {
         switch (relOp) {
         case Query.GT:
--- a/src/share/classes/javax/management/ClientContext.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1091 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import com.sun.jmx.interceptor.SingleMBeanForwarder;
-import com.sun.jmx.namespace.RoutingConnectionProxy;
-import com.sun.jmx.namespace.RoutingProxy;
-import com.sun.jmx.namespace.RoutingServerProxy;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import static javax.management.namespace.JMXNamespaces.NAMESPACE_SEPARATOR;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaceMBean;
-import javax.management.namespace.MBeanServerSupport;
-import javax.management.remote.IdentityMBeanServerForwarder;
-import javax.management.remote.MBeanServerForwarder;
-
-/**
- * <p>Methods to communicate a client context to MBeans.  A context is
- * a {@literal Map<String, String>} that is provided by the client and
- * that an MBean can consult using the {@link #getContext()} method.
- * The context is set on a per-thread basis and can be consulted by any
- * code that the target MBean calls within the thread.</p>
- *
- * <p>One common usage of client context is to communicate the client's
- * {@link Locale} to MBeans.  For example, if an MBean has a String attribute
- * {@code LastProblemDescription}, the value of that attribute could be
- * a description of the last problem encountered by the MBean, translated
- * into the client's locale.  Different clients accessing this attribute
- * from different locales would each see the appropriate version for their
- * locale.</p>
- *
- * <p>The locale case is sufficiently important that it has a special
- * shorthand, the {@link #getLocale()} method.  This method calls
- * <code>{@link #getContext()}.get({@link #LOCALE_KEY})</code> and converts the
- * resultant String into a Locale object.</p>
- *
- * <p>Here is what an MBean with a localized {@code LastProblemDescription}
- * attribute might look like:</p>
- *
- * <pre>
- * public class LocaleSensitive implements LocaleSensitiveMBean {
- *     ...
- *     public String getLastProblemDescription() {
- *         Locale loc = {@link #getLocale() ClientContext.getLocale()};
- *         ResourceBundle rb = ResourceBundle.getBundle("MyResources", loc);
- *         String resourceKey = getLastProblemResourceKey();
- *         return rb.getString(resourceKey);
- *     }
- *     ...
- * }
- * </pre>
- *
- * <p>Here is how a client can communicate its locale to the target
- * MBean:</p>
- *
- * <pre>
- * JMXConnector connector = JMXConnectorFactory.connect(url);
- * MBeanServerConnection connection = connector.getMBeanServerConnection();
- * <b>MBeanServerConnection localizedConnection =
- *     {@link #withLocale(MBeanServerConnection, Locale)
- *      ClientContext.withLocale}(connection, Locale.getDefault());</b>
- * String problem = localizedConnection.getAttribute(
- *          objectName, "LastProblemDescription");
- * </pre>
- *
- * <p>In the more general case where the client wants to communicate context
- * other than the locale, it can use {@link #withContext(MBeanServerConnection,
- * String, String) withContext} instead of {@code withLocale}, and the target
- * MBean can retrieve the context using {@link #getContext()}.</p>
- *
- *
- * <h3 id="remote-use">Remote use of contexts</h3>
- *
- * <p>The various {@code with*} methods, for example {@link
- * #withLocale(javax.management.MBeanServer, java.util.Locale) withLocale},
- * transmit the context of each request by encoding it in the ObjectName of
- * the request.  For example, if a client creates a connection in the
- * French locale like this...</p>
- *
- * <pre>
- * MBeanServerConnection mbsc = ...;
- * Locale french = new Locale("fr");
- * MBeanServerConnection localizedConnection = ClientContext.withLocale(mbsc, french);
- * </pre>
- *
- * <p>...or, equivalently, like this...</p>
- *
- * <pre>
- * MBeanServerConnection localizedConnection =
- *     ClientContext.withContext(mbsc, {@link #LOCALE_KEY "jmx.locale"}, "fr");
- * </pre>
- *
- * <p>...then the context associates {@code "jmx.locale"} with {@code "fr"}
- * and a request such as<br>
- * {@code localizedConnection.getAttribute("java.lang:type=Runtime", "Name")}<br>
- * is translated into<br>
- * {@code mbsc.getAttribute("jmx.context//jmx.locale=fr//java.lang:Runtime", "Name")}.<br>
- * A special {@linkplain javax.management.namespace namespace} {@code jmx.context//}
- * extracts the context from the string {@code jmx.locale=fr} and establishes
- * it in the thread that will do<br>
- * {@code getAttribute("java.lang:Runtime", "Name")}.</p>
- *
- * <p>The details of how contexts are encoded into ObjectNames are explained
- * in the {@link #encode encode} method.</p>
- *
- * <p>The namespace {@code jmx.context//} just mentioned is only needed by
- * remote clients, since local clients can set the context directly using
- * {@link #doWithContext doWithContext}.  Accordingly, this namespace is not
- * present by default in the {@code MBeanServer}.  Instead, it is
- * <em>simulated</em> by the standard RMI connector using a special
- * {@link MBeanServerForwarder}.  If you are using this connector, you do not
- * need to do anything special.  Other connectors may or may not simulate this
- * namespace in the same way.  If the connector server returns true from the
- * method {@link
- * javax.management.remote.JMXConnectorServer#supportsSystemMBeanServerForwarder()
- * supportsSystemMBeanServerForwarder} then it does simulate the namespace.
- * If you are using another connector, or if you want to be able to use the
- * {@code with*} methods locally, then you can install the {@code
- * MBeanServerForwarder} yourself as described in the method {@link
- * #newContextForwarder newContextForwarder}.</p>
- */
-public class ClientContext {
-    /**
-     * <p>The context key for the client locale.  The string associated with
-     * this key is an encoded locale such as {@code en_US} which could be
-     * returned by {@link Locale#toString()}.</p>
-     */
-    public static final String LOCALE_KEY = "jmx.locale";
-
-    private static final Logger LOG =
-            Logger.getLogger("javax.management.context");
-
-    /**
-     * <p>The namespace that implements contexts, {@value}.</p>
-     */
-    public static final String
-            NAMESPACE = "jmx.context";
-    private static final String NAMESPACE_PLUS_SEP =
-            NAMESPACE + NAMESPACE_SEPARATOR;
-    static final ObjectName CLIENT_CONTEXT_NAMESPACE_HANDLER =
-            ObjectName.valueOf(NAMESPACE_PLUS_SEP + ":" +
-                    JMXNamespace.TYPE_ASSIGNMENT);
-    private static final ObjectName NAMESPACE_HANDLER_WITHOUT_NAMESPACE =
-            ObjectName.valueOf(":" + JMXNamespace.TYPE_ASSIGNMENT);
-
-    private static final ThreadLocal<Map<String, String>> contextThreadLocal =
-            new InheritableThreadLocal<Map<String, String>>() {
-        @Override
-        protected Map<String, String> initialValue() {
-            return Collections.emptyMap();
-        }
-    };
-
-    /** There are no instances of this class. */
-    private ClientContext() {
-    }
-
-    /**
-     * <p>Get the client context associated with the current thread.
-     *
-     * @return the client context associated with the current thread.
-     * This may be an empty Map, but it cannot be null.  The returned
-     * Map cannot be modified.
-     */
-    public static Map<String, String> getContext() {
-        return Collections.unmodifiableMap(contextThreadLocal.get());
-    }
-
-    /**
-     * <p>Get the client locale associated with the current thread.
-     * If the client context includes the {@value #LOCALE_KEY} key
-     * then the returned value is the Locale encoded in that key.
-     * Otherwise the returned value is the {@linkplain Locale#getDefault()
-     * default locale}.
-     *
-     * @return the client locale.
-     */
-    public static Locale getLocale() {
-        String localeS = getContext().get(LOCALE_KEY);
-        if (localeS == null)
-            return Locale.getDefault();
-        // Parse the locale string.  Why isn't there a method in Locale for this?
-        String language, country, variant;
-        int ui = localeS.indexOf('_');
-        if (ui < 0) {
-            language = localeS;
-            country = variant = "";
-        } else {
-            language = localeS.substring(0, ui);
-            localeS = localeS.substring(ui + 1);
-            ui = localeS.indexOf('_');
-            if (ui < 0) {
-                country = localeS;
-                variant = "";
-            } else {
-                country = localeS.substring(0, ui);
-                variant = localeS.substring(ui + 1);
-            }
-        }
-        return new Locale(language, country, variant);
-    }
-
-    /**
-     * <p>Execute the given {@code task} with the client context set to
-     * the given Map.  This Map will be the result of {@link #getContext()}
-     * within the {@code task}.</p>
-     *
-     * <p>The {@code task} may include nested calls to {@code doWithContext}.
-     * The value returned by {@link #getContext} at any point is the Map
-     * provided to the most recent {@code doWithContext} (in the current thread)
-     * that has not yet returned.</p>
-     *
-     * <p>The {@link #getContext()} method returns the same value immediately
-     * after a call to this method as immediately before.  In other words,
-     * {@code doWithContext} only affects the context during the execution of
-     * the {@code task}.</p>
-     *
-     * <p>As an example, suppose you want to get an attribute with whatever
-     * context has already been set, plus the locale set to "fr".  You could
-     * write this:</p>
-     *
-     * <pre>
-     * {@code Map<String, String>} context =
-     *     new {@code HashMap<String, String>}(ClientContext.getContext());
-     * context.put(ClientContext.LOCALE_KEY, "fr");
-     * String lastProblemDescription =
-     *     ClientContext.doWithContext(context, new {@code Callable<String>}() {
-     *         public String call() {
-     *             return (String) mbeanServer.getAttribute(mbean, "LastProblemDescription");
-     *         }
-     *     });
-     * </pre>
-     *
-     * @param <T> the type of value that the task will return.  This type
-     * parameter is usually inferred from the type of the {@code task}
-     * parameter.  For example, if {@code task} is a {@code Callable<String>}
-     * then {@code T} is {@code String}.  If the task does not return a value,
-     * use a {@code Callable<Void>} and return null from its
-     * {@link Callable#call call} method.
-     * @param context the context to use while executing {@code task}.
-     * @param task the task to run with the {@code key}={@code value}
-     * binding.
-     * @return the result of {@link Callable#call() task.call()}.
-     * @throws IllegalArgumentException if either parameter is null, or
-     * if any key in {@code context} is null or empty, or if any value
-     * in {@code context} is null.
-     * @throws Exception If {@link Callable#call() task.call()} throws an
-     * exception, {@code doWithContext} throws the same exception.
-     */
-    public static <T> T doWithContext(Map<String, String> context, Callable<T> task)
-    throws Exception {
-        if (context == null || task == null)
-            throw new IllegalArgumentException("Null parameter");
-        Map<String, String> contextCopy = new TreeMap<String, String>(context);
-        validateContext(contextCopy);
-        Map<String, String> oldContextMap = contextThreadLocal.get();
-        try {
-            contextThreadLocal.set(contextCopy);
-            return task.call();
-        } finally {
-            contextThreadLocal.set(oldContextMap);
-        }
-    }
-
-    private static void validateContext(Map<String, String> context) {
-        for (Map.Entry<String, String> entry : context.entrySet()) {
-            // If the user passes a raw Map rather than a Map<String, String>,
-            // entries could contain objects other than Strings.  If so,
-            // we'll get a ClassCastException here.
-            String key = entry.getKey();
-            String value = entry.getValue();
-            if (key == null || value == null)
-                throw new IllegalArgumentException("Null key or value in context");
-            if (key.equals(""))
-                throw new IllegalArgumentException("Empty key in context");
-        }
-    }
-
-    /**
-     * <p>Return an MBeanServer object that is equivalent to the given
-     * MBeanServer object except that operations on MBeans run with
-     * the given Locale in their {@linkplain #getContext() thread context}.
-     * Note that this will only work if the given MBeanServer supports
-     * contexts, as described <a href="#remote-use">above</a>.</p>
-     *
-     * <p>This method is equivalent to {@link #withContext(MBeanServer,
-     * String, String) withContext}<code>(mbs, {@value LOCALE_KEY},
-     * locale.toString())</code>.</p>
-     *
-     * @throws IllegalArgumentException if either parameter is null, or if
-     * {@code mbs} does not support contexts.  In the second case only,
-     * the cause of the {@code IllegalArgumentException} will be an {@link
-     * InstanceNotFoundException}.
-     */
-    public static MBeanServer withLocale(MBeanServer mbs, Locale locale) {
-        return withLocale(mbs, MBeanServer.class, locale);
-    }
-
-    /**
-     * <p>Return an MBeanServerConnection object that is equivalent to the given
-     * MBeanServerConnection object except that operations on MBeans run with
-     * the given Locale in their {@linkplain #getContext() thread context}.
-     * Note that this will only work if the given MBeanServerConnection supports
-     * contexts, as described <a href="#remote-use">above</a>.</p>
-     *
-     * <p>This method is equivalent to {@link #withContext(MBeanServerConnection,
-     * String, String) withContext}<code>(mbs, {@value LOCALE_KEY},
-     * locale.toString())</code>.</p>
-     *
-     * @throws IllegalArgumentException if either parameter is null, or if
-     * the communication with {@code mbsc} fails, or if {@code mbsc} does not
-     * support contexts.  If the communication with {@code mbsc} fails, the
-     * {@linkplain Throwable#getCause() cause} of this exception will be an
-     * {@code IOException}.  If {@code mbsc} does not support contexts, the
-     * cause will be an {@link InstanceNotFoundException}.
-     */
-    public static MBeanServerConnection withLocale(
-            MBeanServerConnection mbsc, Locale locale) {
-        return withLocale(mbsc, MBeanServerConnection.class, locale);
-    }
-
-    private static <T extends MBeanServerConnection> T withLocale(
-            T mbsc, Class<T> mbscClass, Locale locale) {
-        if (locale == null)
-            throw new IllegalArgumentException("Null locale");
-        return withContext(mbsc, mbscClass, LOCALE_KEY, locale.toString());
-    }
-
-    /**
-     * <p>Return an MBeanServer object that is equivalent to the given
-     * MBeanServer object except that operations on MBeans run with
-     * the given key bound to the given value in their {@linkplain
-     * #getContext() thread context}.
-     * Note that this will only work if the given MBeanServer supports
-     * contexts, as described <a href="#remote-use">above</a>.</p>
-     *
-     * @param mbs the original MBeanServer.
-     * @param key the key to bind in the context of MBean operations
-     * in the returned MBeanServer object.
-     * @param value the value to bind to the key in the context of MBean
-     * operations in the returned MBeanServer object.
-     * @throws IllegalArgumentException if any parameter is null, or
-     * if {@code key} is the empty string, or if {@code mbs} does not support
-     * contexts.  In the last case only, the cause of the {@code
-     * IllegalArgumentException} will be an {@link InstanceNotFoundException}.
-     */
-    public static MBeanServer withContext(
-            MBeanServer mbs, String key, String value) {
-        return withContext(mbs, MBeanServer.class, key, value);
-    }
-
-    /**
-     * <p>Return an MBeanServerConnection object that is equivalent to the given
-     * MBeanServerConnection object except that operations on MBeans run with
-     * the given key bound to the given value in their {@linkplain
-     * #getContext() thread context}.
-     * Note that this will only work if the given MBeanServerConnection supports
-     * contexts, as described <a href="#remote-use">above</a>.</p>
-     *
-     * @param mbsc the original MBeanServerConnection.
-     * @param key the key to bind in the context of MBean operations
-     * in the returned MBeanServerConnection object.
-     * @param value the value to bind to the key in the context of MBean
-     * operations in the returned MBeanServerConnection object.
-     * @throws IllegalArgumentException if any parameter is null, or
-     * if {@code key} is the empty string, or if the communication with {@code
-     * mbsc} fails, or if {@code mbsc} does not support contexts.  If
-     * the communication with {@code mbsc} fails, the {@linkplain
-     * Throwable#getCause() cause} of this exception will be an {@code
-     * IOException}.  If {@code mbsc} does not support contexts, the cause will
-     * be an {@link InstanceNotFoundException}.
-     */
-    public static MBeanServerConnection withContext(
-            MBeanServerConnection mbsc, String key, String value) {
-        return withContext(mbsc, MBeanServerConnection.class, key, value);
-    }
-
-
-    /**
-     * <p>Returns an MBeanServerConnection object that is equivalent to the
-     * given MBeanServerConnection object except that remote operations on
-     * MBeans run with the context that has been established by the client
-     * using {@link #doWithContext doWithContext}.  Note that this will
-     * only work if the remote system supports contexts, as described <a
-     * href="#remote-use">above</a>.</p>
-     *
-     * <p>For example, suppose the remote system does support contexts, and you
-     * have created a {@code JMXConnector} like this:</p>
-     *
-     * <pre>
-     * JMXServiceURL url = ...;
-     * JMXConnector client = JMXConnectorFactory.connect(url);
-     * MBeanServerConnection mbsc = client.getMBeanServerConnection();
-     * <b>mbsc = ClientContext.withDynamicContext(mbsc);</b>
-     * </pre>
-     *
-     * <p>Then if you do this...</p>
-     *
-     * <pre>
-     * MBeanInfo mbi = ClientContext.doWithContext(
-     *     Collections.singletonMap(ClientContext.LOCALE_KEY, "fr"),
-     *     new {@code Callable<MBeanInfo>}() {
-     *         public MBeanInfo call() {
-     *             return mbsc.getMBeanInfo(objectName);
-     *         }
-     *     });
-     * </pre>
-     *
-     * <p>...then the context with the locale set to "fr" will be in place
-     * when the {@code getMBeanInfo} is executed on the remote MBean Server.</p>
-     *
-     * @param mbsc the original MBeanServerConnection.
-     *
-     * @throws IllegalArgumentException if the {@code mbsc} parameter is null,
-     * or if the communication with {@code mbsc} fails, or if {@code mbsc}
-     * does not support contexts.  If the communication with {@code mbsc}
-     * fails, the {@linkplain Throwable#getCause() cause} of this exception
-     * will be an {@code IOException}.  If {@code mbsc} does not support
-     * contexts, the cause will be an {@link InstanceNotFoundException}.
-     */
-    public static MBeanServerConnection withDynamicContext(
-            MBeanServerConnection mbsc) {
-        // Probe mbsc to get the right exception if it's incommunicado or
-        // doesn't support namespaces.
-        JMXNamespaces.narrowToNamespace(mbsc, NAMESPACE);
-        return (MBeanServerConnection) Proxy.newProxyInstance(
-                MBeanServerConnection.class.getClassLoader(),
-                new Class<?>[] {MBeanServerConnection.class},
-                new DynamicContextIH(mbsc));
-    }
-
-    private static class DynamicContextIH implements InvocationHandler {
-        private final MBeanServerConnection mbsc;
-
-        public DynamicContextIH(MBeanServerConnection mbsc) {
-            this.mbsc = mbsc;
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-                throws Throwable {
-            MBeanServerConnection dynMBSC = withContext(
-                    mbsc, MBeanServerConnection.class, getContext(), false);
-            try {
-                return method.invoke(dynMBSC, args);
-            } catch (InvocationTargetException e) {
-                throw e.getCause();
-            }
-        }
-    }
-
-    private static <T extends MBeanServerConnection> T withContext(
-            T mbsc, Class<T> mbscClass, String key, String value) {
-        return withContext(
-                mbsc, mbscClass, Collections.singletonMap(key, value), true);
-    }
-
-    private static <T extends MBeanServerConnection> T withContext(
-            T mbsc, Class<T> mbscClass, Map<String, String> context,
-            boolean probe) {
-        if (mbsc == null || context == null)
-            throw new IllegalArgumentException("Null parameter");
-        if (context.isEmpty())
-            return mbsc;
-        validateContext(context);
-        Map<String, String> contextMap = null;
-        if (mbsc.getClass() == RoutingServerProxy.class ||
-                mbsc.getClass() == RoutingProxy.class) {
-            RoutingProxy<?> nsp = (RoutingProxy<?>) mbsc;
-            String where = nsp.getSourceNamespace();
-            if (where.startsWith(NAMESPACE_PLUS_SEP)) {
-                /* Try to merge the existing context namespace with the
-                 * new one.  If it doesn't work, we fall back to just
-                 * prefixing jmx.context//key=value, which
-                 * might lead to a name like jmx.c//k1=v1//jmx.c//k2=v2//d:k=v.
-                 */
-                String encodedContext =
-                        where.substring(NAMESPACE_PLUS_SEP.length());
-                if (encodedContext.indexOf(NAMESPACE_SEPARATOR) < 0) {
-                    contextMap = stringToMapOrNull(encodedContext);
-                    if (contextMap != null) {
-                        contextMap.putAll(context);
-                        mbsc = mbscClass.cast(nsp.source());
-                    }
-                }
-            }
-        }
-        if (contextMap == null)
-            contextMap = context;
-        String contextDir = NAMESPACE_PLUS_SEP + mapToString(contextMap);
-        if (mbscClass == MBeanServer.class) {
-            return mbscClass.cast(RoutingServerProxy.cd(
-                    (MBeanServer) mbsc, contextDir, probe));
-        } else if (mbscClass == MBeanServerConnection.class) {
-            return mbscClass.cast(RoutingConnectionProxy.cd(
-                    mbsc, contextDir, probe));
-        } else
-            throw new AssertionError("Bad MBSC: " + mbscClass);
-    }
-
-    /**
-     * <p>Returns an encoded context prefix for ObjectNames.
-     * If the given context is empty, {@code ""} is returned.
-     * Otherwise, this method returns a string of the form
-     * {@code "jmx.context//key=value;key=value;..."}.
-     * For example, if the context has keys {@code "jmx.locale"}
-     * and {@code "xid"} with respective values {@code "fr"}
-     * and {@code "1234"}, this method will return
-     * {@code "jmx.context//jmx.locale=fr;xid=1234"} or
-     * {@code "jmx.context//xid=1234;jmx.locale=fr"}.</p>
-     *
-     * <p>Each key and each value in the encoded string is subject to
-     * encoding as if by the method {@link URLEncoder#encode(String, String)}
-     * with a character encoding of {@code "UTF-8"}, but with the additional
-     * encoding of any {@code *} character as {@code "%2A"}.  This ensures
-     * that keys and values can contain any character.  Without encoding,
-     * characters such as {@code =} and {@code :} would pose problems.</p>
-     *
-     * @param context the context to encode.
-     *
-     * @return the context in encoded form.
-     *
-     * @throws IllegalArgumentException if the {@code context} parameter
-     * is null or if it contains a null key or value.
-     **/
-    public static String encode(Map<String, String> context) {
-        if (context == null)
-            throw new IllegalArgumentException("Null context");
-        if (context.isEmpty())
-            return "";
-        StringBuilder sb = new StringBuilder();
-        for (Map.Entry<String, String> entry : context.entrySet()) {
-            String key = entry.getKey();
-            String value = entry.getValue();
-            if (key == null || value == null)
-                throw new IllegalArgumentException("Null key or value");
-            if (sb.length() > 0)
-                sb.append(";");
-            sb.append(encode(key)).append("=").append(encode(value));
-        }
-        sb.insert(0, NAMESPACE_PLUS_SEP);
-        return sb.toString();
-    }
-
-    /**
-     * <p>Create a new {@link MBeanServerForwarder} that applies the context
-     * received from a client to the current thread.  A client using
-     * one of the various {@code with*} methods (for example {@link
-     * #withContext(MBeanServerConnection, String, String) withContext}) will
-     * encode that context into the {@code ObjectName} of each
-     * {@code MBeanServer} request.  The object returned by this method
-     * decodes the context from that {@code ObjectName} and applies it
-     * as described for {@link #doWithContext doWithContext} while performing
-     * the {@code MBeanServer} request using the {@code ObjectName} without
-     * the encoded context.</p>
-     *
-     * <p>This forwarder can be used in a number of ways:</p>
-     *
-     * <ul>
-     * <li>
-     * <p>To add context decoding to a local {@code MBeanServer}, you can
-     * write:</p>
-     * <pre>
-     * MBeanServer mbs = {@link
-     * java.lang.management.ManagementFactory#getPlatformMBeanServer()
-     * ManagementFactory.getPlatformMBeanServer()};  // for example
-     * mbs = ClientContext.newContextForwarder(mbs, null);
-     * </pre>
-     *
-     * <li>
-     * <p>To add context decoding to a {@linkplain
-     * javax.management.remote.JMXConnectorServer connector server}:</p>
-     * <pre>
-     * JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(...);
-     * MBeanServer nextMBS = cs.getMBeanServer();
-     * MBeanServerForwarder mbsf = ClientContext.newContextForwarder(nextMBS, null);
-     * cs.{@link
-     * javax.management.remote.JMXConnectorServer#setMBeanServerForwarder
-     * setMBeanServerForwarder}(mbsf);
-     * </pre>
-     *
-     * <li>
-     * <p>For connectors, such as the standard RMI connector, that support
-     * a {@linkplain
-     * javax.management.remote.JMXConnectorServer#getSystemMBeanServerForwarder
-     * system chain} of {@code MBeanServerForwarder}s, this forwarder will
-     * be installed in that chain by default.  See
-     * {@link javax.management.remote.JMXConnectorServer#CONTEXT_FORWARDER
-     * JMXConnectorServer.CONTEXT_FORWARDER}.
-     * </p>
-     *
-     * </ul>
-     *
-     * @param nextMBS the next {@code MBeanServer} in the chain of
-     * forwarders, which might be another {@code MBeanServerForwarder} or
-     * a plain {@code MBeanServer}.  This is the object to which {@code
-     * MBeanServer} requests that do not include a context are sent.  It
-     * will be the value of {@link MBeanServerForwarder#getMBeanServer()
-     * getMBeanServer()} on the returned object, and can be changed with {@link
-     * MBeanServerForwarder#setMBeanServer setMBeanServer}.  It can be null but
-     * must be set to a non-null value before any {@code MBeanServer} requests
-     * arrive.
-     *
-     * @param loopMBS the {@code MBeanServer} to which requests that contain
-     * an encoded context should be sent once the context has been decoded.
-     * For example, if the request is {@link MBeanServer#getAttribute
-     * getAttribute}{@code ("jmx.context//jmx.locale=fr//java.lang:type=Runtime",
-     * "Name")}, then the {@linkplain #getContext() context} of the thread
-     * executing that request will have {@code "jmx.locale"} set to {@code "fr"}
-     * while executing {@code loopMBS.getAttribute("java.lang:type=Runtime",
-     * "Name")}.  If this parameter is null, then these requests will be
-     * sent to the newly-created {@code MBeanServerForwarder}.  Usually
-     * the parameter will either be null or will be the result of {@link
-     * javax.management.remote.JMXConnectorServer#getSystemMBeanServerForwarder
-     * getSystemMBeanServerForwarder()} for the connector server in which
-     * this forwarder will be installed.
-     *
-     * @return a new {@code MBeanServerForwarder} that decodes client context
-     * from {@code ObjectName}s.
-     */
-    /*
-     * What we're building here is confusing enough to need a diagram.
-     * The MBSF that we return is actually the composition of two forwarders:
-     * the first one simulates the existence of the MBean
-     * jmx.context//:type=JMXNamespace, and the second one simulates the
-     * existence of the namespace jmx.context//.  Furthermore, that namespace
-     * loops back to the composed forwarder, so that something like
-     * jmx.context//foo=bar//jmxcontext//baz=buh will work.  And the loopback
-     * goes through yet another forwarder, which simulates the existence of
-     * (e.g.) jmx.context//foo=bar//:type=JMXNamespace, which is needed
-     * notably so that narrowToNamespace will work.
-     *
-     *          |     +--------------------------------------------------+
-     *          v     v                                                  |
-     * +----------------+                                                |
-     * | Handler MBSF   |->accesses to jmx.context//:type=JMXNamespace   |
-     * +----------------+    (handled completely here)   +-------------------+
-     *          |                                        | 2nd Handler MBSF  |
-     *          v                                        +-------------------+
-     * +----------------+                                                ^
-     * | Namespace MBSF |->accesses to jmx.context//**-------------------+
-     * +----------------+    (after attaching context to thread)
-     *          |
-     *          v          accesses to anything else
-     *
-     * And finally, we need to ensure that from the outside the composed object
-     * looks like a single forwarder, so that its get/setMBeanServer methods
-     * will do the expected thing.  That's what the anonymous subclass is for.
-     */
-    public static MBeanServerForwarder newContextForwarder(
-            MBeanServer nextMBS, MBeanServer loopMBS) {
-        final MBeanServerForwarder mbsWrapper =
-                new IdentityMBeanServerForwarder(nextMBS);
-        DynamicMBean handlerMBean = new StandardMBean(
-                new JMXNamespace(mbsWrapper), JMXNamespaceMBean.class, false);
-        SingleMBeanForwarder handlerForwarder = new SingleMBeanForwarder(
-                CLIENT_CONTEXT_NAMESPACE_HANDLER, handlerMBean, true) {
-            @Override
-            public MBeanServer getMBeanServer() {
-                return ((MBeanServerForwarder) super.getMBeanServer()).getMBeanServer();
-            }
-
-            @Override
-            public void setMBeanServer(MBeanServer mbs1) {
-                MBeanServerForwarder mbsf1 = (MBeanServerForwarder)
-                        super.getMBeanServer();
-                if (mbsf1 != null)
-                    mbsf1.setMBeanServer(mbs1);
-                else
-                    super.setMBeanServer(mbs1);
-                mbsWrapper.setMBeanServer(mbs1);
-            }
-        };
-        if (loopMBS == null)
-            loopMBS = handlerForwarder;
-        ContextInvocationHandler contextIH =
-                new ContextInvocationHandler(nextMBS, loopMBS);
-        MBeanServerForwarder contextForwarder = newForwarderProxy(contextIH);
-        handlerForwarder.setMBeanServer(contextForwarder);
-        return handlerForwarder;
-    }
-
-    /**
-     * <p>Create a new {@link MBeanServerForwarder} that localizes
-     * descriptions in {@code MBeanInfo} instances returned by
-     * {@link MBeanServer#getMBeanInfo getMBeanInfo}.  The {@code
-     * MBeanServerForwarder} returned by this method passes all {@code
-     * MBeanServer} methods through unchanged to the supplied object, {@code
-     * mbs}, with the exception of {@code getMBeanInfo}.  To handle {@code
-     * getMBeanInfo(objectName)}, it calls {@code mbs.getMBeanInfo(objectName)}
-     * to get an {@code MBeanInfo}, {@code mbi}; it calls {@link
-     * MBeanServer#getClassLoaderFor mbs.getClassLoaderFor(objectName)} to
-     * get a {@code ClassLoader}, {@code cl}; and it calls {@link
-     * #getLocale} to get a {@code Locale}, {@code locale}.  The order
-     * of these three calls is not specified.  Then the result is {@code
-     * mbi.localizeDescriptions(locale, loader)}.</p>
-     *
-     * <p>This forwarder can be used in a number of ways:</p>
-     *
-     * <ul>
-     * <li>
-     * <p>To add description localization to a local {@code MBeanServer}, you
-     * can write:</p>
-     *
-     * <pre>
-     * MBeanServer mbs = {@link
-     * java.lang.management.ManagementFactory#getPlatformMBeanServer()
-     * ManagementFactory.getPlatformMBeanServer()};  // for example
-     * mbs = ClientContext.newLocalizeMBeanInfoForwarder(mbs);
-     * </pre>
-     *
-     * <li>
-     * <p>To add description localization to a {@linkplain
-     * javax.management.remote.JMXConnectorServer connector server}, you will
-     * need to add both a {@linkplain #newContextForwarder context forwarder}
-     * and a localization forwarder, for example like this:</p>
-     *
-     * <pre>
-     * JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(...);
-     * MBeanServer nextMBS = cs.getMBeanServer();
-     * MBeanServerForwarder localizeMBSF =
-     *     ClientContext.newLocalizeMBeanInfoForwarder(nextMBS);
-     * MBeanServerForwarder contextMBSF =
-     *     ClientContext.newContextForwarder(localizeMBSF, null);
-     * cs.{@link
-     * javax.management.remote.JMXConnectorServer#setMBeanServerForwarder
-     * setMBeanServerForwarder}(contextMBSF);
-     * </pre>
-     *
-     * <p>Notice that the context forwarder must run before the localization
-     * forwarder, so that the locale is correctly established when the latter
-     * runs.  So the {@code nextMBS} parameter of the context forwarder must
-     * be the localization forwarder, and not vice versa.</p>
-     *
-     * <li>
-     * <p>For connectors, such as the standard RMI connector, that support
-     * a {@linkplain
-     * javax.management.remote.JMXConnectorServer#getSystemMBeanServerForwarder
-     * system chain} of {@code MBeanServerForwarder}s, the context forwarder and
-     * the localization forwarder will be installed in that chain, in the right
-     * order, if you include
-     * {@link
-     * javax.management.remote.JMXConnectorServer#LOCALIZE_MBEAN_INFO_FORWARDER
-     * LOCALIZE_MBEAN_INFO_FORWARDER} in the environment {@code Map} with
-     * the value {@code "true"}, for example like this:</p>
-     * </p>
-     * <pre>
-     * MBeanServer mbs = ...;
-     * JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://...");
-     * {@code Map<String, Object>} env = new {@code HashMap<String, Object>}();
-     * env.put(JMXConnectorServer.LOCALIZE_MBEAN_INFO_FORWARDER, "true");
-     * JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
-     *     url, env, mbs);
-     * </pre>
-     *
-     * </ul>
-     *
-     * @param mbs the next {@code MBeanServer} in the chain of
-     * forwarders, which might be another {@code MBeanServerForwarder}
-     * or a plain {@code MBeanServer}.  It will be the value of
-     * {@link MBeanServerForwarder#getMBeanServer() getMBeanServer()}
-     * on the returned object, and can be changed with {@link
-     * MBeanServerForwarder#setMBeanServer setMBeanServer}.  It can be null but
-     * must be set to a non-null value before any {@code MBeanServer} requests
-     * arrive.
-     *
-     * @return a new {@code MBeanServerForwarder} that localizes descriptions
-     * in the result of {@code getMBeanInfo}.
-     */
-    public static MBeanServerForwarder newLocalizeMBeanInfoForwarder(
-            MBeanServer mbs) {
-        return new IdentityMBeanServerForwarder(mbs) {
-            @Override
-            public MBeanInfo getMBeanInfo(ObjectName name)
-                    throws InstanceNotFoundException, IntrospectionException,
-                           ReflectionException {
-                MBeanInfo mbi = super.getMBeanInfo(name);
-                Locale locale = getLocale();
-                ClassLoader loader = getClassLoaderFor(name);
-                return mbi.localizeDescriptions(locale, loader);
-            }
-        };
-    }
-
-    private static MBeanServerForwarder newForwarderProxy(InvocationHandler ih) {
-        return (MBeanServerForwarder) Proxy.newProxyInstance(
-                MBeanServerForwarder.class.getClassLoader(),
-                new Class<?>[] {MBeanServerForwarder.class},
-                ih);
-    }
-
-    // A proxy connection that will strip the 'contextDir' at input (routing),
-    // and put it back at output (createMBean / registerMBean / query* /
-    // getObjectInstance). Usually RoutingProxy / RoutingServerProxy are used
-    // the other way round (they are used for 'cd' - where they need to add
-    // something at input and remove it at output).
-    // For 'cd' operations we create RoutingProxys with a non empty sourceDir,
-    // and a possibly non-empty targetDir. This is the only case where we use
-    // RoutingProxies with an empty sourceDir (sourceDir is what we add at input
-    // and remove at output, targetDir is what we remove at input and add at
-    // output.
-    //
-    // Note that using a transient ContextRoutingConnection
-    // is possible only because RoutingProxys don't rewrite
-    // notifications sources - otherwise we would have to
-    // keep the ContextRoutingConnection - just to preserve
-    // the 'wrapping listeners'
-    //
-    private static final class ContextRoutingConnection
-            extends RoutingServerProxy {
-        public ContextRoutingConnection(MBeanServer source,
-                                 String contextDir) {
-            super(source, "", contextDir, false);
-        }
-
-        // Not really needed - but this is safer and more optimized.
-        // See RoutingProxy for more details.
-        //
-        @Override
-        public Integer getMBeanCount() {
-            return source().getMBeanCount();
-        }
-
-        // Not really needed - but this is safer and more optimized.
-        // See RoutingProxy for more details.
-        //
-        @Override
-        public String[] getDomains() {
-            return source().getDomains();
-        }
-
-        // Not really needed - but this is safer and more optimized.
-        // See RoutingProxy for more details.
-        //
-        @Override
-        public String getDefaultDomain() {
-            return source().getDefaultDomain();
-        }
-
-    }
-
-    private static class ContextInvocationHandler implements InvocationHandler {
-        /*
-         * MBeanServer requests that don't include jmx.context//foo=bar//
-         * are forwarded to forwardMBS, which is the unadorned MBeanServer
-         * that knows nothing about the context namespace.
-         * MBeanServer requests that do include this prefix will
-         * usually (depending on the value of the loopMBS parameter to
-         * newContextForwarder) loop back to the combined MBeanServerForwarder
-         * that first implements
-         * jmx.context//:type=JMXNamespace and then implements
-         * jmx.context//foo=bar//.  The reason is that it is valid
-         * to have jmx.context//foo=bar//jmx.context//baz=buh//, although
-         * usually that will be combined into jmx.context//foo=bar;baz=buh//.
-         *
-         * Before forwarding to loopMBS, we must check for :type=JMXNamespace
-         * so that jmx.context//foo=bar//:type=JMXNamespace will exist.  Its
-         * existence is partial because it must remain "invisible": it should
-         * not show up in queryNames or getMBeanCount even though it does
-         * accept getAttribute and isRegistered and all other methods that
-         * reference a single MBean.
-         */
-        private MBeanServer forwardMBS;
-        private final MBeanServer loopMBS;
-        private static final MBeanServer emptyMBS = new MBeanServerSupport() {
-            @Override
-            public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                    throws InstanceNotFoundException {
-                throw new InstanceNotFoundException(name.toString());
-            }
-
-            @Override
-            protected Set<ObjectName> getNames() {
-                return Collections.emptySet();
-            }
-        };
-
-        ContextInvocationHandler(MBeanServer forwardMBS, MBeanServer loopMBS) {
-            this.forwardMBS = forwardMBS;
-            DynamicMBean handlerMBean = new StandardMBean(
-                    new JMXNamespace(loopMBS), JMXNamespaceMBean.class, false);
-            MBeanServerForwarder handlerMBS = new SingleMBeanForwarder(
-                    NAMESPACE_HANDLER_WITHOUT_NAMESPACE, handlerMBean, false);
-            handlerMBS.setMBeanServer(loopMBS);
-            this.loopMBS = handlerMBS;
-        }
-
-        public Object invoke(Object proxy, final Method method, final Object[] args)
-        throws Throwable {
-            String methodName = method.getName();
-            Class<?>[] paramTypes = method.getParameterTypes();
-
-            // If this is a method from MBeanServerForwarder, handle it here.
-            // There are only two such methods: getMBeanServer() and
-            // setMBeanServer(mbs).
-            if (methodName.equals("getMBeanServer"))
-                return forwardMBS;
-            else if (methodName.equals("setMBeanServer")) {
-                this.forwardMBS = (MBeanServer) args[0];
-                return null;
-            }
-
-            // It is a method from MBeanServer.
-            // Find the first parameter whose declared type is ObjectName,
-            // and see if it is in the context namespace.  If so we need to
-            // trigger the logic for that namespace.  If not, we simply
-            // forward to the next MBeanServer in the chain.  This logic
-            // depends on the fact that if a method in the MBeanServer interface
-            // has a "routing" ObjectName parameter, it is always the first
-            // parameter of that type.  Conversely, if a method has an
-            // ObjectName parameter, then it makes sense to "route" that
-            // method.  Except for deserialize and instantiate, but if we
-            // recognize a context namespace in those methods' ObjectName
-            // parameters it is pretty harmless.
-            int objectNameI = -1;
-            for (int i = 0; i < paramTypes.length; i++) {
-                if (paramTypes[i] == ObjectName.class) {
-                    objectNameI = i;
-                    break;
-                }
-            }
-
-            if (objectNameI < 0)
-                return invoke(method, forwardMBS, args);
-
-            ObjectName target = (ObjectName) args[objectNameI];
-            if (target == null ||
-                    !target.getDomain().startsWith(NAMESPACE_PLUS_SEP))
-                return invoke(method, forwardMBS, args);
-
-            String domain = target.getDomain().substring(NAMESPACE_PLUS_SEP.length());
-
-            // The method routes through the (simulated) context namespace.
-            // Decode the context after it, e.g. jmx.context//jmx.locale=fr//...
-            // If there is no context part, we can throw an exception,
-            // because a forwarder has already handled the unique MBean
-            // jmx.context//:type=JMXNamespace.
-            int sep = domain.indexOf(NAMESPACE_SEPARATOR);
-            if (sep < 0)
-                return invoke(method, emptyMBS, args);  // throw exception
-            final String encodedContext = domain.substring(0, sep);
-
-            if (method.getName().startsWith("query") &&
-                    (encodedContext.contains("*") || encodedContext.contains("?"))) {
-                // Queries like jmx.context//*//d:k=v return
-                // an empty set, consistent with "real" namespaces.
-                return Collections.EMPTY_SET;
-            }
-
-            Map<String, String> ctx = new TreeMap<String, String>(getContext());
-            ctx.putAll(stringToMap(encodedContext));
-
-            return doWithContext(ctx, new Callable<Object>() {
-                public Object call() throws Exception {
-                    // Create a proxy connection that will strip
-                    // "jmx.context//" + encodedContext + "//" on input,
-                    // and put it back on output.
-                    //
-                    // Note that using a transient ContextRoutingConnection
-                    // is possible only because it doesn't rewrite
-                    // notification sources - otherwise we would have to
-                    // keep the ContextRoutingConnection - just to preserve
-                    // the 'wrapping listeners'
-                    //
-                    String namespace = NAMESPACE_PLUS_SEP + encodedContext;
-                    final ContextRoutingConnection route =
-                              new ContextRoutingConnection(loopMBS, namespace);
-
-                    if (LOG.isLoggable(Level.FINE))
-                        LOG.fine("context="+encodedContext);
-                    if (LOG.isLoggable(Level.FINER))
-                        LOG.finer(method.getName()+""+
-                            ((args==null)?"()":(""+Arrays.asList(args))));
-
-                    return invoke(method, route, args);
-                }
-            });
-        }
-
-        private static Object invoke(Method method, Object target, Object[] args)
-                throws Exception {
-            try {
-                return method.invoke(target, args);
-            } catch (InvocationTargetException e) {
-                Throwable cause = e.getCause();
-                if (cause instanceof Error)
-                    throw (Error) cause;
-                throw (Exception) cause;
-            }
-        }
-    }
-
-    private static String mapToString(Map<String, String> map) {
-        StringBuilder sb = new StringBuilder();
-        for (Map.Entry<String, String> entry : map.entrySet()) {
-            String key = encode(entry.getKey());
-            String value = encode(entry.getValue());
-            if (sb.length() > 0)
-                sb.append(";");
-            sb.append(key).append("=").append(value);
-        }
-        return sb.toString();
-    }
-
-    private static Map<String, String> stringToMap(String encodedContext) {
-        Map<String, String> map = stringToMapOrNull(encodedContext);
-        if (map == null) {
-            throw new IllegalArgumentException(
-                    "Invalid encoded context: " + encodedContext);
-        }
-        return map;
-    }
-
-    private static Map<String, String> stringToMapOrNull(String encodedContext) {
-        Map<String, String> map = new LinkedHashMap<String, String>();
-        StringTokenizer stok = new StringTokenizer(encodedContext, ";");
-        while (stok.hasMoreTokens()) {
-            String tok = stok.nextToken();
-            int eq = tok.indexOf('=');
-            if (eq < 0)
-                return null;
-            String key = decode(tok.substring(0, eq));
-            if (key.equals(""))
-                return null;
-            String value = decode(tok.substring(eq + 1));
-            map.put(key, value);
-        }
-        return map;
-    }
-
-    private static String encode(String s) {
-        try {
-            s = URLEncoder.encode(s, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e);  // Should not happen
-        }
-        return s.replace("*", "%2A");
-        // The * character is left intact in URL encodings, but for us it
-        // is special (an ObjectName wildcard) so we must map it.
-        // We are assuming that URLDecoder will decode it the same way as any
-        // other hex escape.
-    }
-
-    private static String decode(String s) {
-        try {
-            return URLDecoder.decode(s, "UTF-8");
-        } catch (UnsupportedEncodingException e) {
-            throw new RuntimeException(e);
-        }
-    }
-}
--- a/src/share/classes/javax/management/Description.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.util.ResourceBundle;
-
-/**
- * <p>The textual description of an MBean or part of an MBean.  This
- * description is intended to be displayed to users to help them
- * understand what the MBean does.  Ultimately it will be the value of
- * the {@code getDescription()} method of an {@link MBeanInfo}, {@link
- * MBeanAttributeInfo}, or similar.</p>
- *
- * <p>This annotation applies to Standard MBean interfaces and to
- * MXBean interfaces, as well as to MBean classes defined using the
- * {@link MBean @MBean} or {@link MXBean @MXBean} annotations.  For
- * example, a Standard MBean might be defined like this:</p>
- *
- * <pre>
- * <b>{@code @Description}</b>("Application configuration")
- * public interface ConfigurationMBean {
- *     <b>{@code @Description}</b>("Cache size in bytes")
- *     public int getCacheSize();
- *     public void setCacheSize(int size);
- *
- *     <b>{@code @Description}</b>("Last time the configuration was changed, " +
- *                  "in milliseconds since 1 Jan 1970")
- *     public long getLastChangedTime();
- *
- *     <b>{@code @Description}</b>("Save the configuration to a file")
- *     public void save(
- *         <b>{@code @Description}</b>("Optional name of the file, or null for the default name")
- *         String fileName);
- * }
- * </pre>
- *
- * <p>The {@code MBeanInfo} for this MBean will have a {@link
- * MBeanInfo#getDescription() getDescription()} that is {@code
- * "Application configuration"}.  It will contain an {@code
- * MBeanAttributeInfo} for the {@code CacheSize} attribute that is
- * defined by the methods {@code getCacheSize} and {@code
- * setCacheSize}, and another {@code MBeanAttributeInfo} for {@code
- * LastChangedTime}.  The {@link MBeanAttributeInfo#getDescription()
- * getDescription()} for {@code CacheSize} will be {@code "Cache size
- * in bytes"}.  Notice that there is no need to add a
- * {@code @Description} to both {@code getCacheSize} and {@code
- * setCacheSize} - either alone will do.  But if you do add a
- * {@code @Description} to both, it must be the same.</p>
- *
- * <p>The {@code MBeanInfo} will also contain an {@link
- * MBeanOperationInfo} where {@link
- * MBeanOperationInfo#getDescription() getDescription()} is {@code
- * "Save the configuration to a file"}.  This {@code
- * MBeanOperationInfo} will contain an {@link MBeanParameterInfo}
- * where {@link MBeanParameterInfo#getDescription() getDescription()}
- * is {@code "Optional name of the file, or null for the default
- * name"}.</p>
- *
- * <p>The {@code @Description} annotation can also be applied to the
- * public constructors of the implementation class.  Continuing the
- * above example, the {@code Configuration} class implementing {@code
- * ConfigurationMBean} might look like this:</p>
- *
- * <pre>
- * public class Configuration implements ConfigurationMBean {
- *     <b>{@code @Description}</b>("A Configuration MBean with the default file name")
- *     public Configuration() {
- *         this(DEFAULT_FILE_NAME);
- *     }
- *
- *     <b>{@code @Description}</b>("A Configuration MBean with a specified file name")
- *     public Configuration(
- *         <b>{@code @Description}</b>("Name of the file the configuration is stored in")
- *         String fileName) {...}
- *     ...
- * }
- * </pre>
- *
- * <p>The {@code @Description} annotation also works in MBeans that
- * are defined using the {@code @MBean} or {@code @MXBean} annotation
- * on classes.  Here is an alternative implementation of {@code
- * Configuration} that does not use an {@code ConfigurationMBean}
- * interface.</p>
- *
- * <pre>
- * <b>{@code @MBean}</b>
- * <b>{@code @Description}</b>("Application configuration")
- * public class Configuration {
- *     <b>{@code @Description}</b>("A Configuration MBean with the default file name")
- *     public Configuration() {
- *         this(DEFAULT_FILE_NAME);
- *     }
- *
- *     <b>{@code @Description}</b>("A Configuration MBean with a specified file name")
- *     public Configuration(
- *         <b>{@code @Description}</b>("Name of the file the configuration is stored in")
- *         String fileName) {...}
- *
- *     <b>{@code @ManagedAttribute}</b>
- *     <b>{@code @Description}</b>("Cache size in bytes")
- *     public int getCacheSize() {...}
- *     <b>{@code @ManagedAttribute}</b>
- *     public void setCacheSize(int size) {...}
- *
- *     <b>{@code @ManagedOperation}</b>
- *     <b>{@code @Description}</b>("Last time the configuration was changed, " +
- *                  "in milliseconds since 1 Jan 1970")
- *     public long getLastChangedTime() {...}
- *
- *     <b>{@code @ManagedOperation}</b>
- *     <b>{@code @Description}</b>("Save the configuration to a file")
- *     public void save(
- *         <b>{@code @Description}</b>("Optional name of the file, or null for the default name")
- *         String fileName) {...}
- *     ...
- * }
- * </pre>
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.PARAMETER,
-         ElementType.TYPE})
-public @interface Description {
-    /**
-     * <p>The description.</p>
-     */
-    String value();
-
-    /**
-     * <p>The base name for the {@link ResourceBundle} in which the key given in
-     * the {@code descriptionResourceKey} field can be found, for example
-     * {@code "com.example.myapp.MBeanResources"}.  If a non-default value
-     * is supplied for this element, it will appear in the
-     * <a href="Descriptor.html#descriptionResourceBundleBaseName"><!--
-     * -->{@code Descriptor}</a> for the annotated item.</p>
-     */
-    @DescriptorKey(
-        value = "descriptionResourceBundleBaseName", omitIfDefault = true)
-    String bundleBaseName() default "";
-
-    /**
-     * <p>A resource key for the description of this element.  In
-     * conjunction with the {@link #bundleBaseName bundleBaseName},
-     * this can be used to find a localized version of the description.
-     * If a non-default value
-     * is supplied for this element, it will appear in the
-     * <a href="Descriptor.html#descriptionResourceKey"><!--
-     * -->{@code Descriptor}</a> for the annotated item.</p>
-     */
-    @DescriptorKey(value = "descriptionResourceKey", omitIfDefault = true)
-    String key() default "";
-}
--- a/src/share/classes/javax/management/Descriptor.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/Descriptor.java	Wed Nov 25 11:08:25 2009 -0800
@@ -38,7 +38,6 @@
 import java.util.Locale;
 import java.util.ResourceBundle;
 import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.MXBeanMappingFactory;
 import javax.management.openmbean.OpenMBeanAttributeInfoSupport;
 import javax.management.openmbean.OpenMBeanOperationInfoSupport;
 import javax.management.openmbean.OpenMBeanParameterInfoSupport;
@@ -118,22 +117,23 @@
  * deprecation, for example {@code "1.3 Replaced by the Capacity
  * attribute"}.</td>
  *
- * <tr><td id="descriptionResourceBundleBaseName"><i>descriptionResource<br>
- * BundleBaseName</i></td><td>String</td><td>Any</td>
+ * <tr><td id="descriptionResourceBundleBaseName">descriptionResource<br>
+ * BundleBaseName</td><td>String</td><td>Any</td>
  *
  * <td>The base name for the {@link ResourceBundle} in which the key given in
  * the {@code descriptionResourceKey} field can be found, for example
- * {@code "com.example.myapp.MBeanResources"}.  See
- * {@link MBeanInfo#localizeDescriptions MBeanInfo.localizeDescriptions}.</td>
+ * {@code "com.example.myapp.MBeanResources"}.  The meaning of this
+ * field is defined by this specification but the field is not set or
+ * used by the JMX API itself.</td>
  *
- * <tr><td id="descriptionResourceKey"><i>descriptionResourceKey</i></td>
+ * <tr><td id="descriptionResourceKey">descriptionResourceKey</td>
  * <td>String</td><td>Any</td>
  *
  * <td>A resource key for the description of this element.  In
  * conjunction with the {@code descriptionResourceBundleBaseName},
  * this can be used to find a localized version of the description.
- * See {@link MBeanInfo#localizeDescriptions MBeanInfo.localizeDescriptions}.
- * </td>
+ * The meaning of this field is defined by this specification but the
+ * field is not set or used by the JMX API itself.</td>
  *
  * <tr><td>enabled</td><td>String</td>
  * <td>MBeanAttributeInfo<br>MBeanNotificationInfo<br>MBeanOperationInfo</td>
@@ -147,31 +147,16 @@
  * might be disabled if it cannot currently be emitted but could be in
  * other circumstances.</td>
  *
- * <tr id="exceptions"><td><i>exceptions</i><td>String[]</td>
+ * <tr id="exceptions"><td>exceptions<td>String[]</td>
  * <td>MBeanAttributeInfo, MBeanConstructorInfo, MBeanOperationInfo</td>
  *
  * <td>The class names of the exceptions that can be thrown when invoking a
- * constructor or operation, or getting an attribute. Exceptions thrown when
+ * constructor or operation, or getting an attribute. The meaning of this field
+ * is defined by this specification but the field is not set or used by the
+ * JMX API itself. Exceptions thrown when
  * setting an attribute are specified by the field
  * <a href="#setExceptions">{@code setExceptions}</a>.
  *
- * <tr id="exceptionErrorCodes"><td>exceptionErrorCodes</td><td>String[]</td>
- * <td>MBeanAttributeInfo<br>MBeanConstructorInfo<br>MBeanOperationInfo</td>
- *
- * <td>The {@linkplain GenericMBeanException#getErrorCode() error codes}
- * that can appear in a {@link GenericMBeanException} thrown when getting
- * this attribute or invoking this operation or constructor.  See also
- * <a href="#setExceptionErrorCodes">{@code setExceptionErrorCodes}</a>.
- *
- * <tr id="exceptionUserDataTypes"><td>exceptionUserDataTypes</td>
- * <td>{@link javax.management.openmbean.CompositeType}[]</td>
- * <td>MBeanAttributeInfo<br>MBeanConstructorInfo<br>MBeanOperationInfo</td>
- *
- * <td>The types of {@linkplain GenericMBeanException#getUserData() userData}
- * that can appear in a {@link GenericMBeanException} thrown when getting
- * this attribute or invoking this operation or constructor.  See also
- * <a href="#setExceptionUserDataTypes">{@code setExceptionUserDataTypes}</a>.
- *
  * <tr id="immutableInfo"><td><i>immutableInfo</i><td>String</td>
  * <td>MBeanInfo</td>
  *
@@ -213,7 +198,7 @@
  * <td>Legal values for an attribute or parameter.  See
  * {@link javax.management.openmbean}.</td>
  *
- * <tr id="locale"><td><i>locale</i></td>
+ * <tr id="locale"><td>locale</td>
  * <td>String</td><td>Any</td>
  *
  * <td>The {@linkplain Locale locale} of the description in this
@@ -254,21 +239,6 @@
  * StandardMBean} class will have this field in its MBeanInfo
  * Descriptor.</td>
  *
- * <tr><td id="mxbeanMappingFactoryClass"><i>mxbeanMappingFactoryClass</i>
- * </td><td>String</td>
- * <td>MBeanInfo</td>
- *
- * <td>The name of the {@link MXBeanMappingFactory} class that was used for this
- * MXBean, if it was not the {@linkplain MXBeanMappingFactory#DEFAULT default}
- * one.</td>
- *
- * <tr><td id="objectNameTemplate"><i>objectNameTemplate</i>
- * </td><td>String</td>
- * <td>MBeanInfo</td>
- *
- * <td>The template to use to name this MBean. Its value must be compliant with
- * the specification of the {@link ObjectNameTemplate} annotation.</td>
- *
  * <tr id="openType"><td><i>openType</i><td>{@link OpenType}</td>
  * <td>MBeanAttributeInfo<br>MBeanOperationInfo<br>MBeanParameterInfo</td>
  *
@@ -306,26 +276,11 @@
  * <td>MBeanAttributeInfo</td>
  *
  * <td>The class names of the exceptions that can be thrown when setting
- * an attribute. Exceptions thrown when getting an attribute are specified
+ * an attribute. The meaning of this field
+ * is defined by this specification but the field is not set or used by the
+ * JMX API itself.  Exceptions thrown when getting an attribute are specified
  * by the field <a href="#exceptions">{@code exceptions}</a>.
  *
- * <tr id="setExceptionErrorCodes"><td>setExceptionErrorCodes</td>
- * <td>String[]</td><td>MBeanAttributeInfo</td>
- *
- * <td>The {@linkplain GenericMBeanException#getErrorCode() error codes}
- * that can appear in a {@link GenericMBeanException} thrown when setting
- * this attribute.  See also
- * <a href="#exceptionErrorCodes">{@code exceptionErrorCodes}</a>.
- *
- * <tr id="setExceptionUserDataTypes"><td>setExceptionUserDataTypes</td>
- * <td>{@link javax.management.openmbean.CompositeType}[]</td>
- * <td>MBeanAttributeInfo</td>
- *
- * <td>The types of {@linkplain GenericMBeanException#getUserData() userData}
- * that can appear in a {@link GenericMBeanException} thrown when setting
- * this attribute.  See also
- * <a href="#exceptionUserDataTypes">{@code exceptionUserDataTypes}</a>.
- *
  * <tr><td>severity</td><td>String<br>Integer</td>
  * <td>MBeanNotificationInfo</td>
  *
--- a/src/share/classes/javax/management/DescriptorFields.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,137 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>Annotation that adds fields to a {@link Descriptor}.  This can be the
- * Descriptor for an MBean, or for an attribute, operation, or constructor
- * in an MBean, or for a parameter of an operation or constructor.</p>
- *
- * <p>Consider this Standard MBean interface, for example:</p>
- *
- * <pre>
- * public interface CacheControlMBean {
- *     <b>&#64;DescriptorFields("units=bytes")</b>
- *     public long getCacheSize();
- * }
- * </pre>
- *
- * <p>When a Standard MBean is made using this interface, the usual rules
- * mean that it will have an attribute called {@code CacheSize} of type
- * {@code long}.  The {@code DescriptorFields} annotation will ensure
- * that the {@link MBeanAttributeInfo} for this attribute will have a
- * {@code Descriptor} that has a field called {@code units} with
- * corresponding value {@code bytes}.</p>
- *
- * <p>Similarly, if the interface looks like this:</p>
- *
- * <pre>
- * public interface CacheControlMBean {
- *     <b>&#64;DescriptorFields({"units=bytes", "since=1.5"})</b>
- *     public long getCacheSize();
- * }
- * </pre>
- *
- * <p>then the resulting {@code Descriptor} will contain the following
- * fields:</p>
- *
- * <table border="2">
- * <tr><th>Name</th><th>Value</th></tr>
- * <tr><td>units</td><td>"bytes"</td></tr>
- * <tr><td>since</td><td>"1.5"</td></tr>
- * </table>
- *
- * <p>The {@code @DescriptorFields} annotation can be applied to:</p>
- *
- * <ul>
- * <li>a Standard MBean or MXBean interface;
- * <li>a method in such an interface;
- * <li>a parameter of a method in a Standard MBean or MXBean interface
- * when that method is an operation (not a getter or setter for an attribute);
- * <li>a public constructor in the class that implements a Standard MBean
- * or MXBean;
- * <li>a parameter in such a constructor.
- * </ul>
- *
- * <p>Other uses of the annotation will either fail to compile or be
- * ignored.</p>
- *
- * <p>Interface annotations are checked only on the exact interface
- * that defines the management interface of a Standard MBean or an
- * MXBean, not on its parent interfaces.  Method annotations are
- * checked only in the most specific interface in which the method
- * appears; in other words, if a child interface overrides a method
- * from a parent interface, only {@code @DescriptorFields} annotations in
- * the method in the child interface are considered.
- *
- * <p>The Descriptor fields contributed in this way must be consistent
- * with each other and with any fields contributed by {@link
- * DescriptorKey &#64;DescriptorKey} annotations.  That is, two
- * different annotations, or two members of the same annotation, must
- * not define a different value for the same Descriptor field.  Fields
- * from annotations on a getter method must also be consistent with
- * fields from annotations on the corresponding setter method.</p>
- *
- * <p>The Descriptor resulting from these annotations will be merged
- * with any Descriptor fields provided by the implementation, such as
- * the <a href="Descriptor.html#immutableInfo">{@code
- * immutableInfo}</a> field for an MBean.  The fields from the annotations
- * must be consistent with these fields provided by the implementation.</p>
- *
- * <h4>{@literal @DescriptorFields and @DescriptorKey}</h4>
- *
- * <p>The {@link DescriptorKey @DescriptorKey} annotation provides
- * another way to use annotations to define Descriptor fields.
- * <code>&#64;DescriptorKey</code> requires more work but is also more
- * robust, because there is less risk of mistakes such as misspelling
- * the name of the field or giving an invalid value.
- * <code>&#64;DescriptorFields</code> is more convenient but includes
- * those risks.  <code>&#64;DescriptorFields</code> is more
- * appropriate for occasional use, but for a Descriptor field that you
- * add in many places, you should consider a purpose-built annotation
- * using <code>&#64;DescriptorKey</code>.
- *
- * @since 1.7
- */
-@Documented
-@Inherited  // for @MBean and @MXBean classes
-@Target({ElementType.CONSTRUCTOR, ElementType.METHOD,
-         ElementType.PARAMETER, ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface DescriptorFields {
-    /**
-     * <p>The descriptor fields.  Each element of the string looks like
-     * {@code "name=value"}.</p>
-     */
-    public String[] value();
-}
--- a/src/share/classes/javax/management/DescriptorKey.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/DescriptorKey.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,11 +33,6 @@
  * an MBean, or for an attribute, operation, or constructor in an
  * MBean, or for a parameter of an operation or constructor.</p>
  *
- * <p>(The {@link DescriptorFields @DescriptorFields} annotation
- * provides another way to add fields to a {@code Descriptor}.  See
- * the documentation for that annotation for a comparison of the
- * two possibilities.)</p>
- *
  * <p>Consider this annotation for example:</p>
  *
  * <pre>
@@ -130,13 +125,12 @@
  * the method in the child interface are considered.
  *
  * <p>The Descriptor fields contributed in this way by different
- * annotations on the same program element must be consistent with
- * each other and with any fields contributed by a {@link
- * DescriptorFields &#64;DescriptorFields} annotation.  That is, two
- * different annotations, or two members of the same annotation, must
- * not define a different value for the same Descriptor field.  Fields
- * from annotations on a getter method must also be consistent with
- * fields from annotations on the corresponding setter method.</p>
+ * annotations on the same program element must be consistent.  That
+ * is, two different annotations, or two members of the same
+ * annotation, must not define a different value for the same
+ * Descriptor field.  Fields from annotations on a getter method must
+ * also be consistent with fields from annotations on the
+ * corresponding setter method.</p>
  *
  * <p>The Descriptor resulting from these annotations will be merged
  * with any Descriptor fields provided by the implementation, such as
@@ -175,36 +169,4 @@
 @Target(ElementType.METHOD)
 public @interface DescriptorKey {
     String value();
-
-    /**
-     * <p>Do not include this field in the Descriptor if the annotation
-     * element has its default value.  For example, suppose {@code @Units} is
-     * defined like this:</p>
-     *
-     * <pre>
-     * &#64;Documented
-     * &#64;Target(ElementType.METHOD)
-     * &#64;Retention(RetentionPolicy.RUNTIME)
-     * public &#64;interface Units {
-     *     &#64;DescriptorKey("units")
-     *     String value();
-     *
-     *     <b>&#64;DescriptorKey(value = "descriptionResourceKey",
-     *                    omitIfDefault = true)</b>
-     *     String resourceKey() default "";
-     *
-     *     <b>&#64;DescriptorKey(value = "descriptionResourceBundleBaseName",
-     *                    omitIfDefault = true)</b>
-     *     String resourceBundleBaseName() default "";
-     * }
-     * </pre>
-     *
-     * <p>Then consider a usage such as {@code @Units("bytes")} or
-     * {@code @Units(value = "bytes", resourceKey = "")}, where the
-     * {@code resourceKey} and {@code resourceBundleBaseNames} elements
-     * have their default values.  In this case the Descriptor resulting
-     * from these annotations will not include a {@code descriptionResourceKey}
-     * or {@code descriptionResourceBundleBaseName} field.</p>
-     */
-    boolean omitIfDefault() default false;
 }
--- a/src/share/classes/javax/management/DynamicWrapperMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright 2005-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 javax.management;
-
-/**
- * <p>An MBean can implement this interface to affect how the MBeanServer's
- * {@link MBeanServer#getClassLoaderFor getClassLoaderFor} and
- * {@link MBeanServer#isInstanceOf isInstanceOf} methods behave.
- * If these methods should refer to a wrapped object rather than the
- * MBean object itself, then the {@link #getWrappedObject} method should
- * return that wrapped object.</p>
- *
- * @see MBeanServer#getClassLoaderFor
- * @see MBeanServer#isInstanceOf
- */
-public interface DynamicWrapperMBean extends DynamicMBean {
-    /**
-     * <p>The resource corresponding to this MBean.  This is the object whose
-     * class name should be reflected by the MBean's
-     * {@link MBeanServer#getMBeanInfo getMBeanInfo()}.<!--
-     * -->{@link MBeanInfo#getClassName getClassName()} for example.  For a "plain"
-     * DynamicMBean it will be "this".  For an MBean that wraps another
-     * object, in the manner of {@link javax.management.StandardMBean}, it will be the
-     * wrapped object.</p>
-     *
-     * @return The resource corresponding to this MBean.
-     */
-    public Object getWrappedObject();
-
-    /**
-     * <p>The {@code ClassLoader} for this MBean, which can be used to
-     * retrieve resources associated with the MBean for example.  Usually,
-     * it will be
-     * {@link #getWrappedObject()}.{@code getClass().getClassLoader()}.
-     *
-     * @return The {@code ClassLoader} for this MBean.
-     */
-    public ClassLoader getWrappedClassLoader();
-}
--- a/src/share/classes/javax/management/GenericMBeanException.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,276 +0,0 @@
-/*
- * 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 javax.management;
-
-import javax.management.openmbean.CompositeData;
-
-/**
- * <p>A customizable exception that has an optional error code string and
- * payload.  By using this exception in an MBean, you can avoid requiring
- * clients of the MBean to have custom exception classes.</p>
- *
- * <p>An instance of this class has an optional {@linkplain #getErrorCode()
- * error code}, and an optional {@linkplain #getUserData() payload} known as
- * {@code userData}.  This allows you to distinguish between different
- * sorts of exception while still using this class for all of them.</p>
- *
- * <p>To produce a suitable {@code userData}, it is often simplest to use
- * the MXBean framework.  For example, suppose you want to convey a severity
- * and a subsystem with your exception, which are respectively an int and a
- * String.  You could define a class like this:</p>
- *
- * <pre>
- * public class ExceptionDetails {
- *     private final int severity;
- *     private final String subsystem;
- *
- *     {@link java.beans.ConstructorProperties &#64;ConstructorProperties}(<!--
- * -->{"severity", "subsystem"})
- *     public ExceptionDetails(int severity, String subsystem) {
- *         this.severity = severity;
- *         this.subsystem = subsystem;
- *     }
- *
- *     public int getSeverity() {
- *         return severity;
- *     }
- *
- *     public String getSubsystem() {
- *         return subsystem;
- *     }
- * }
- * </pre>
- *
- * <p>Then you can get the MXBean framework to transform {@code ExceptionDetails}
- * into {@link CompositeData} like this:</p>
- *
- * <pre>
- * static final <!--
- * -->{@link javax.management.openmbean.MXBeanMapping MXBeanMapping} <!--
- * -->exceptionDetailsMapping = <!--
- * -->{@link javax.management.openmbean.MXBeanMappingFactory#DEFAULT
- *     MXBeanMappingFactory.DEFAULT}.mappingForType(
- *         ExceptionDetails.class, MXBeanMappingFactory.DEFAULT);
- *
- * public static GenericMBeanException newGenericMBeanException(
- *         String message, String errorCode, int severity, String subsystem) {
- *     ExceptionDetails details = new ExceptionDetails(severity, subsystem);
- *     CompositeData userData = (CompositeData)
- *             exceptionDetailsMapping.toOpenValue(details);
- *     return new GenericMBeanException(
- *             message, errorCode, userData, (Throwable) null);
- * }
- *
- * ...
- *     throw newGenericMBeanException(message, errorCode, 25, "foosystem");
- * </pre>
- *
- * <p>A client that knows the {@code ExceptionDetails} class can convert
- * back from the {@code userData} of a {@code GenericMBeanException}
- * that was generated as above:</p>
- *
- * <pre>
- * ...
- *     try {
- *         mbeanProxy.foo();
- *     } catch (GenericMBeanException e) {
- *         CompositeData userData = e.getUserData();
- *         ExceptionDetails details = (ExceptionDetails)
- *                 exceptionDetailsMapping.fromOpenValue(userData);
- *         System.out.println("Exception Severity: " + details.getSeverity());
- *     }
- * ...
- * </pre>
- *
- * <p>The Descriptor field <a href="Descriptor.html#exceptionErrorCodes"><!--
- * -->exceptionErrorCodes</a> can be used to specify in the
- * {@link MBeanOperationInfo} for an operation what the possible
- * {@linkplain #getErrorCode() error codes} are when that operation throws
- * {@code GenericMBeanException}.  It can also be used in an {@link
- * MBeanConstructorInfo} or {@link MBeanAttributeInfo} to specify what the
- * possible error codes are for {@code GenericMBeanException} when invoking
- * that constructor or getting that attribute, respectively.  The field
- * <a href="Descriptor.html#setExceptionErrorCodes"><!--
- * -->setExceptionErrorCodes</a> can be used to specify what the possible
- * error codes are when setting an attribute.</p>
- *
- * <p>You may want to use the {@link DescriptorKey &#64;DescriptorKey} facility
- * to define annotations that allow you to specify the error codes.  If you
- * define...</p>
- *
- * <pre>
- * {@link java.lang.annotation.Documented &#64;Documented}
- * {@link java.lang.annotation.Target &#64;Target}(ElementType.METHOD)
- * {@link java.lang.annotation.Retention &#64;Retention}(RetentionPolicy.RUNTIME)
- * public &#64;interface ErrorCodes {
- *     &#64;DescriptorKey("exceptionErrorCodes")
- *     String[] value();
- * }
- * </pre>
- *
- * <p>...then you can write MBean interfaces like this...</p>
- *
- * <pre>
- * public interface FooMBean {  // or FooMXBean
- *     &#64;ErrorCodes({"com.example.bad", "com.example.worse"})
- *     public void foo() throws GenericMBeanException;
- * }
- * </pre>
- *
- * <p>The Descriptor field <a href="Descriptor.html#exceptionUserDataTypes"><!--
- * -->exceptionUserDataTypes</a> can be used to specify in the
- * {@link MBeanOperationInfo} for an operation what the possible types of
- * {@linkplain #getUserData() userData} are when that operation throws
- * {@code GenericMBeanException}.  It is an array of
- * {@link javax.management.openmbean.CompositeType CompositeType} values
- * describing the possible {@link CompositeData} formats.  This field can also be used
- * in an {@link MBeanConstructorInfo} or {@link MBeanAttributeInfo} to specify
- * the possible types of user data for {@code GenericMBeanException} when
- * invoking that constructor or getting that attribute, respectively.  The
- * field
- * <a href="Descriptor.html#setExceptionUserDataTypes">setExceptionUserDataTypes</a>
- * can be used to specify the possible types of user data for exceptions when
- * setting an attribute.  If a Descriptor has both {@code exceptionErrorCodes}
- * and {@code exceptionUserDataTypes} then the two arrays should be the
- * same size; each pair of corresponding elements describes one kind
- * of exception.  Similarly for {@code setExceptionErrorCodes} and {@code
- * setExceptionUserDataTypes}.
- *
- *
- * <h4>Serialization</h4>
- *
- * <p>For compatibility reasons, instances of this class are serialized as
- * instances of {@link MBeanException}.  Special logic in that class converts
- * them back to instances of this class at deserialization time.  If the
- * serialized object is deserialized in an earlier version of the JMX API
- * that does not include this class, then it will appear as just an {@code
- * MBeanException} and the error code or userData will not be available.</p>
- *
- * @since 1.7
- */
-public class GenericMBeanException extends MBeanException {
-    private static final long serialVersionUID = -1560202003985932823L;
-
-    /**
-     * <p>Constructs a new {@code GenericMBeanException} with the given
-     * detail message.  This constructor is
-     * equivalent to {@link #GenericMBeanException(String, String,
-     * CompositeData, Throwable) GenericMBeanException(message, "",
-     * null, null)}.</p>
-     *
-     * @param message the exception detail message.
-     */
-    public GenericMBeanException(String message) {
-        this(message, "", null, null);
-    }
-
-    /**
-     * <p>Constructs a new {@code GenericMBeanException} with the given
-     * detail message and cause.  This constructor is
-     * equivalent to {@link #GenericMBeanException(String, String,
-     * CompositeData, Throwable) GenericMBeanException(message, "",
-     * null, cause)}.</p>
-     *
-     * @param message the exception detail message.
-     * @param cause the cause of this exception.  Can be null.
-     */
-    public GenericMBeanException(String message, Throwable cause) {
-        this(message, "", null, cause);
-    }
-
-    /**
-     * <p>Constructs a new {@code GenericMBeanException} with the given
-     * detail message, error code, and user data.  This constructor is
-     * equivalent to {@link #GenericMBeanException(String, String,
-     * CompositeData, Throwable) GenericMBeanException(message, errorCode,
-     * userData, null)}.</p>
-     *
-     * @param message the exception detail message.
-     * @param errorCode the exception error code.  Specifying a null value
-     * is equivalent to specifying an empty string.  It is recommended to use
-     * the same reverse domain name convention as package names, for example
-     * "com.example.foo.UnexpectedFailure".  There is no requirement that the
-     * error code be a syntactically valid Java identifier.
-     * @param userData extra information about the exception.  Can be null.
-     */
-    public GenericMBeanException(
-            String message, String errorCode, CompositeData userData) {
-        this(message, errorCode, userData, null);
-    }
-
-    /**
-     * <p>Constructs a new {@code GenericMBeanException} with the given
-     * detail message, error code, user data, and cause.</p>
-     *
-     * @param message the exception detail message.
-     * @param errorCode the exception error code.  Specifying a null value
-     * is equivalent to specifying an empty string.  It is recommended to use
-     * the same reverse domain name convention as package names, for example
-     * "com.example.foo.UnexpectedFailure".  There is no requirement that the
-     * error code be a syntactically valid Java identifier.
-     * @param userData extra information about the exception.  Can be null.
-     * @param cause the cause of this exception.  Can be null.
-     */
-    public GenericMBeanException(
-            String message, String errorCode, CompositeData userData,
-            Throwable cause) {
-        super(message, (errorCode == null) ? "" : errorCode, userData, cause);
-    }
-
-    /**
-     * <p>Returns the error code of this exception.</p>
-     *
-     * @return the error code.  This value is never null.
-     */
-    public String getErrorCode() {
-        return errorCode;
-    }
-
-    /**
-     * <p>Returns the userData of this exception.</p>
-     *
-     * @return the userData.  Can be null.
-     */
-    public CompositeData getUserData() {
-        return userData;
-    }
-
-    /**
-     * <p>Instances of this class are serialized as instances of
-     * {@link MBeanException}.  {@code MBeanException} has private fields that can
-     * not be set by its public constructors.  They can only be set in objects
-     * returned by this method.  When an {@code MBeanException} instance is
-     * deserialized, if those fields are present then its {@code readResolve}
-     * method will substitute a {@code GenericMBeanException} equivalent to
-     * this one.</p>
-     */
-    Object writeReplace() {
-        MBeanException x = new MBeanException(
-                getMessage(), errorCode, userData, getCause());
-        x.setStackTrace(this.getStackTrace());
-        return x;
-    }
-}
--- a/src/share/classes/javax/management/Impact.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-/**
- * <p>Defines the impact of an MBean operation, in particular whether it
- * has an effect on the MBean or simply returns information.  This enum
- * is used in the {@link ManagedOperation @ManagedOperation} annotation.
- * Its {@link #getCode()} method can be used to get an {@code int} suitable
- * for use as the {@code impact} parameter in an {@link MBeanOperationInfo}
- * constructor.</p>
- */
-public enum Impact {
-    /**
-     * The operation is read-like: it returns information but does not change
-     * any state.
-     * @see MBeanOperationInfo#INFO
-     */
-    INFO(MBeanOperationInfo.INFO),
-
-    /**
-     * The operation is write-like: it has an effect but does not return
-     * any information from the MBean.
-     * @see MBeanOperationInfo#ACTION
-     */
-    ACTION(MBeanOperationInfo.ACTION),
-
-    /**
-     * The operation is both read-like and write-like: it has an effect,
-     * and it also returns information from the MBean.
-     * @see MBeanOperationInfo#ACTION_INFO
-     */
-    ACTION_INFO(MBeanOperationInfo.ACTION_INFO),
-
-    /**
-     * The impact of the operation is unknown or cannot be expressed
-     * using one of the other values.
-     * @see MBeanOperationInfo#UNKNOWN
-     */
-    UNKNOWN(MBeanOperationInfo.UNKNOWN);
-
-    private final int code;
-
-    /**
-     * An instance of this enumeration, with the corresponding {@code int}
-     * code used by the {@link MBeanOperationInfo} constructors.
-     *
-     * @param code the code used by the {@code MBeanOperationInfo} constructors.
-     */
-    Impact(int code) {
-        this.code = code;
-    }
-
-    /**
-     * The equivalent {@code int} code used by the {@link MBeanOperationInfo}
-     * constructors.
-     * @return the {@code int} code.
-     */
-    public int getCode() {
-        return code;
-    }
-
-    /**
-     * Return the {@code Impact} value corresponding to the given {@code int}
-     * code.  The {@code code} is the value that would be used in an
-     * {@code MBeanOperationInfo} constructor.
-     *
-     * @param code the {@code int} code.
-     *
-     * @return an {@code Impact} value {@code x} such that
-     * {@code code == x.}{@link #getCode()}, or {@code Impact.UNKNOWN}
-     * if there is no such value.
-     */
-    public static Impact forCode(int code) {
-        switch (code) {
-            case MBeanOperationInfo.ACTION: return ACTION;
-            case MBeanOperationInfo.INFO: return INFO;
-            case MBeanOperationInfo.ACTION_INFO: return ACTION_INFO;
-            default: return UNKNOWN;
-        }
-    }
-}
--- a/src/share/classes/javax/management/InstanceNotFoundException.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/InstanceNotFoundException.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-2003 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
@@ -51,16 +51,4 @@
     public InstanceNotFoundException(String message) {
         super(message);
     }
-
-    /**
-     * Constructor for the frequent case where the message is the ObjectName
-     * of the missing MBean.
-     *
-     * @param name the ObjectName of the missing MBean.
-     *
-     * @since 1.7
-     */
-    public InstanceNotFoundException(ObjectName name) {
-        this(String.valueOf(name));
-    }
 }
--- a/src/share/classes/javax/management/JMRuntimeException.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/JMRuntimeException.java	Wed Nov 25 11:08:25 2009 -0800
@@ -58,22 +58,6 @@
      * specification.  A later version may make it public.
      */
     JMRuntimeException(String message, Throwable cause) {
-        super(message);
-
-        /* Make a best effort to set the cause, but if we don't
-           succeed, too bad, you don't get that useful debugging
-           information.  We jump through hoops here so that we can
-           work on platforms prior to J2SE 1.4 where the
-           Throwable.initCause method was introduced.  If we change
-           the public interface of JMRuntimeException in a future
-           version we can add getCause() so we don't need to do this.  */
-        try {
-            java.lang.reflect.Method initCause =
-                Throwable.class.getMethod("initCause",
-                                          new Class<?>[] {Throwable.class});
-            initCause.invoke(this, new Object[] {cause});
-        } catch (Exception e) {
-            // OK: just means we won't have debugging info
-        }
+        super(message, cause);
     }
 }
--- a/src/share/classes/javax/management/JMX.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/JMX.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * 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
@@ -26,20 +26,8 @@
 package javax.management;
 
 import com.sun.jmx.mbeanserver.Introspector;
-import com.sun.jmx.mbeanserver.MBeanInjector;
-import com.sun.jmx.remote.util.ClassLogger;
-import java.beans.BeanInfo;
-import java.beans.PropertyDescriptor;
-import java.io.IOException;
-import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
-import java.util.Map;
-import java.util.TreeMap;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.openmbean.MXBeanMappingFactory;
 
 /**
  * Static methods from the JMX API.  There are no instances of this class.
@@ -60,27 +48,6 @@
      */
     public static final String DEFAULT_VALUE_FIELD = "defaultValue";
 
-   /**
-     * The name of the <a
-     * href="Descriptor.html#descriptionResourceBundleBaseName">{@code
-     * descriptionResourceBundleBaseName}</a> field.
-     */
-    public static final String DESCRIPTION_RESOURCE_BUNDLE_BASE_NAME_FIELD =
-            "descriptionResourceBundleBaseName";
-
-    /**
-     * The name of the <a href="Descriptor.html#descriptionResourceKey">{@code
-     * descriptionResourceKey}</a> field.
-     */
-    public static final String DESCRIPTION_RESOURCE_KEY_FIELD =
-            "descriptionResourceKey";
-
-    /**
-     * The name of the <a href="Descriptor.html#exceptions">{@code
-     * exceptions}</a> field.
-     */
-    public static final String EXCEPTIONS_FIELD = "exceptions";
-
     /**
      * The name of the <a href="Descriptor.html#immutableInfo">{@code
      * immutableInfo}</a> field.
@@ -100,12 +67,6 @@
     public static final String LEGAL_VALUES_FIELD = "legalValues";
 
     /**
-     * The name of the <a href="Descriptor.html#locale">{@code locale}</a>
-     * field.
-     */
-    public static final String LOCALE_FIELD = "locale";
-
-    /**
      * The name of the <a href="Descriptor.html#maxValue">{@code
      * maxValue}</a> field.
      */
@@ -124,14 +85,6 @@
     public static final String MXBEAN_FIELD = "mxbean";
 
     /**
-     * The name of the
-     * <a href="Descriptor.html#mxbeanMappingFactoryClass">{@code
-     * mxbeanMappingFactoryClass}</a> field.
-     */
-    public static final String MXBEAN_MAPPING_FACTORY_CLASS_FIELD =
-            "mxbeanMappingFactoryClass";
-
-    /**
      * The name of the <a href="Descriptor.html#openType">{@code
      * openType}</a> field.
      */
@@ -144,276 +97,6 @@
     public static final String ORIGINAL_TYPE_FIELD = "originalType";
 
     /**
-     * The name of the <a href="Descriptor.html#setExceptions">{@code
-     * setExceptions}</a> field.
-     */
-    public static final String SET_EXCEPTIONS_FIELD = "setExceptions";
-
-    /**
-     * The name of the <a href="Descriptor.html#objectNameTemplate">{@code
-     * objectNameTemplate}</a> field.
-     */
-    public static final String OBJECT_NAME_TEMPLATE = "objectNameTemplate";
-
-    /**
-     * <p>Options to apply to an MBean proxy or to an instance of {@link
-     * StandardMBean}.</p>
-     *
-     * <p>For example, to specify the "wrapped object visible" option for a
-     * {@code StandardMBean}, you might write this:</p>
-     *
-     * <pre>
-     * StandardMBean.Options opts = new StandardMBean.Options();
-     * opts.setWrappedObjectVisible(true);
-     * StandardMBean mbean = new StandardMBean(impl, intf, opts);
-     * </pre>
-     *
-     * @see javax.management.JMX.ProxyOptions
-     * @see javax.management.StandardMBean.Options
-     */
-    public static class MBeanOptions implements Serializable, Cloneable {
-        private static final long serialVersionUID = -6380842449318177843L;
-
-        static final MBeanOptions MXBEAN = new MBeanOptions();
-        static {
-            MXBEAN.setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-        }
-
-        private MXBeanMappingFactory mappingFactory;
-
-        /**
-         * <p>Construct an {@code MBeanOptions} object where all options have
-         * their default values.</p>
-         */
-        public MBeanOptions() {}
-
-        @Override
-        public MBeanOptions clone() {
-            try {
-                return (MBeanOptions) super.clone();
-            } catch (CloneNotSupportedException e) {
-                throw new AssertionError(e);
-            }
-        }
-
-        /**
-         * <p>True if this is an MXBean proxy or a StandardMBean instance
-         * that is an MXBean.  The default value is false.</p>
-         *
-         * <p>This method is equivalent to {@link #getMXBeanMappingFactory()
-         * this.getMXBeanMappingFactory()}{@code != null}.</p>
-         *
-         * @return true if this is an MXBean proxy or a StandardMBean instance
-         * that is an MXBean.
-         */
-        public boolean isMXBean() {
-            return (this.mappingFactory != null);
-        }
-
-        /**
-         * <p>The mappings between Java types and Open Types to be used in
-         * an MXBean proxy or a StandardMBean instance that is an MXBean,
-         * or null if this instance is not for an MXBean.
-         * The default value is null.</p>
-         *
-         * @return the mappings to be used in this proxy or StandardMBean,
-         * or null if this instance is not for an MXBean.
-         */
-        public MXBeanMappingFactory getMXBeanMappingFactory() {
-            return mappingFactory;
-        }
-
-        /**
-         * <p>Set the {@link #getMXBeanMappingFactory() MXBeanMappingFactory} to
-         * the given value.  The value should be null if this instance is not
-         * for an MXBean.  If this instance is for an MXBean, the value should
-         * usually be either a custom mapping factory, or
-         * {@link MXBeanMappingFactory#forInterface
-         * MXBeanMappingFactory.forInterface}{@code (mxbeanInterface)}
-         * which signifies
-         * that the {@linkplain MXBeanMappingFactory#DEFAULT default} mapping
-         * factory should be used unless an {@code @}{@link
-         * javax.management.openmbean.MXBeanMappingFactoryClass
-         * MXBeanMappingFactoryClass} annotation on {@code mxbeanInterface}
-         * specifies otherwise.</p>
-         *
-         * <p>Examples:</p>
-         * <pre>
-         * MBeanOptions opts = new MBeanOptions();
-         * opts.setMXBeanMappingFactory(myMappingFactory);
-         * MyMXBean proxy = JMX.newMBeanProxy(
-         *         mbeanServerConnection, objectName, MyMXBean.class, opts);
-         *
-         * // ...or...
-         *
-         * MBeanOptions opts = new MBeanOptions();
-         * MXBeanMappingFactory defaultFactoryForMyMXBean =
-         *         MXBeanMappingFactory.forInterface(MyMXBean.class);
-         * opts.setMXBeanMappingFactory(defaultFactoryForMyMXBean);
-         * MyMXBean proxy = JMX.newMBeanProxy(
-         *         mbeanServerConnection, objectName, MyMXBean.class, opts);
-         * </pre>
-         *
-         * @param f the new value.  If null, this instance is not for an
-         * MXBean.
-         */
-        public void setMXBeanMappingFactory(MXBeanMappingFactory f) {
-            this.mappingFactory = f;
-        }
-
-        /* To maximise object sharing, classes in this package can replace
-         * a private MBeanOptions with no MXBeanMappingFactory with one
-         * of these shared instances.  But they must be EXTREMELY careful
-         * never to give out the shared instances to user code, which could
-         * modify them.
-         */
-        private static final MBeanOptions[] CANONICALS = {
-            new MBeanOptions(), MXBEAN,
-        };
-        // Overridden in local subclasses:
-        MBeanOptions[] canonicals() {
-            return CANONICALS;
-        }
-
-        // This is only used by the logic for canonical instances.
-        // Overridden in local subclasses:
-        boolean same(MBeanOptions opt) {
-            return (opt.mappingFactory == mappingFactory);
-        }
-
-        final MBeanOptions canonical() {
-            for (MBeanOptions opt : canonicals()) {
-                if (opt.getClass() == this.getClass() && same(opt))
-                    return opt;
-            }
-            return this;
-        }
-
-        final MBeanOptions uncanonical() {
-            for (MBeanOptions opt : canonicals()) {
-                if (this == opt)
-                    return clone();
-            }
-            return this;
-        }
-
-        private Map<String, Object> toMap() {
-            Map<String, Object> map = new TreeMap<String, Object>();
-            try {
-                BeanInfo bi = java.beans.Introspector.getBeanInfo(getClass());
-                PropertyDescriptor[] pds = bi.getPropertyDescriptors();
-                for (PropertyDescriptor pd : pds) {
-                    String name = pd.getName();
-                    if (name.equals("class"))
-                        continue;
-                    Method get = pd.getReadMethod();
-                    if (get != null)
-                        map.put(name, get.invoke(this));
-                }
-            } catch (Exception e) {
-                Throwable t = e;
-                if (t instanceof InvocationTargetException)
-                    t = t.getCause();
-                map.put("Exception", t);
-            }
-            return map;
-        }
-
-        @Override
-        public String toString() {
-            return getClass().getSimpleName() + toMap();
-            // For example "MBeanOptions{MXBean=true, <etc>}".
-        }
-
-        /**
-         * <p>Indicates whether some other object is "equal to" this one. The
-         * result is true if and only if the other object is also an instance
-         * of MBeanOptions or a subclass, and has the same properties with
-         * the same values.</p>
-         * @return {@inheritDoc}
-         */
-        @Override
-        public boolean equals(Object obj) {
-            if (obj == this)
-                return true;
-            if (obj == null || obj.getClass() != this.getClass())
-                return false;
-            return toMap().equals(((MBeanOptions) obj).toMap());
-        }
-
-        @Override
-        public int hashCode() {
-            return toMap().hashCode();
-        }
-    }
-
-    /**
-     * <p>Options to apply to an MBean proxy.</p>
-     *
-     * @see #newMBeanProxy
-     */
-    public static class ProxyOptions extends MBeanOptions {
-        private static final long serialVersionUID = 7238804866098386559L;
-
-        private boolean notificationEmitter;
-
-        /**
-         * <p>Construct a {@code ProxyOptions} object where all options have
-         * their default values.</p>
-         */
-        public ProxyOptions() {}
-
-        @Override
-        public ProxyOptions clone() {
-            return (ProxyOptions) super.clone();
-        }
-
-        /**
-         * <p>Defines whether the returned proxy should
-         * implement {@link NotificationEmitter}.  The default value is false.</p>
-         *
-         * @return true if this proxy will be a NotificationEmitter.
-         *
-         * @see JMX#newMBeanProxy(MBeanServerConnection, ObjectName, Class,
-         * MBeanOptions)
-         */
-        public boolean isNotificationEmitter() {
-            return this.notificationEmitter;
-        }
-
-        /**
-         * <p>Set the {@link #isNotificationEmitter NotificationEmitter} option to
-         * the given value.</p>
-         * @param emitter the new value.
-         */
-        public void setNotificationEmitter(boolean emitter) {
-            this.notificationEmitter = emitter;
-        }
-
-        // Canonical objects for each of (MXBean,!MXBean) x (Emitter,!Emitter)
-        private static final ProxyOptions[] CANONICALS = {
-            new ProxyOptions(), new ProxyOptions(),
-            new ProxyOptions(), new ProxyOptions(),
-        };
-        static {
-            CANONICALS[1].setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-            CANONICALS[2].setNotificationEmitter(true);
-            CANONICALS[3].setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-            CANONICALS[3].setNotificationEmitter(true);
-        }
-        @Override
-        MBeanOptions[] canonicals() {
-            return CANONICALS;
-        }
-
-        @Override
-        boolean same(MBeanOptions opt) {
-            return (super.same(opt) && opt instanceof ProxyOptions &&
-                    ((ProxyOptions) opt).notificationEmitter == notificationEmitter);
-        }
-    }
-
-    /**
      * <p>Make a proxy for a Standard MBean in a local or remote
      * MBean Server.</p>
      *
@@ -501,12 +184,6 @@
      * likewise for the other methods of {@link
      * NotificationBroadcaster} and {@link NotificationEmitter}.</p>
      *
-     * <p>This method is equivalent to {@link
-     * #newMBeanProxy(MBeanServerConnection, ObjectName, Class, JMX.MBeanOptions)
-     * newMBeanProxy(connection, objectName, interfaceClass, opts)}, where
-     * {@code opts} is a {@link JMX.ProxyOptions} representing the
-     * {@code notificationEmitter} parameter.</p>
-     *
      * @param connection the MBean server to forward to.
      * @param objectName the name of the MBean within
      * {@code connection} to forward to.
@@ -515,18 +192,22 @@
      * @param notificationEmitter make the returned proxy
      * implement {@link NotificationEmitter} by forwarding its methods
      * via {@code connection}.
+     *
      * @param <T> allows the compiler to know that if the {@code
      * interfaceClass} parameter is {@code MyMBean.class}, for
      * example, then the return type is {@code MyMBean}.
+     *
      * @return the new proxy instance.
      */
     public static <T> T newMBeanProxy(MBeanServerConnection connection,
                                       ObjectName objectName,
                                       Class<T> interfaceClass,
                                       boolean notificationEmitter) {
-        ProxyOptions opts = new ProxyOptions();
-        opts.setNotificationEmitter(notificationEmitter);
-        return newMBeanProxy(connection, objectName, interfaceClass, opts);
+        return MBeanServerInvocationHandler.newProxyInstance(
+                connection,
+                objectName,
+                interfaceClass,
+                notificationEmitter);
     }
 
     /**
@@ -599,6 +280,10 @@
      *
      * </ul>
      *
+     * <p>The object returned by this method is a
+     * {@link Proxy} whose {@code InvocationHandler} is an
+     * {@link MBeanServerInvocationHandler}.</p>
+     *
      * <p>This method is equivalent to {@link
      * #newMXBeanProxy(MBeanServerConnection, ObjectName, Class,
      * boolean) newMXBeanProxy(connection, objectName, interfaceClass,
@@ -641,17 +326,6 @@
      * likewise for the other methods of {@link
      * NotificationBroadcaster} and {@link NotificationEmitter}.</p>
      *
-     * <p>This method is equivalent to {@link
-     * #newMBeanProxy(MBeanServerConnection, ObjectName, Class, JMX.MBeanOptions)
-     * newMBeanProxy(connection, objectName, interfaceClass, opts)}, where
-     * {@code opts} is a {@link JMX.ProxyOptions} where the {@link
-     * JMX.ProxyOptions#getMXBeanMappingFactory() MXBeanMappingFactory}
-     * property is
-     * {@link MXBeanMappingFactory#forInterface(Class)
-     * MXBeanMappingFactory.forInterface(interfaceClass)} and the {@link
-     * JMX.ProxyOptions#isNotificationEmitter() notificationEmitter} property
-     * is equal to the {@code notificationEmitter} parameter.</p>
-     *
      * @param connection the MBean server to forward to.
      * @param objectName the name of the MBean within
      * {@code connection} to forward to.
@@ -660,130 +334,26 @@
      * @param notificationEmitter make the returned proxy
      * implement {@link NotificationEmitter} by forwarding its methods
      * via {@code connection}.
+     *
      * @param <T> allows the compiler to know that if the {@code
      * interfaceClass} parameter is {@code MyMXBean.class}, for
      * example, then the return type is {@code MyMXBean}.
+     *
      * @return the new proxy instance.
      */
     public static <T> T newMXBeanProxy(MBeanServerConnection connection,
                                        ObjectName objectName,
                                        Class<T> interfaceClass,
                                        boolean notificationEmitter) {
-        ProxyOptions opts = new ProxyOptions();
-        MXBeanMappingFactory f = MXBeanMappingFactory.forInterface(interfaceClass);
-        opts.setMXBeanMappingFactory(f);
-        opts.setNotificationEmitter(notificationEmitter);
-        return newMBeanProxy(connection, objectName, interfaceClass, opts);
-    }
-
-    /**
-     * <p>Make a proxy for a Standard MBean or MXBean in a local or remote MBean
-     * Server that may also support the methods of {@link
-     * NotificationEmitter} and (for an MXBean) that may define custom MXBean
-     * type mappings.</p>
-     *
-     * <p>This method behaves the same as
-     * {@link #newMBeanProxy(MBeanServerConnection, ObjectName, Class)} or
-     * {@link #newMXBeanProxy(MBeanServerConnection, ObjectName, Class)},
-     * according as {@code opts.isMXBean()} is respectively false or true; but
-     * with the following changes based on {@code opts}.</p>
-     *
-     * <ul>
-     *     <li>If {@code opts.isNotificationEmitter()} is {@code
-     *         true}, then the MBean is assumed to be a {@link
-     *         NotificationBroadcaster} or {@link NotificationEmitter} and the
-     *         returned proxy will implement {@link NotificationEmitter} as
-     *         well as {@code interfaceClass}.  A call to {@link
-     *         NotificationBroadcaster#addNotificationListener} on the proxy
-     *         will result in a call to {@link
-     *         MBeanServerConnection#addNotificationListener(ObjectName,
-     *         NotificationListener, NotificationFilter, Object)}, and
-     *         likewise for the other methods of {@link
-     *     NotificationBroadcaster} and {@link NotificationEmitter}.</li>
-     *
-     *     <li>If {@code opts.getMXBeanMappingFactory()} is not null,
-     *         then the mappings it defines will be applied to convert between
-     *     arbitrary Java types and Open Types.</li>
-     * </ul>
-     *
-     * <p>The object returned by this method is a
-     * {@link Proxy} whose {@code InvocationHandler} is an
-     * {@link MBeanServerInvocationHandler}.  This means that it is possible
-     * to retrieve the parameters that were used to produce the proxy.  If the
-     * proxy was produced as follows...</p>
-     *
-     * <pre>
-     * FooMBean proxy =
-     *     JMX.newMBeanProxy(connection, objectName, FooMBean.class, opts);
-     * </pre>
-     *
-     * <p>...then you can get the {@code MBeanServerInvocationHandler} like
-     * this...</p>
-     *
-     * <pre>
-     * MBeanServerInvocationHandler mbsih = (MBeanServerInvocationHandler)
-     *     {@link Proxy#getInvocationHandler(Object)
-     *            Proxy.getInvocationHandler}(proxy);
-     * </pre>
-     *
-     * <p>...and you can retrieve {@code connection}, {@code
-     * objectName}, and {@code opts} using the {@link
-     * MBeanServerInvocationHandler#getMBeanServerConnection()
-     * getMBeanServerConnection()}, {@link
-     * MBeanServerInvocationHandler#getObjectName() getObjectName()}, and
-     * {@link MBeanServerInvocationHandler#getMBeanOptions() getMBeanOptions()}
-     * methods on {@code mbsih}.  You can retrieve {@code FooMBean.class}
-     * using {@code proxy.getClass().}{@link
-     * Class#getInterfaces() getInterfaces()}.</p>
-     *
-     * @param connection the MBean server to forward to.
-     * @param objectName the name of the MBean within
-     * {@code connection} to forward to.
-     * @param interfaceClass the Standard MBean or MXBean interface,
-     * which will also be implemented by the returned proxy.
-     * @param opts the options to apply for this proxy.  Can be null,
-     * in which case default options are applied.
-     * @param <T> allows the compiler to know that if the {@code
-     * interfaceClass} parameter is {@code MyMXBean.class}, for
-     * example, then the return type is {@code MyMXBean}.
-     * @return the new proxy instance.
-     *
-     * @throws IllegalArgumentException if {@code interfaceClass} is not a
-     * valid MXBean interface.
-     */
-    public static <T> T newMBeanProxy(MBeanServerConnection connection,
-                                      ObjectName objectName,
-                                      Class<T> interfaceClass,
-                                      MBeanOptions opts) {
+        // Check interface for MXBean compliance
+        //
         try {
-            return newMBeanProxy2(connection, objectName, interfaceClass, opts);
+            Introspector.testComplianceMXBeanInterface(interfaceClass);
         } catch (NotCompliantMBeanException e) {
             throw new IllegalArgumentException(e);
         }
-    }
-
-    private static <T> T newMBeanProxy2(MBeanServerConnection connection,
-                                        ObjectName objectName,
-                                        Class<T> interfaceClass,
-                                        MBeanOptions opts)
-    throws NotCompliantMBeanException {
-
-        if (opts == null)
-            opts = new MBeanOptions();
-
-        boolean notificationEmitter = opts instanceof ProxyOptions &&
-                ((ProxyOptions) opts).isNotificationEmitter();
-
-        MXBeanMappingFactory mappingFactory = opts.getMXBeanMappingFactory();
-
-        if (mappingFactory != null) {
-            // Check interface for MXBean compliance
-            Introspector.testComplianceMXBeanInterface(interfaceClass,
-                    mappingFactory);
-        }
-
         InvocationHandler handler = new MBeanServerInvocationHandler(
-                connection, objectName, opts);
+                connection, objectName, true);
         final Class<?>[] interfaces;
         if (notificationEmitter) {
             interfaces =
@@ -822,109 +392,4 @@
         // exactly the string "MXBean" since that would mean there
         // was no package name, which is pretty unlikely in practice.
     }
-
-    /**
-     * <p>Test if an MBean can emit notifications.  An MBean can emit
-     * notifications if either it implements {@link NotificationBroadcaster}
-     * (perhaps through its child interface {@link NotificationEmitter}), or
-     * it uses <a href="MBeanRegistration.html#injection">resource
-     * injection</a> to obtain an instance of {@link SendNotification}
-     * through which it can send notifications.</p>
-     *
-     * @param mbean an MBean object.
-     * @return true if the given object is a valid MBean that can emit
-     * notifications; false if the object is a valid MBean but that
-     * cannot emit notifications.
-     * @throws NotCompliantMBeanException if the given object is not
-     * a valid MBean.
-     */
-    public static boolean isNotificationSource(Object mbean)
-            throws NotCompliantMBeanException {
-        for (int i = 0; i < 2; i++) {
-            if (mbean instanceof NotificationBroadcaster ||
-                    MBeanInjector.injectsSendNotification(mbean))
-                return true;
-            if (mbean instanceof DynamicWrapperMBean)
-                mbean = ((DynamicWrapperMBean) mbean).getWrappedObject();
-            else
-                break;
-        }
-        return false;
-    }
-
-    /**
-     * <p>Return the version of the JMX specification that a (possibly remote)
-     * MBean Server is using.  The JMX specification described in this
-     * documentation is version 2.0.  The earlier versions that might be
-     * reported by this method are 1.0, 1.1, 1.2, and 1.4.  (There is no 1.3.)
-     * All of these versions and all future versions can be compared using
-     * {@link String#compareTo(String)}.  So, for example, to tell if
-     * {@code mbsc} is running at least version 2.0 you can write:</p>
-     *
-     * <pre>
-     * String version = JMX.getSpecificationVersion(mbsc, null);
-     * boolean atLeast2dot0 = (version.compareTo("2.0") >= 0);
-     * </pre>
-     *
-     * <p>A remote MBean Server might be running an earlier version of the
-     * JMX API, and in that case <a href="package-summary.html#interop">certain
-     * features</a> might not be available in it.</p>
-     *
-     * <p>The version of the MBean Server {@code mbsc} is not necessarily
-     * the version of all namespaces within that MBean Server, for example
-     * if some of them use {@link javax.management.namespace.JMXRemoteNamespace
-     * JMXRemoteNamespace}.  To determine the version of the namespace
-     * that a particular MBean is in, give its name as the {@code mbeanName}
-     * parameter.</p>
-     *
-     * @param mbsc a connection to an MBean Server.
-     *
-     * @param mbeanName the name of an MBean within that MBean Server, or null.
-     * If non-null, the namespace of this name, as determined by
-     * {@link JMXNamespaces#getContainingNamespace
-     * JMXNamespaces.getContainingNamespace}, is the one whose specification
-     * version will be returned.
-     *
-     * @return the JMX specification version reported by that MBean Server.
-     *
-     * @throws IllegalArgumentException if {@code mbsc} is null, or if
-     * {@code mbeanName} includes a wildcard character ({@code *} or {@code ?})
-     * in its namespace.
-     *
-     * @throws IOException if the version cannot be obtained, either because
-     * there is a communication problem or because the remote MBean Server
-     * does not have the appropriate {@linkplain
-     * MBeanServerDelegateMBean#getSpecificationVersion() attribute}.
-     *
-     * @see <a href="package-summary.html#interop">Interoperability between
-     * versions of the JMX specification</a>
-     * @see MBeanServerDelegateMBean#getSpecificationVersion
-     */
-    public static String getSpecificationVersion(
-            MBeanServerConnection mbsc, ObjectName mbeanName)
-            throws IOException {
-        if (mbsc == null)
-            throw new IllegalArgumentException("Null MBeanServerConnection");
-
-        String namespace;
-        if (mbeanName == null)
-            namespace = "";
-        else
-            namespace = JMXNamespaces.getContainingNamespace(mbeanName);
-        if (namespace.contains("*") || namespace.contains("?")) {
-            throw new IllegalArgumentException(
-                    "ObjectName contains namespace wildcard: " + mbeanName);
-        }
-
-        try {
-            if (namespace.length() > 0)
-                mbsc = JMXNamespaces.narrowToNamespace(mbsc, namespace);
-            return (String) mbsc.getAttribute(
-                    MBeanServerDelegate.DELEGATE_NAME, "SpecificationVersion");
-        } catch (IOException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new IOException(e);
-        }
-    }
 }
--- a/src/share/classes/javax/management/MBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>Indicates that the annotated class is a Standard MBean.  A Standard
- * MBean class can be defined as in this example:</p>
- *
- * <pre>
- * {@code @MBean}
- * public class Configuration {
- *     {@link ManagedAttribute @ManagedAttribute}
- *     public int getCacheSize() {...}
- *     {@code @ManagedAttribute}
- *     public void setCacheSize(int size);
- *
- *     {@code @ManagedAttribute}
- *     public long getLastChangedTime();
- *
- *     {@link ManagedOperation @ManagedOperation}
- *     public void save();
- * }
- * </pre>
- *
- * <p>The class must be public.  Public methods within the class can be
- * annotated with {@code @ManagedOperation} to indicate that they are
- * MBean operations.  Public getter and setter methods within the class
- * can be annotated with {@code @ManagedAttribute} to indicate that they define
- * MBean attributes.</p>
- *
- * <p>If the MBean is to be an MXBean rather than a Standard MBean, then
- * the {@link MXBean @MXBean} annotation must be used instead of
- * {@code @MBean}.</p>
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Inherited
-public @interface MBean {
-}
--- a/src/share/classes/javax/management/MBeanAttributeInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanAttributeInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -186,10 +186,8 @@
              (getter != null),
              (setter != null),
              isIs(getter),
-             ImmutableDescriptor.union(Introspector.
-             descriptorForElement(getter, false),
-                                   Introspector.descriptorForElement(setter,
-                                   true)));
+             ImmutableDescriptor.union(Introspector.descriptorForElement(getter),
+                                   Introspector.descriptorForElement(setter)));
     }
 
     /**
--- a/src/share/classes/javax/management/MBeanConstructorInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanConstructorInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -67,7 +67,7 @@
     public MBeanConstructorInfo(String description, Constructor<?> constructor) {
         this(constructor.getName(), description,
              constructorSignature(constructor),
-             Introspector.descriptorForElement(constructor, false));
+             Introspector.descriptorForElement(constructor));
     }
 
     /**
--- a/src/share/classes/javax/management/MBeanException.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanException.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,8 +25,6 @@
 
 package javax.management;
 
-import javax.management.openmbean.CompositeData;
-
 
 /**
  * Represents "user defined" exceptions thrown by MBean methods
@@ -43,26 +41,6 @@
     private static final long serialVersionUID = 4066342430588744142L;
 
     /**
-     * @serial This field is null for instances of this class that were
-     * produced by its public constructors.  It is non-null for instances
-     * of this class that represent serialized instances of {@link
-     * GenericMBeanException}.
-     *
-     * @see GenericMBeanException#getErrorCode()
-     */
-    final String errorCode;
-
-    /**
-     * @serial This field is null for instances of this class that were
-     * produced by its public constructors.  It may be non-null for instances
-     * of this class that represent serialized instances of {@link
-     * GenericMBeanException}.
-     *
-     * @see GenericMBeanException#getUserData()
-     */
-    final CompositeData userData;
-
-    /**
      * @serial Encapsulated {@link Exception}
      */
     private java.lang.Exception exception ;
@@ -73,8 +51,9 @@
      *
      * @param e the wrapped exception.
      */
-    public MBeanException(Exception e) {
-        this(null, null, null, e);
+    public MBeanException(java.lang.Exception e) {
+        super() ;
+        exception = e ;
     }
 
     /**
@@ -84,19 +63,11 @@
      * @param e the wrapped exception.
      * @param message the detail message.
      */
-    public MBeanException(Exception e, String message) {
-        this(message, null, null, e);
+    public MBeanException(java.lang.Exception e, String message) {
+        super(message) ;
+        exception = e ;
     }
 
-    MBeanException(
-            String message, String errorCode, CompositeData userData, Throwable cause) {
-        super(message);
-        initCause(cause);
-        if (cause instanceof Exception)
-            this.exception = (Exception) cause;
-        this.errorCode = errorCode;
-        this.userData = userData;
-    }
 
     /**
      * Return the actual {@link Exception} thrown.
@@ -108,24 +79,11 @@
     }
 
     /**
-     * This method is invoked when deserializing instances of this class.
-     * If the {@code errorCode} field of the deserialized instance is not
-     * null, this method returns an instance of {@link GenericMBeanException}
-     * instead.  Otherwise it returns {@code this}.
-     * @return {@code this}, or a {@code GenericMBeanException}.
+     * Return the actual {@link Exception} thrown.
+     *
+     * @return the wrapped exception.
      */
-    Object readResolve() {
-        if (errorCode == null) {
-            // serial compatibility: earlier versions did not set
-            // Throwable.cause because they overrode getCause().
-            if (getCause() == null && exception != null)
-                initCause(exception);
-            return this;
-        } else {
-            Throwable t = new GenericMBeanException(
-                    getMessage(), errorCode, userData, getCause());
-            t.setStackTrace(this.getStackTrace());
-            return t;
-        }
+    public Throwable getCause() {
+        return exception;
     }
 }
--- a/src/share/classes/javax/management/MBeanInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,7 +25,6 @@
 
 package javax.management;
 
-import com.sun.jmx.mbeanserver.Util;
 import java.io.IOException;
 import java.io.StreamCorruptedException;
 import java.io.Serializable;
@@ -38,12 +37,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 import static javax.management.ImmutableDescriptor.nonNullDescriptor;
 
 /**
@@ -80,50 +73,27 @@
  * constructors in that object;
  *
  * <li>{@link #getAttributes()} returns the list of all attributes
- * whose existence is deduced as follows:
- * <ul>
- * <li>if the Standard MBean is defined with an MBean interface,
- * from <code>get<i>Name</i></code>, <code>is<i>Name</i></code>, or
- * <code>set<i>Name</i></code> methods that conform to the conventions
+ * whose existence is deduced from the presence in the MBean interface
+ * of a <code>get<i>Name</i></code>, <code>is<i>Name</i></code>, or
+ * <code>set<i>Name</i></code> method that conforms to the conventions
  * for Standard MBeans;
- * <li>if the Standard MBean is defined with the {@link MBean &#64;MBean} or
- * {@link MXBean &#64;MXBean} annotation on a class, from methods with the
- * {@link ManagedAttribute &#64;ManagedAttribute} annotation;
- * </ul>
  *
- * <li>{@link #getOperations()} returns the list of all operations whose
- * existence is deduced as follows:
- * <ul>
- * <li>if the Standard MBean is defined with an MBean interface, from methods in
+ * <li>{@link #getOperations()} returns the list of all methods in
  * the MBean interface that do not represent attributes;
- * <li>if the Standard MBean is defined with the {@link MBean &#64;MBean} or
- * {@link MXBean &#64;MXBean} annotation on a class, from methods with the
- * {@link ManagedOperation &#64;ManagedOperation} annotation;
- * </ul>
  *
- * <li>{@link #getNotifications()} returns:
- * <ul>
- * <li>if the MBean implements the {@link NotificationBroadcaster} interface,
- * the result of calling {@link
+ * <li>{@link #getNotifications()} returns an empty array if the MBean
+ * does not implement the {@link NotificationBroadcaster} interface,
+ * otherwise the result of calling {@link
  * NotificationBroadcaster#getNotificationInfo()} on it;
- * <li>otherwise, if there is a {@link NotificationInfo &#64;NotificationInfo}
- * or {@link NotificationInfos &#64;NotificationInfos} annotation on the
- * MBean interface or <code>&#64;MBean</code> or <code>&#64;MXBean</code>
- * class, the array implied by those annotations;
- * <li>otherwise an empty array;
- * </ul>
  *
  * <li>{@link #getDescriptor()} returns a descriptor containing the contents
  * of any descriptor annotations in the MBean interface (see
- * {@link DescriptorFields &#64;DescriptorFields} and
  * {@link DescriptorKey &#64;DescriptorKey}).
  *
  * </ul>
  *
  * <p>The description returned by {@link #getDescription()} and the
- * descriptions of the contained attributes and operations are determined
- * by the corresponding {@link Description} annotations if any;
- * otherwise their contents are not specified.</p>
+ * descriptions of the contained attributes and operations are not specified.</p>
  *
  * <p>The remaining details of the <code>MBeanInfo</code> for a
  * Standard MBean are not specified.  This includes the description of
@@ -758,377 +728,4 @@
             throw new StreamCorruptedException("Got unexpected byte.");
         }
     }
-
-    /**
-     * <p>Return an {@code MBeanInfo} object that is the same as this one
-     * except that its descriptions are localized in the given locale.
-     * This means the text returned by {@link MBeanInfo#getDescription}
-     * (the description of the MBean itself), and the text returned by the
-     * {@link MBeanFeatureInfo#getDescription getDescription()} method
-     * for every {@linkplain MBeanAttributeInfo attribute}, {@linkplain
-     * MBeanOperationInfo operation}, {@linkplain MBeanConstructorInfo
-     * constructor}, and {@linkplain MBeanNotificationInfo notification}
-     * contained in the {@code MBeanInfo}.</p>
-     *
-     * <p>Here is how the description {@code this.getDescription()} is
-     * localized.</p>
-     *
-     * <p>First, if the {@linkplain #getDescriptor() descriptor}
-     * of this {@code MBeanInfo} contains a field <code><a
-     * href="Descriptor.html#locale">"locale"</a></code>, and the value of
-     * the field is the same as {@code locale.toString()}, then this {@code
-     * MBeanInfo} is returned. Otherwise, localization proceeds as follows,
-     * and the {@code "locale"} field in the returned {@code MBeanInfo} will
-     * be {@code locale.toString()}.
-     *
-     * <p>A <em>{@code className}</em> is determined. If this
-     * {@code MBeanInfo} contains a descriptor with the field
-     * <a href="Descriptor.html#interfaceClassName">{@code
-     * "interfaceClassName"}</a>, then the value of that field is the
-     * {@code className}. Otherwise, it is {@link #getClassName()}.
-     * Everything before the last period (.) in the {@code className} is
-     * the <em>{@code package}</em>, and everything after is the <em>{@code
-     * simpleClassName}</em>. (If there is no period, then the {@code package}
-     * is empty and the {@code simpleClassName} is the same as the {@code
-     * className}.)</p>
-     *
-     * <p>A <em>{@code resourceKey}</em> is determined. If this {@code
-     * MBeanInfo} contains a {@linkplain MBeanInfo#getDescriptor() descriptor}
-     * with a field {@link JMX#DESCRIPTION_RESOURCE_KEY_FIELD
-     * "descriptionResourceKey"}, the value of the field is
-     * the {@code resourceKey}. Otherwise, the {@code resourceKey} is {@code
-     * simpleClassName + ".mbean"}.</p>
-     *
-     * <p>A <em>{@code resourceBundleBaseName}</em> is determined. If
-     * this {@code MBeanInfo} contains a descriptor with a field {@link
-     * JMX#DESCRIPTION_RESOURCE_BUNDLE_BASE_NAME_FIELD
-     * "descriptionResourceBundleBaseName"}, the value of the field
-     * is the {@code resourceBundleBaseName}. Otherwise, the {@code
-     * resourceBundleBaseName} is {@code package + ".MBeanDescriptions"}.
-     *
-     * <p>Then, a {@link java.util.ResourceBundle ResourceBundle} is
-     * determined, using<br> {@link java.util.ResourceBundle#getBundle(String,
-     * Locale, ClassLoader) ResourceBundle.getBundle(resourceBundleBaseName,
-     * locale, loader)}. If this succeeds, and if {@link
-     * java.util.ResourceBundle#getString(String) getString(resourceKey)}
-     * returns a string, then that string is the localized description.
-     * Otherwise, the original description is unchanged.</p>
-     *
-     * <p>A localized description for an {@code MBeanAttributeInfo} is
-     * obtained similarly. The default {@code resourceBundleBaseName}
-     * is the same as above. The default description and the
-     * descriptor fields {@code "descriptionResourceKey"} and {@code
-     * "descriptionResourceBundleBaseName"} come from the {@code
-     * MBeanAttributeInfo} rather than the {@code MBeanInfo}. If the
-     * attribute's {@linkplain MBeanFeatureInfo#getName() name} is {@code
-     * Foo} then its default {@code resourceKey} is {@code simpleClassName +
-     * ".attribute.Foo"}.</p>
-     *
-     * <p>Similar rules apply for operations, constructors, and notifications.
-     * If the name of the operation, constructor, or notification is {@code
-     * Foo} then the default {@code resourceKey} is respectively {@code
-     * simpleClassName + ".operation.Foo"}, {@code simpleClassName +
-     * ".constructor.Foo"}, or {@code simpleClassName + ".notification.Foo"}.
-     * If two operations or constructors have the same name (overloading) then
-     * they have the same default {@code resourceKey}; if different localized
-     * descriptions are needed then a non-default key must be supplied using
-     * {@code "descriptionResourceKey"}.</p>
-     *
-     * <p>Similar rules also apply for descriptions of parameters ({@link
-     * MBeanParameterInfo}). The default {@code resourceKey} for a parameter
-     * whose {@linkplain MBeanFeatureInfo#getName() name} is {@code
-     * Bar} in an operation or constructor called {@code Foo} is {@code
-     * simpleClassName + ".operation.Foo.Bar"} or {@code simpleClassName +
-     * ".constructor.Foo.Bar"} respectively.</p>
-     *
-     * <h4>Example</h4>
-     *
-     * <p>Suppose you have an MBean defined by these two Java source files:</p>
-     *
-     * <pre>
-     * // ConfigurationMBean.java
-     * package com.example;
-     * public interface ConfigurationMBean {
-     *     public String getName();
-     *     public void save(String fileName);
-     * }
-     *
-     * // Configuration.java
-     * package com.example;
-     * public class Configuration implements ConfigurationMBean {
-     *     public Configuration(String defaultName) {
-     *         ...
-     *     }
-     *     ...
-     * }
-     * </pre>
-     *
-     * <p>Then you could define the default descriptions for the MBean, by
-     * including a resource bundle called {@code com/example/MBeanDescriptions}
-     * with the compiled classes. Most often this is done by creating a file
-     * {@code MBeanDescriptions.properties} in the same directory as {@code
-     * ConfigurationMBean.java}. Make sure that this file is copied into the
-     * same place as the compiled classes; in typical build environments that
-     * will be true by default.</p>
-     *
-     * <p>The file {@code com/example/MBeanDescriptions.properties} might
-     * look like this:</p>
-     *
-     * <pre>
-     * # Description of the MBean
-     * ConfigurationMBean.mbean = Configuration manager
-     *
-     * # Description of the Name attribute
-     * ConfigurationMBean.attribute.Name = The name of the configuration
-     *
-     * # Description of the save operation
-     * ConfigurationMBean.operation.save = Save the configuration to a file
-     *
-     * # Description of the parameter to the save operation.
-     * # Parameter names from the original Java source are not available,
-     * # so the default names are p1, p2, etc.  If the names were available,
-     * # this would be ConfigurationMBean.operation.save.fileName
-     * ConfigurationMBean.operation.save.p1 = The name of the file
-     *
-     * # Description of the constructor.  The default name of a constructor is
-     * # its fully-qualified class name.
-     * ConfigurationMBean.constructor.com.example.Configuration = <!--
-     * -->Constructor with name of default file
-     * # Description of the constructor parameter.
-     * ConfigurationMBean.constructor.com.example.Configuration.p1 = <!--
-     * -->Name of the default file
-     * </pre>
-     *
-     * <p>Starting with this file, you could create descriptions for the French
-     * locale by creating {@code com/example/MBeanDescriptions_fr.properties}.
-     * The keys in this file are the same as before but the text has been
-     * translated:
-     *
-     * <pre>
-     * ConfigurationMBean.mbean = Gestionnaire de configuration
-     *
-     * ConfigurationMBean.attribute.Name = Le nom de la configuration
-     *
-     * ConfigurationMBean.operation.save = Sauvegarder la configuration <!--
-     * -->dans un fichier
-     *
-     * ConfigurationMBean.operation.save.p1 = Le nom du fichier
-     *
-     * ConfigurationMBean.constructor.com.example.Configuration = <!--
-     * -->Constructeur avec nom du fichier par d&eacute;faut
-     * ConfigurationMBean.constructor.com.example.Configuration.p1 = <!--
-     * -->Nom du fichier par d&eacute;faut
-     * </pre>
-     *
-     * <p>The descriptions in {@code MBeanDescriptions.properties} and
-     * {@code MBeanDescriptions_fr.properties} will only be consulted if
-     * {@code localizeDescriptions} is called, perhaps because the
-     * MBean Server has been wrapped by {@link
-     * ClientContext#newLocalizeMBeanInfoForwarder} or because the
-     * connector server has been created with the {@link
-     * javax.management.remote.JMXConnectorServer#LOCALIZE_MBEAN_INFO_FORWARDER
-     * LOCALIZE_MBEAN_INFO_FORWARDER} option. If you want descriptions
-     * even when there is no localization step, then you should consider
-     * using {@link Description &#64;Description} annotations. Annotations
-     * provide descriptions by default but are overridden if {@code
-     * localizeDescriptions} is called.</p>
-     *
-     * @param locale the target locale for descriptions.  Cannot be null.
-     *
-     * @param loader the {@code ClassLoader} to use for looking up resource
-     * bundles.
-     *
-     * @return an {@code MBeanInfo} with descriptions appropriately localized.
-     *
-     * @throws NullPointerException if {@code locale} is null.
-     */
-    public MBeanInfo localizeDescriptions(Locale locale, ClassLoader loader) {
-        if (locale == null)
-            throw new NullPointerException("locale");
-        Descriptor d = getDescriptor();
-        String mbiLocaleString = (String) d.getFieldValue(JMX.LOCALE_FIELD);
-        if (locale.toString().equals(mbiLocaleString))
-            return this;
-        return new Rewriter(this, locale, loader).getMBeanInfo();
-    }
-
-    private static class Rewriter {
-        private final MBeanInfo mbi;
-        private final ClassLoader loader;
-        private final Locale locale;
-        private final String packageName;
-        private final String simpleClassNamePlusDot;
-        private ResourceBundle defaultBundle;
-        private boolean defaultBundleLoaded;
-
-        // ResourceBundle.getBundle throws NullPointerException
-        // if the loader is null, even though that is perfectly
-        // valid and means the bootstrap loader.  So we work
-        // around with a ClassLoader that is equivalent to the
-        // bootstrap loader but is not null.
-        private static final ClassLoader bootstrapLoader =
-                new ClassLoader(null) {};
-
-        Rewriter(MBeanInfo mbi, Locale locale, ClassLoader loader) {
-            this.mbi = mbi;
-            this.locale = locale;
-            if (loader == null)
-                loader = bootstrapLoader;
-            this.loader = loader;
-
-            String intfName = (String)
-                    mbi.getDescriptor().getFieldValue("interfaceClassName");
-            if (intfName == null)
-                intfName = mbi.getClassName();
-            int lastDot = intfName.lastIndexOf('.');
-            this.packageName = intfName.substring(0, lastDot + 1);
-            this.simpleClassNamePlusDot = intfName.substring(lastDot + 1) + ".";
-            // Inner classes show up as Outer$Inner so won't match the dot.
-            // When there is no dot, lastDot is -1,
-            // packageName is empty, and simpleClassNamePlusDot is intfName.
-        }
-
-        MBeanInfo getMBeanInfo() {
-            MBeanAttributeInfo[] mbais =
-                    rewrite(mbi.getAttributes(), "attribute.");
-            MBeanOperationInfo[] mbois =
-                    rewrite(mbi.getOperations(), "operation.");
-            MBeanConstructorInfo[] mbcis =
-                    rewrite(mbi.getConstructors(), "constructor.");
-            MBeanNotificationInfo[] mbnis =
-                    rewrite(mbi.getNotifications(), "notification.");
-            Descriptor d = mbi.getDescriptor();
-            d = changeLocale(d);
-            String description = getDescription(d, "mbean", "");
-            if (description == null)
-                description = mbi.getDescription();
-            return new MBeanInfo(
-                    mbi.getClassName(), description,
-                    mbais, mbcis, mbois, mbnis, d);
-        }
-
-        private Descriptor changeLocale(Descriptor d) {
-            if (d.getFieldValue(JMX.LOCALE_FIELD) != null) {
-                Map<String, Object> map = new HashMap<String, Object>();
-                for (String field : d.getFieldNames())
-                    map.put(field, d.getFieldValue(field));
-                map.remove(JMX.LOCALE_FIELD);
-                d = new ImmutableDescriptor(map);
-            }
-            return ImmutableDescriptor.union(
-                    d, new ImmutableDescriptor(JMX.LOCALE_FIELD + "=" + locale));
-        }
-
-        private String getDescription(
-                Descriptor d, String defaultPrefix, String defaultSuffix) {
-            ResourceBundle bundle = bundleFromDescriptor(d);
-            if (bundle == null)
-                return null;
-            String key =
-                    (String) d.getFieldValue(JMX.DESCRIPTION_RESOURCE_KEY_FIELD);
-            if (key == null)
-                key = simpleClassNamePlusDot + defaultPrefix + defaultSuffix;
-            return descriptionFromResource(bundle, key);
-        }
-
-        private <T extends MBeanFeatureInfo> T[] rewrite(
-                T[] features, String resourcePrefix) {
-            for (int i = 0; i < features.length; i++) {
-                T feature = features[i];
-                Descriptor d = feature.getDescriptor();
-                String description =
-                        getDescription(d, resourcePrefix, feature.getName());
-                if (description != null &&
-                        !description.equals(feature.getDescription())) {
-                    features[i] = setDescription(feature, description);
-                }
-            }
-            return features;
-        }
-
-        private <T extends MBeanFeatureInfo> T setDescription(
-                T feature, String description) {
-
-            Object newf;
-            String name = feature.getName();
-            Descriptor d = feature.getDescriptor();
-
-            if (feature instanceof MBeanAttributeInfo) {
-                MBeanAttributeInfo mbai = (MBeanAttributeInfo) feature;
-                newf = new MBeanAttributeInfo(
-                        name, mbai.getType(), description,
-                        mbai.isReadable(), mbai.isWritable(), mbai.isIs(),
-                        d);
-            } else if (feature instanceof MBeanOperationInfo) {
-                MBeanOperationInfo mboi = (MBeanOperationInfo) feature;
-                MBeanParameterInfo[] sig = rewrite(
-                        mboi.getSignature(), "operation." + name + ".");
-                newf = new MBeanOperationInfo(
-                        name, description, sig,
-                        mboi.getReturnType(), mboi.getImpact(), d);
-            } else if (feature instanceof MBeanConstructorInfo) {
-                MBeanConstructorInfo mbci = (MBeanConstructorInfo) feature;
-                MBeanParameterInfo[] sig = rewrite(
-                        mbci.getSignature(), "constructor." + name + ".");
-                newf = new MBeanConstructorInfo(
-                        name, description, sig, d);
-            } else if (feature instanceof MBeanNotificationInfo) {
-                MBeanNotificationInfo mbni = (MBeanNotificationInfo) feature;
-                newf = new MBeanNotificationInfo(
-                        mbni.getNotifTypes(), name, description, d);
-            } else if (feature instanceof MBeanParameterInfo) {
-                MBeanParameterInfo mbpi = (MBeanParameterInfo) feature;
-                newf = new MBeanParameterInfo(
-                        name, mbpi.getType(), description, d);
-            } else {
-                logger().log(Level.FINE, "Unknown feature type: " +
-                        feature.getClass());
-                newf = feature;
-            }
-
-            return Util.<T>cast(newf);
-        }
-
-        private ResourceBundle bundleFromDescriptor(Descriptor d) {
-            String bundleName = (String) d.getFieldValue(
-                    JMX.DESCRIPTION_RESOURCE_BUNDLE_BASE_NAME_FIELD);
-
-            if (bundleName != null)
-                return getBundle(bundleName);
-
-            if (defaultBundleLoaded)
-                return defaultBundle;
-
-            bundleName = packageName + "MBeanDescriptions";
-            defaultBundle = getBundle(bundleName);
-            defaultBundleLoaded = true;
-            return defaultBundle;
-        }
-
-        private String descriptionFromResource(
-                ResourceBundle bundle, String key) {
-            try {
-                return bundle.getString(key);
-            } catch (MissingResourceException e) {
-                logger().log(Level.FINEST, "No resource for " + key, e);
-            } catch (Exception e) {
-                logger().log(Level.FINE, "Bad resource for " + key, e);
-            }
-            return null;
-        }
-
-        private ResourceBundle getBundle(String name) {
-            try {
-                return ResourceBundle.getBundle(name, locale, loader);
-            } catch (Exception e) {
-                logger().log(Level.FINE,
-                           "Could not load ResourceBundle " + name, e);
-                return null;
-            }
-        }
-
-        private Logger logger() {
-            return Logger.getLogger("javax.management.locale");
-        }
-    }
 }
--- a/src/share/classes/javax/management/MBeanOperationInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanOperationInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -48,28 +48,24 @@
     /**
      * Indicates that the operation is read-like:
      * it returns information but does not change any state.
-     * @see Impact#INFO
      */
     public static final int INFO = 0;
 
     /**
      * Indicates that the operation is write-like: it has an effect but does
      * not return any information from the MBean.
-     * @see Impact#ACTION
      */
     public static final int ACTION = 1;
 
     /**
      * Indicates that the operation is both read-like and write-like:
      * it has an effect, and it also returns information from the MBean.
-     * @see Impact#ACTION_INFO
      */
     public static final int ACTION_INFO = 2;
 
     /**
      * Indicates that the impact of the operation is unknown or cannot be
      * expressed using one of the other values.
-     * @see Impact#UNKNOWN
      */
     public static final int UNKNOWN = 3;
 
@@ -113,7 +109,7 @@
              methodSignature(method),
              method.getReturnType().getName(),
              UNKNOWN,
-             Introspector.descriptorForElement(method, false));
+             Introspector.descriptorForElement(method));
     }
 
     /**
@@ -185,6 +181,7 @@
      * <p>Since this class is immutable, cloning is chiefly of interest
      * to subclasses.</p>
      */
+     @Override
      public Object clone () {
          try {
              return super.clone() ;
@@ -257,6 +254,7 @@
         return impact;
     }
 
+    @Override
     public String toString() {
         String impactString;
         switch (getImpact()) {
@@ -288,6 +286,7 @@
      * to those of this MBeanConstructorInfo.  Two signature arrays
      * are equal if their elements are pairwise equal.
      */
+    @Override
     public boolean equals(Object o) {
         if (o == this)
             return true;
@@ -327,14 +326,9 @@
 
         for (int i = 0; i < classes.length; i++) {
             Descriptor d = Introspector.descriptorForAnnotations(annots[i]);
-            String description = Introspector.descriptionForParameter(annots[i]);
-            if (description == null)
-                description = "";
-            String name = Introspector.nameForParameter(annots[i]);
-            if (name == null)
-                name = "p" + (i + 1);
-            params[i] = new MBeanParameterInfo(
-                    name, classes[i].getName(), description, d);
+            final String pn = "p" + (i + 1);
+            params[i] =
+                new MBeanParameterInfo(pn, classes[i].getName(), "", d);
         }
 
         return params;
--- a/src/share/classes/javax/management/MBeanPermission.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanPermission.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,7 +25,6 @@
 
 package javax.management;
 
-import com.sun.jmx.mbeanserver.Util;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.security.Permission;
@@ -46,7 +45,7 @@
  * allowed if the permissions you have {@linkplain #implies imply} the
  * permission you need.</p>
  *
- * <p>An MBeanPermission contains five items of information:</p>
+ * <p>An MBeanPermission contains four items of information:</p>
  *
  * <ul>
  *
@@ -58,23 +57,6 @@
  *
  * <p>The action is returned by {@link #getActions()}.</p>
  *
- * <li id="MBeanServerName"><p>The <em>MBean Server name</em>.</p>
- *
- * <p>For a permission you need, this is the {@linkplain
- * javax.management.MBeanServerFactory#getMBeanServerName
- * name of the MBeanServer}
- * containing the <a href="#MBeanName">MBean</a> for which the MBean
- * permission is checked.</p>
- *
- * <p>For a permission you have, this is either the  {@linkplain
- * javax.management.MBeanServerFactory#getMBeanServerName
- * name of the MBeanServer} in which the <a href="#MBeanName">MBean</a>
- * you have this permission for must be registered,
- * or a pattern against which that MBean Server name will be matched.<br>
- * An {@code mbeanServerName} pattern can also be empty or the single
- * character {@code "*"}, both of which will match any {@code MBeanServer} name.
- * </p>
- *
  * <li><p>The <em>class name</em>.</p>
  *
  * <p>For a permission you need, this is the class name of an MBean
@@ -121,15 +103,15 @@
  * </ul>
  *
  * <p>If you have an MBeanPermission, it allows operations only if all
- * five of the items match.</p>
+ * four of the items match.</p>
  *
- * <p>The MBean Server name, class name, member, and object name can be written
- * together as a single string, which is the <em>name</em> of this permission.
+ * <p>The class name, member, and object name can be written together
+ * as a single string, which is the <em>name</em> of this permission.
  * The name of the permission is the string returned by {@link
  * Permission#getName() getName()}.  The format of the string is:</p>
  *
  * <blockquote>
- * <code>mbeanServerName::className#member[objectName]</code>
+ * <code>className#member[objectName]</code>
  * </blockquote>
  *
  * <p>The object name is written using the usual syntax for {@link
@@ -137,18 +119,15 @@
  * <code>]</code>.  It is terminated by a <code>]</code> character
  * that is the last character in the string.</p>
  *
- * <p>One or more of the <code>mbeanServerName</code>, <code>className</code>,
- * <code>member</code>, or <code>objectName</code> may be omitted. If the
- * <code>mbeanServerName</code> is omitted, the <code>::</code> may be too (but
- * does not have to be).
- * If the <code>member</code> is omitted, the <code>#</code> may be too (but
+ * <p>One or more of the <code>className</code>, <code>member</code>,
+ * or <code>objectName</code> may be omitted.  If the
+ * <code>member</code> is omitted, the <code>#</code> may be too (but
  * does not have to be).  If the <code>objectName</code> is omitted,
  * the <code>[]</code> may be too (but does not have to be).  It is
- * not legal to omit all four items, that is to have a <em>name</em>
+ * not legal to omit all three items, that is to have a <em>name</em>
  * that is the empty string.</p>
  *
- * <p>One or more of the <code>mbeanServerName</code>,  <code>className</code>,
- * <code>member</code>,
+ * <p>One or more of the <code>className</code>, <code>member</code>,
  * or <code>objectName</code> may be the character "<code>-</code>",
  * which is equivalent to a null value.  A null value is implied by
  * any value (including another null value) but does not imply any
@@ -268,13 +247,6 @@
     private transient ObjectName objectName;
 
     /**
-     * The name of the MBeanServer in which this permission is checked, or
-     * granted.  If null, is implied by any MBean Server name
-     * but does not imply any non-null MBean Server name.
-     */
-    private transient String mbeanServerName;
-
-    /**
      * Parse <code>actions</code> parameter.
      */
     private void parseActions() {
@@ -311,13 +283,6 @@
             throw new IllegalArgumentException("MBeanPermission name " +
                                                "cannot be empty");
 
-        final int sepIndex = name.indexOf("::");
-        if (sepIndex < 0) {
-            setMBeanServerName("*");
-        } else {
-            setMBeanServerName(name.substring(0,sepIndex));
-        }
-
         /* The name looks like "class#member[objectname]".  We subtract
            elements from the right as we parse, so after parsing the
            objectname we have "class#member" and after parsing the
@@ -325,14 +290,11 @@
 
         // Parse ObjectName
 
-
-        final int start = (sepIndex<0)?0:sepIndex+2;
-        int openingBracket = name.indexOf("[",start);
+        int openingBracket = name.indexOf("[");
         if (openingBracket == -1) {
             // If "[on]" missing then ObjectName("*:*")
             //
             objectName = ObjectName.WILDCARD;
-            name = name.substring(start);
         } else {
             if (!name.endsWith("]")) {
                 throw new IllegalArgumentException("MBeanPermission: " +
@@ -343,11 +305,11 @@
             } else {
                 // Create ObjectName
                 //
-                String on = name.substring(openingBracket + 1,
-                                           name.length() - 1);
                 try {
                     // If "[]" then ObjectName("*:*")
                     //
+                    String on = name.substring(openingBracket + 1,
+                                               name.length() - 1);
                     if (on.equals(""))
                         objectName = ObjectName.WILDCARD;
                     else if (on.equals("-"))
@@ -362,7 +324,7 @@
                 }
             }
 
-            name = name.substring(start, openingBracket);
+            name = name.substring(0, openingBracket);
         }
 
         // Parse member
@@ -386,9 +348,8 @@
      * Assign fields based on className, member, and objectName
      * parameters.
      */
-    private void initName(String mbeanServerName, String className,
-                          String member, ObjectName objectName) {
-        setMBeanServerName(mbeanServerName);
+    private void initName(String className, String member,
+                          ObjectName objectName) {
         setClassName(className);
         setMember(member);
         this.objectName = objectName;
@@ -420,30 +381,19 @@
             this.member = member;
     }
 
-    private void setMBeanServerName(String mbeanServerName) {
-        if (mbeanServerName == null || mbeanServerName.equals("-")) {
-            this.mbeanServerName = null;
-        } else if (mbeanServerName.equals("")) {
-            this.mbeanServerName = "*";
-        } else {
-            this.mbeanServerName = mbeanServerName;
-        }
-    }
-
-
     /**
      * <p>Create a new MBeanPermission object with the specified target name
      * and actions.</p>
      *
      * <p>The target name is of the form
-     * "<code>mbeanServerName::className#member[objectName]</code>" where
-     * each part is optional.  It must not be empty or null.</p>
+     * "<code>className#member[objectName]</code>" where each part is
+     * optional.  It must not be empty or null.</p>
      *
      * <p>The actions parameter contains a comma-separated list of the
      * desired actions granted on the target name.  It must not be
      * empty or null.</p>
      *
-     * @param name the quadruplet "mbeanServerName::className#member[objectName]".
+     * @param name the triplet "className#member[objectName]".
      * @param actions the action string.
      *
      * @exception IllegalArgumentException if the <code>name</code> or
@@ -468,12 +418,6 @@
      * optional.  This will be the result of {@link #getName()} on the
      * resultant MBeanPermission.</p>
      *
-     * <p>This corresponds to a permission granted for all
-     *    MBean servers present in the JVM and is equivalent to
-     *    {@link #MBeanPermission(String,String,String,ObjectName,String)
-     *           MBeanPermission("*",className,member,objectName,actions)}.
-     * </p>
-     *
      * <p>The actions parameter contains a comma-separated list of the
      * desired actions granted on the target name.  It must not be
      * empty or null.</p>
@@ -495,67 +439,17 @@
                            String member,
                            ObjectName objectName,
                            String actions) {
-        this("*",className,member,objectName,actions);
-    }
 
-    /**
-     * <p>Create a new MBeanPermission object with the specified target name
-     * (MBean Server name, class name, member, object name) and actions.</p>
-     *
-     * <p>The MBean Server name, class name, member and object name
-     * parameters define a target name of the form
-     * "<code>mbeanServerName::className#member[objectName]</code>" where each
-     * part is optional.  This will be the result of {@link #getName()} on the
-     * resultant MBeanPermission.
-     * If the <code>mbeanServerName</code> is empty or exactly {@code "*"}, then
-     * "{@code mbeanServerName::}" is omitted in that result.
-     * </p>
-     *
-     * <p>The actions parameter contains a comma-separated list of the
-     * desired actions granted on the target name.  It must not be
-     * empty or null.</p>
-     *
-     * @param mbeanServerName the name of the {@code MBeanServer} to which this
-     * permission applies.
-     * May be null or <code>"-"</code>, which represents an MBeanServer name
-     * that is implied by any MBeanServer name but does not imply any other
-     * MBeanServer name.
-     * @param className the class name to which this permission applies.
-     * May be null or <code>"-"</code>, which represents a class name
-     * that is implied by any class name but does not imply any other
-     * class name.
-     * @param member the member to which this permission applies.  May
-     * be null or <code>"-"</code>, which represents a member that is
-     * implied by any member but does not imply any other member.
-     * @param objectName the object name to which this permission
-     * applies.  May be null, which represents an object name that is
-     * implied by any object name but does not imply any other object
-     * name.
-     * @param actions the action string.
-     *
-     * @since 1.7
-     */
-    public MBeanPermission(String mbeanServerName,
-                           String className,
-                           String member,
-                           ObjectName objectName,
-                           String actions) {
-
-        super(makeName(mbeanServerName,className, member, objectName));
-        initName(mbeanServerName,className, member, objectName);
+        super(makeName(className, member, objectName));
+        initName(className, member, objectName);
 
         this.actions = actions;
         parseActions();
     }
 
-    private static String makeName(String mbeanServerName, String className,
-                                   String member,
+    private static String makeName(String className, String member,
                                    ObjectName objectName) {
         final StringBuilder name = new StringBuilder();
-        if (mbeanServerName == null)
-            mbeanServerName = "-";
-        if (!mbeanServerName.equals("") && !mbeanServerName.equals("*"))
-            name.append(mbeanServerName).append("::");
         if (className == null)
             className = "-";
         name.append(className);
@@ -1097,9 +991,6 @@
      *
      * <li> <i>p</i> is an instance of MBeanPermission; and</li>
      *
-     * <li> <i>p</i> has a null mbeanServerName or <i>p</i>'s mbeanServerName
-     * matches this object's mbeanServerName; and</li>
-     *
      * <li> <i>p</i> has a null className or <i>p</i>'s className
      * matches this object's className; and</li>
      *
@@ -1113,13 +1004,6 @@
      *
      * </ul>
      *
-     * <p>If this object's mbeanServerName is a pattern, then <i>p</i>'s
-     *    mbeanServerName is matched against that pattern. An empty
-     *    mbeanServerName is equivalent to "{@code *}". A null
-     *    mbeanServerName is equivalent to "{@code -}".</p>
-     * <p>If this object's mbeanServerName is "<code>*</code>" or is
-     * empty, <i>p</i>'s mbeanServerName always matches it.</p>
-     *
      * <p>If this object's className is "<code>*</code>", <i>p</i>'s
      * className always matches it.  If it is "<code>a.*</code>", <i>p</i>'s
      * className matches it if it begins with "<code>a.</code>".</p>
@@ -1166,12 +1050,6 @@
 
         // Target name
         //
-        // The 'mbeanServerName' check is true iff:
-        // 1) the mbeanServerName in 'this' permission is omitted or "*", or
-        // 2) the mbeanServerName in 'that' permission is omitted or "*", or
-        // 3) the mbeanServerName in 'this' permission does pattern
-        //    matching with the mbeanServerName in 'that' permission.
-        //
         // The 'className' check is true iff:
         // 1) the className in 'this' permission is omitted or "*", or
         // 2) the className in 'that' permission is omitted or "*", or
@@ -1198,17 +1076,6 @@
            expect that "that" contains a wildcard, since it is a
            needed permission.  So we assume that.classNameExactMatch.  */
 
-        if (that.mbeanServerName == null) {
-            // bottom is implied
-        } else if (this.mbeanServerName == null) {
-            // bottom implies nothing but itself
-            return false;
-        } else if (that.mbeanServerName.equals(this.mbeanServerName)) {
-            // exact match
-        } else if (!Util.wildmatch(that.mbeanServerName,this.mbeanServerName)) {
-            return false; // no match
-        }
-
         if (that.classNamePrefix == null) {
             // bottom is implied
         } else if (this.classNamePrefix == null) {
--- a/src/share/classes/javax/management/MBeanRegistration.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanRegistration.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,99 +33,6 @@
  * to get a reference to the MBean Server and/or its name within that
  * MBean Server.</p>
  *
- * <h4 id="injection">Resource injection</h4>
- *
- * <p>As an alternative to implementing {@code MBeanRegistration}, if all that
- * is needed is the MBean Server or ObjectName then an MBean can use
- * <em>resource injection</em>.</p>
- *
- * <p>If a field in the MBean object has type {@link ObjectName} and has
- * the {@link javax.annotation.Resource &#64;Resource} annotation,
- * then the {@code ObjectName} under which the MBean is registered is
- * assigned to that field during registration.  Likewise, if a field has type
- * {@link MBeanServer} and the <code>&#64;Resource</code> annotation, then it will
- * be set to the {@code MBeanServer} in which the MBean is registered.</p>
- *
- * <p>For example:</p>
- *
- * <pre>
- * public Configuration implements ConfigurationMBean {
- *     &#64;Resource
- *     private volatile MBeanServer mbeanServer;
- *     &#64;Resource
- *     private volatile ObjectName objectName;
- *     ...
- *     void unregisterSelf() throws Exception {
- *         mbeanServer.unregisterMBean(objectName);
- *     }
- * }
- * </pre>
- *
- * <p>Resource injection can also be used on fields of type
- * {@link SendNotification} to simplify notification sending.  Such a field
- * will get a reference to an object of type {@code SendNotification} when
- * the MBean is registered, and it can use this reference to send notifications.
- * For example:</p>
- *
- * <pre>
- * public Configuration implements ConfigurationMBean {
- *     &#64;Resource
- *     private volatile SendNotification sender;
- *     ...
- *     private void updated() {
- *         Notification n = new Notification(...);
- *         sender.sendNotification(n);
- *     }
- * }
- * </pre>
- *
- * <p>(Listeners may be invoked in the same thread as the caller of
- * {@code sender.sendNotification}.)</p>
- *
- * <p>A field to be injected must not be static.  It is recommended that
- * such fields be declared {@code volatile}.</p>
- *
- * <p>It is also possible to use the <code>&#64;Resource</code> annotation on
- * methods. Such a method must have a {@code void} return type and a single
- * argument of the appropriate type, for example {@code ObjectName}.</p>
- *
- * <p>Any number of fields and methods may have the <code>&#64;Resource</code>
- * annotation.  All fields and methods with type {@code ObjectName}
- * (for example) will receive the same {@code ObjectName} value.</p>
- *
- * <p>Resource injection is available for all types of MBeans, not just
- * Standard MBeans.</p>
- *
- * <p>If an MBean implements the {@link DynamicWrapperMBean} interface then
- * resource injection happens on the object returned by that interface's
- * {@link DynamicWrapperMBean#getWrappedObject() getWrappedObject()} method
- * rather than on the MBean object itself.
- *
- * <p>Resource injection happens after the {@link #preRegister preRegister}
- * method is called (if any), and before the MBean is actually registered
- * in the MBean Server. If a <code>&#64;Resource</code> method throws
- * an exception, the effect is the same as if {@code preRegister} had
- * thrown the exception. In particular it will prevent the MBean from being
- * registered.</p>
- *
- * <p>Resource injection can be used on a field or method where the type
- * is a parent of the injected type, if the injected type is explicitly
- * specified in the <code>&#64;Resource</code> annotation.  For example:</p>
- *
- * <pre>
- *     &#64;Resource(type = MBeanServer.class)
- *     private volatile MBeanServerConnection mbsc;
- * </pre>
- *
- * <p>Formally, suppose <em>R</em> is the type in the <code>&#64;Resource</code>
- * annotation and <em>T</em> is the type of the method parameter or field.
- * Then one of <em>R</em> and <em>T</em> must be a subtype of the other
- * (or they must be the same type).  Injection happens if this subtype
- * is {@code MBeanServer}, {@code ObjectName}, or {@code SendNotification}.
- * Otherwise the <code>&#64;Resource</code> annotation is ignored.</p>
- *
- * <p>Resource injection in MBeans is new in version 2.0 of the JMX API.</p>
- *
  * @since 1.5
  */
 public interface MBeanRegistration   {
@@ -196,7 +103,7 @@
      * <p>If the implementation of this method throws a {@link RuntimeException}
      * or an {@link Error}, the MBean Server will rethrow those inside
      * a {@link RuntimeMBeanException} or {@link RuntimeErrorException},
-     * respectively. However, throwing an excepption in {@code postDeregister}
+     * respectively. However, throwing an exception in {@code postDeregister}
      * will not change the state of the MBean:
      * the MBean was already successfully deregistered and will remain so. </p>
      * <p>This might be confusing for the code calling
--- a/src/share/classes/javax/management/MBeanServer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanServer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -61,13 +61,9 @@
  * <CODE>ObjectName</CODE> is: <BR>
  * <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.</p>
  *
- * <p id="security">An object obtained from the {@link
- * MBeanServerFactory#createMBeanServer(String) createMBeanServer}, {@link
- * MBeanServerFactory#createNamedMBeanServer(String,String) createNamedMBeanServer},
- * {@link
- * MBeanServerFactory#newMBeanServer(String) newMBeanServer}, or
- * {@link
- * MBeanServerFactory#newNamedMBeanServer(String,String) newNamedMBeanServer}
+ * <p>An object obtained from the {@link
+ * MBeanServerFactory#createMBeanServer(String) createMBeanServer} or
+ * {@link MBeanServerFactory#newMBeanServer(String) newMBeanServer}
  * methods of the {@link MBeanServerFactory} class applies security
  * checks to its methods, as follows.</p>
  *
@@ -77,26 +73,10 @@
  *
  * <p>Assuming that there is a security manager, or that the
  * implementation chooses to make checks anyway, the checks are made
- * as detailed below.
- * In what follows, and unless otherwise specified:
- * </p>
- * <ul><li><code>className</code> is the
+ * as detailed below.  In what follows, and unless otherwise specified,
+ * {@code className} is the
  * string returned by {@link MBeanInfo#getClassName()} for the target
- * MBean,</li>
- * <li>{@code mbeanServerName} is the
- * {@linkplain MBeanServerFactory#getMBeanServerName name of the
- * MBean Server} in which the target MBean is registered. This is the
- * value returned by {@link MBeanServerFactory#getMBeanServerName
- * MBeanServerFactory.getMBeanServerName(MBeanServer)}, and
- * is usually the {@code mbeanServerName} parameter that was supplied
- * to the {@link
- * MBeanServerFactory#createNamedMBeanServer(String,String)
- * createNamedMBeanServer} or {@link
- * MBeanServerFactory#newNamedMBeanServer(String,String) newNamedMBeanServer}
- * methods of the {@link MBeanServerFactory} when the MBeanServer was created,
- * or {@value javax.management.MBeanServerFactory#DEFAULT_MBEANSERVER_NAME} if
- * no name was supplied.
- * </li></ul>
+ * MBean.</p>
  *
  * <p>If a security check fails, the method throws {@link
  * SecurityException}.</p>
@@ -110,87 +90,79 @@
  *
  * <li><p>For the {@link #invoke invoke} method, the caller's
  * permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, operationName, name, "invoke")}.
- * </p>
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, operationName, name, "invoke")}.</p>
  *
  * <li><p>For the {@link #getAttribute getAttribute} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, attribute, name,
- * "getAttribute")}.</p>
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, attribute, name, "getAttribute")}.</p>
  *
  * <li><p>For the {@link #getAttributes getAttributes} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName,className, null, name, "getAttribute")}.
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name, "getAttribute")}.
  * Additionally, for each attribute <em>a</em> in the {@link
  * AttributeList}, if the caller's permissions do not imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, <em>a</em>, name,
- * "getAttribute")}, the
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, <em>a</em>, name, "getAttribute")}, the
  * MBean server will behave as if that attribute had not been in the
  * supplied list.</p>
  *
  * <li><p>For the {@link #setAttribute setAttribute} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, attrName, name,
- * "setAttribute")}, where
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, attrName, name, "setAttribute")}, where
  * <code>attrName</code> is {@link Attribute#getName()
  * attribute.getName()}.</p>
  *
  * <li><p>For the {@link #setAttributes setAttributes} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name, "setAttribute")}.
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name, "setAttribute")}.
  * Additionally, for each attribute <em>a</em> in the {@link
  * AttributeList}, if the caller's permissions do not imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, <em>a</em>, name,
- * "setAttribute")}, the
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, <em>a</em>, name, "setAttribute")}, the
  * MBean server will behave as if that attribute had not been in the
  * supplied list.</p>
  *
  * <li><p>For the <code>addNotificationListener</code> methods,
  * the caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name,
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name,
  * "addNotificationListener")}.</p>
  *
  * <li><p>For the <code>removeNotificationListener</code> methods,
  * the caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name,
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name,
  * "removeNotificationListener")}.</p>
  *
  * <li><p>For the {@link #getMBeanInfo getMBeanInfo} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name, "getMBeanInfo")}.
- * </p>
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name, "getMBeanInfo")}.</p>
  *
  * <li><p>For the {@link #getObjectInstance getObjectInstance} method,
  * the caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name,
- * "getObjectInstance")}.</p>
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name, "getObjectInstance")}.</p>
  *
  * <li><p>For the {@link #isInstanceOf isInstanceOf} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name, "isInstanceOf")}.
- * </p>
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name, "isInstanceOf")}.</p>
  *
  * <li><p>For the {@link #queryMBeans queryMBeans} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, null, null, null, "queryMBeans")}.
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(null, null, null, "queryMBeans")}.
  * Additionally, for each MBean <em>n</em> that matches <code>name</code>,
  * if the caller's permissions do not imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, <em>n</em>, "queryMBeans")},
- * the MBean server will behave as if that MBean did not exist.</p>
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, <em>n</em>, "queryMBeans")}, the
+ * MBean server will behave as if that MBean did not exist.</p>
  *
  * <p>Certain query elements perform operations on the MBean server.
  * If the caller does not have the required permissions for a given
@@ -208,10 +180,10 @@
  *
  * <li><p>For the {@link #getDomains getDomains} method, the caller's
  * permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, null, null, null, "getDomains")}.
- * Additionally, for each domain <var>d</var> in the returned array, if the
- * caller's permissions do not imply {@link
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(null, null, null, "getDomains")}.  Additionally,
+ * for each domain <var>d</var> in the returned array, if the caller's
+ * permissions do not imply {@link
  * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
  * MBeanPermission(null, null, new ObjectName("<var>d</var>:x=x"),
  * "getDomains")}, the domain is eliminated from the array.  Here,
@@ -220,22 +192,21 @@
  *
  * <li><p>For the {@link #getClassLoader getClassLoader} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, loaderName,
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, loaderName,
  * "getClassLoader")}.</p>
  *
  * <li><p>For the {@link #getClassLoaderFor getClassLoaderFor} method,
  * the caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, mbeanName,
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, mbeanName,
  * "getClassLoaderFor")}.</p>
  *
  * <li><p>For the {@link #getClassLoaderRepository
  * getClassLoaderRepository} method, the caller's permissions must
  * imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, null, null, null,
- * "getClassLoaderRepository")}.</p>
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(null, null, null, "getClassLoaderRepository")}.</p>
  *
  * <li><p>For the deprecated <code>deserialize</code> methods, the
  * required permissions are the same as for the methods that replace
@@ -243,15 +214,15 @@
  *
  * <li><p>For the <code>instantiate</code> methods, the caller's
  * permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, null, "instantiate")},
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, null, "instantiate")},
  * where {@code className} is the name of the class which is to
  * be instantiated.</p>
  *
  * <li><p>For the {@link #registerMBean registerMBean} method, the
  * caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name, "registerMBean")}.
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name, "registerMBean")}.
  *
  * <p>If the <code>MBeanPermission</code> check succeeds, the MBean's
  * class is validated by checking that its {@link
@@ -271,8 +242,8 @@
  *
  * <li><p>For the {@link #unregisterMBean unregisterMBean} method,
  * the caller's permissions must imply {@link
- * MBeanPermission#MBeanPermission(String,String,String,ObjectName,String)
- * MBeanPermission(mbeanServerName, className, null, name, "unregisterMBean")}.
+ * MBeanPermission#MBeanPermission(String,String,ObjectName,String)
+ * MBeanPermission(className, null, name, "unregisterMBean")}.</p>
  * </p>
  *
  * </ul>
@@ -351,14 +322,11 @@
 
     /**
      * <p>Registers a pre-existing object as an MBean with the MBean
-     * server.  If the object name given is null, the
-     * MBean must provide its own name in one or both of two ways: by implementing the {@link
+     * server. If the object name given is null, the MBean must
+     * provide its own name by implementing the {@link
      * javax.management.MBeanRegistration MBeanRegistration} interface
      * and returning the name from the {@link
-     * MBeanRegistration#preRegister preRegister} method; or by defining
-     * an {@code objectNameTemplate} field in its {@link Descriptor},
-     * typically using the {@link ObjectNameTemplate &#64;ObjectNameTemplate}
-     * annotation.</p>
+     * MBeanRegistration#preRegister preRegister} method.
      *
      * <p>If this method successfully registers an MBean, a notification
      * is sent as described <a href="#notif">above</a>.</p>
@@ -764,16 +732,13 @@
                    ReflectionException;
 
     /**
-     * <p>Return the {@link java.lang.ClassLoader} that was used for loading
-     * the class of the named MBean. If the MBean implements the {@link
-     * DynamicWrapperMBean} interface, then the returned value is the
-     * result of the {@link DynamicWrapperMBean#getWrappedClassLoader()}
-     * method.</p>
+     * <p>Return the {@link java.lang.ClassLoader} that was used for
+     * loading the class of the named MBean.</p>
      *
      * @param mbeanName The ObjectName of the MBean.
      *
      * @return The ClassLoader used for that MBean.  If <var>l</var>
-     * is the value specified by the rules above, and <var>r</var> is the
+     * is the MBean's actual ClassLoader, and <var>r</var> is the
      * returned value, then either:
      *
      * <ul>
--- a/src/share/classes/javax/management/MBeanServerConnection.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanServerConnection.java	Wed Nov 25 11:08:25 2009 -0800
@@ -29,7 +29,6 @@
 // java import
 import java.io.IOException;
 import java.util.Set;
-import javax.management.event.NotificationManager;
 
 
 /**
@@ -40,20 +39,17 @@
  *
  * @since 1.5
  */
-public interface MBeanServerConnection extends NotificationManager {
+public interface MBeanServerConnection {
     /**
      * <p>Instantiates and registers an MBean in the MBean server.  The
      * MBean server will use its {@link
      * javax.management.loading.ClassLoaderRepository Default Loader
      * Repository} to load the class of the MBean.  An object name is
      * associated with the MBean.  If the object name given is null, the
-     * MBean must provide its own name in one or both of two ways: by implementing the {@link
+     * MBean must provide its own name by implementing the {@link
      * javax.management.MBeanRegistration MBeanRegistration} interface
      * and returning the name from the {@link
-     * MBeanRegistration#preRegister preRegister} method; or by defining
-     * an {@code objectNameTemplate} field in its {@link Descriptor},
-     * typically using the {@link ObjectNameTemplate &#64;ObjectNameTemplate}
-     * annotation.</p>
+     * MBeanRegistration#preRegister preRegister} method.</p>
      *
      * <p>This method is equivalent to {@link
      * #createMBean(String,ObjectName,Object[],String[])
@@ -122,14 +118,11 @@
      * class loader to be used is identified by its object name. An
      * object name is associated with the MBean. If the object name of
      * the loader is null, the ClassLoader that loaded the MBean
-     * server will be used.  If the object name given is null, the
-     * MBean must provide its own name in one or both of two ways: by implementing the {@link
+     * server will be used.  If the MBean's object name given is null,
+     * the MBean must provide its own name by implementing the {@link
      * javax.management.MBeanRegistration MBeanRegistration} interface
      * and returning the name from the {@link
-     * MBeanRegistration#preRegister preRegister} method; or by defining
-     * an {@code objectNameTemplate} field in its {@link Descriptor},
-     * typically using the {@link ObjectNameTemplate &#64;ObjectNameTemplate}
-     * annotation.</p>
+     * MBeanRegistration#preRegister preRegister} method.</p>
      *
      * <p>This method is equivalent to {@link
      * #createMBean(String,ObjectName,ObjectName,Object[],String[])
@@ -205,13 +198,10 @@
      * javax.management.loading.ClassLoaderRepository Default Loader
      * Repository} to load the class of the MBean.  An object name is
      * associated with the MBean.  If the object name given is null, the
-     * MBean must provide its own name in one or both of two ways: by implementing the {@link
+     * MBean must provide its own name by implementing the {@link
      * javax.management.MBeanRegistration MBeanRegistration} interface
      * and returning the name from the {@link
-     * MBeanRegistration#preRegister preRegister} method; or by defining
-     * an {@code objectNameTemplate} field in its {@link Descriptor},
-     * typically using the {@link ObjectNameTemplate &#64;ObjectNameTemplate}
-     * annotation.</p>
+     * MBeanRegistration#preRegister preRegister} method.
      *
      * @param className The class name of the MBean to be instantiated.
      * @param name The object name of the MBean. May be null.
@@ -280,14 +270,11 @@
      * class loader to be used is identified by its object name. An
      * object name is associated with the MBean. If the object name of
      * the loader is not specified, the ClassLoader that loaded the
-     * MBean server will be used.  If the object name given is null, the
-     * MBean must provide its own name in one or both of two ways: by implementing the {@link
-     * javax.management.MBeanRegistration MBeanRegistration} interface
-     * and returning the name from the {@link
-     * MBeanRegistration#preRegister preRegister} method; or by defining
-     * an {@code objectNameTemplate} field in its {@link Descriptor},
-     * typically using the {@link ObjectNameTemplate &#64;ObjectNameTemplate}
-     * annotation.</p>
+     * MBean server will be used.  If the MBean object name given is
+     * null, the MBean must provide its own name by implementing the
+     * {@link javax.management.MBeanRegistration MBeanRegistration}
+     * interface and returning the name from the {@link
+     * MBeanRegistration#preRegister preRegister} method.
      *
      * @param className The class name of the MBean to be instantiated.
      * @param name The object name of the MBean. May be null.
@@ -436,17 +423,7 @@
      * specified, all the MBeans registered will be retrieved.
      * @param query The query expression to be applied for selecting
      * MBeans. If null no query expression will be applied for
-     * selecting MBeans.  ObjectName patterns that may be contained in the
-     * query expression will be
-     * <a href="namespace/package-summary.html#NamespaceAndQueries"><!--
-     * -->evaluated</a> in the context of the
-     * {@link javax.management.namespace namespace}
-     * in which the MBeans selected by {@code name} are registered.
-     * Thus, in the {@code query} parameter, no ObjectName pattern containing a
-     * namespace path can match any of the MBean names selected by {@code name}.
-     * See the
-     * <a href="namespace/package-summary.html#RejectedNamespacePatterns"><!--
-     * -->namespaces documentation</a> for more details.
+     * selecting MBeans.
      *
      * @return A set containing the <CODE>ObjectInstance</CODE>
      * objects for the selected MBeans.  If no MBean satisfies the
@@ -454,11 +431,6 @@
      *
      * @exception IOException A communication problem occurred when
      * talking to the MBean server.
-     * @exception RuntimeOperationsException Wraps a
-     * <CODE>java.lang.IllegalArgumentException</CODE>: The <em>name</em>
-     * parameter contains an invalid pattern. See the
-     * <a href="namespace/package-summary.html#RejectedNamespacePatterns"><!--
-     * -->namespaces documentation</a> for more details.
      */
     public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query)
             throws IOException;
@@ -479,17 +451,7 @@
      * specified, the name of all registered MBeans will be retrieved.
      * @param query The query expression to be applied for selecting
      * MBeans. If null no query expression will be applied for
-     * selecting MBeans. ObjectName patterns that may be contained in the
-     * query expression will be
-     * <a href="namespace/package-summary.html#NamespaceAndQueries"><!--
-     * -->evaluated</a> in the context of the
-     * {@link javax.management.namespace namespace}
-     * in which the MBeans slected by {@code name} are registered.
-     * Thus, in the {@code query} parameter, no ObjectName pattern containing a
-     * namespace path can match any of the MBean names selected by {@code name}.
-     * See the
-     * <a href="namespace/package-summary.html#RejectedNamespacePatterns"><!--
-     * -->namespaces documentation</a> for more details.
+     * selecting MBeans.
      *
      * @return A set containing the ObjectNames for the MBeans
      * selected.  If no MBean satisfies the query, an empty list is
@@ -497,11 +459,6 @@
      *
      * @exception IOException A communication problem occurred when
      * talking to the MBean server.
-     * @exception RuntimeOperationsException Wraps a
-     * <CODE>java.lang.IllegalArgumentException</CODE>: The <em>name</em>
-     * parameter contains an invalid pattern. See the
-     * <a href="namespace/package-summary.html#RejectedNamespacePatterns"><!--
-     * -->namespaces documentation</a> for more details.
      */
     public Set<ObjectName> queryNames(ObjectName name, QueryExp query)
             throws IOException;
@@ -594,7 +551,8 @@
      * else {
      *     {@code List<String>} missing = new {@code ArrayList<String>}(<!--
      * -->{@link java.util.Arrays#asList Arrays.asList}(attrNames));
-     *     missing.removeAll(list.toMap().keySet());
+     *     for (Attribute a : list.asList())
+     *         missing.remove(a.getName());
      *     System.out.println("Did not retrieve: " + missing);
      * }
      * </pre>
@@ -681,9 +639,11 @@
      * if (inputAttrs.size() == outputAttrs.size())
      *     System.out.println("All attributes were set successfully");
      * else {
-     *     {@code List<String>} missing = new {@code ArrayList<String>}(<!--
-     * -->inputAttrs.toMap().keySet());
-     *     missing.removeAll(outputAttrs.toMap().keySet());
+     *     {@code List<String>} missing = new {@code ArrayList<String>}();
+     *     for (Attribute a : inputAttrs.asList())
+     *         missing.add(a.getName());
+     *     for (Attribute a : outputAttrs.asList())
+     *         missing.remove(a.getName());
      *     System.out.println("Did not set: " + missing);
      * }
      * </pre>
@@ -809,7 +769,28 @@
     public String[] getDomains()
             throws IOException;
 
-    // doc inherited from NotificationManager
+    /**
+     * <p>Adds a listener to a registered MBean.
+     * Notifications emitted by the MBean will be forwarded to the listener.</p>
+     *
+     * @param name The name of the MBean on which the listener should
+     * be added.
+     * @param listener The listener object which will handle the
+     * notifications emitted by the registered MBean.
+     * @param filter The filter object. If filter is null, no
+     * filtering will be performed before handling notifications.
+     * @param handback The context to be sent to the listener when a
+     * notification is emitted.
+     *
+     * @exception InstanceNotFoundException The MBean name provided
+     * does not match any of the registered MBeans.
+     * @exception IOException A communication problem occurred when
+     * talking to the MBean server.
+     *
+     * @see #removeNotificationListener(ObjectName, NotificationListener)
+     * @see #removeNotificationListener(ObjectName, NotificationListener,
+     * NotificationFilter, Object)
+     */
     public void addNotificationListener(ObjectName name,
                                         NotificationListener listener,
                                         NotificationFilter filter,
@@ -926,13 +907,65 @@
             throws InstanceNotFoundException, ListenerNotFoundException,
                    IOException;
 
-    // doc inherited from NotificationManager
+
+    /**
+     * <p>Removes a listener from a registered MBean.</p>
+     *
+     * <P> If the listener is registered more than once, perhaps with
+     * different filters or callbacks, this method will remove all
+     * those registrations.
+     *
+     * @param name The name of the MBean on which the listener should
+     * be removed.
+     * @param listener The listener to be removed.
+     *
+     * @exception InstanceNotFoundException The MBean name provided
+     * does not match any of the registered MBeans.
+     * @exception ListenerNotFoundException The listener is not
+     * registered in the MBean.
+     * @exception IOException A communication problem occurred when
+     * talking to the MBean server.
+     *
+     * @see #addNotificationListener(ObjectName, NotificationListener,
+     * NotificationFilter, Object)
+     */
     public void removeNotificationListener(ObjectName name,
                                            NotificationListener listener)
             throws InstanceNotFoundException, ListenerNotFoundException,
                    IOException;
 
-    // doc inherited from NotificationManager
+    /**
+     * <p>Removes a listener from a registered MBean.</p>
+     *
+     * <p>The MBean must have a listener that exactly matches the
+     * given <code>listener</code>, <code>filter</code>, and
+     * <code>handback</code> parameters.  If there is more than one
+     * such listener, only one is removed.</p>
+     *
+     * <p>The <code>filter</code> and <code>handback</code> parameters
+     * may be null if and only if they are null in a listener to be
+     * removed.</p>
+     *
+     * @param name The name of the MBean on which the listener should
+     * be removed.
+     * @param listener The listener to be removed.
+     * @param filter The filter that was specified when the listener
+     * was added.
+     * @param handback The handback that was specified when the
+     * listener was added.
+     *
+     * @exception InstanceNotFoundException The MBean name provided
+     * does not match any of the registered MBeans.
+     * @exception ListenerNotFoundException The listener is not
+     * registered in the MBean, or it is not registered with the given
+     * filter and handback.
+     * @exception IOException A communication problem occurred when
+     * talking to the MBean server.
+     *
+     * @see #addNotificationListener(ObjectName, NotificationListener,
+     * NotificationFilter, Object)
+     *
+     */
     public void removeNotificationListener(ObjectName name,
                                            NotificationListener listener,
                                            NotificationFilter filter,
@@ -986,12 +1019,6 @@
      *
      * <p>Otherwise, the result is false.</p>
      *
-     * <p>If the MBean implements the {@link DynamicWrapperMBean}
-     * interface, then in the above rules X is the result of the MBean's {@link
-     * DynamicWrapperMBean#getWrappedObject() getWrappedObject()} method and L
-     * is the result of its {@link DynamicWrapperMBean#getWrappedClassLoader()
-     * getWrappedClassLoader()} method.
-     *
      * @param name The <CODE>ObjectName</CODE> of the MBean.
      * @param className The name of the class.
      *
--- a/src/share/classes/javax/management/MBeanServerDelegate.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanServerDelegate.java	Wed Nov 25 11:08:25 2009 -0800
@@ -41,7 +41,6 @@
 
     /** The MBean server agent identification.*/
     private String mbeanServerId ;
-    private String mbeanServerName;
 
     /** The NotificationBroadcasterSupport object that sends the
         notifications */
@@ -71,7 +70,6 @@
     public MBeanServerDelegate () {
         stamp = getStamp();
         broadcaster = new NotificationBroadcasterSupport() ;
-        mbeanServerName=null;
     }
 
 
@@ -90,99 +88,12 @@
                         "using \"localhost\" instead. Cause is: "+e);
                 localHost = "localhost";
             }
-            mbeanServerId =
-                    Util.insertMBeanServerName(localHost + "_" + stamp,
-                    mbeanServerName);
+            mbeanServerId = localHost + "_" + stamp;
         }
         return mbeanServerId;
     }
 
     /**
-     * The name of the MBeanServer.
-     * @return The name of the MBeanServer, or {@value
-     * javax.management.MBeanServerFactory#DEFAULT_MBEANSERVER_NAME} if no
-     * name was specified.
-     *
-     * @since 1.7
-     * @see #setMBeanServerName
-     */
-    public synchronized String getMBeanServerName() {
-        if (Util.isMBeanServerNameUndefined(mbeanServerName))
-            return MBeanServerFactory.DEFAULT_MBEANSERVER_NAME;
-        return mbeanServerName;
-    }
-
-    /**
-     * Sets the name of the MBeanServer. The name will be embedded into the
-     * {@link #getMBeanServerId MBeanServerId} using the following format:<br>
-     * {@code mbeanServerId: <mbeanServerId>;mbeanServerName=<mbeanServerName>}
-     * <p>The characters {@code ':'} (colon), {@code ';'} (semicolon ),
-     * {@code '*'} (star) and {@code '?'} (question mark) are not legal in an
-     * MBean Server name.</p>
-     * <p>For instance, if the {@code mbeanServerName} provided is
-     * {@code "com.mycompany.myapp.server1"}, and the original
-     * {@code MBeanServerId} was {@code "myhost_1213353064145"},
-     * then {@code mbeanServerName} will be
-     * embedded in the {@code MBeanServerId} - and the new value of the
-     * {@code MBeanServerId} will be:
-     * </p>
-     * <pre>
-     *       "myhost_1213353064145;mbeanServerName=com.mycompany.myapp.server1"
-     * </pre>
-     * <p>Note: The {@code mbeanServerName} is usually set by the
-     *   {@code MBeanServerFactory}. It is set only once, before the
-     *   MBean Server is returned by the factory. Once the MBean Server name is
-     *   set, it is not possible to change it.
-     * </p>
-     * @param mbeanServerName The MBeanServer name.
-     * @throws IllegalArgumentException if the MBeanServerName is already set
-     *         to a different value, or if the provided name contains
-     *         illegal characters, or if the provided name is {@code ""}
-     *         (the empty string) or "-" (dash).
-     * @throws UnsupportedOperationException if this object is of a legacy
-     *         subclass of MBeanServerDelegate which overrides {@link
-     *         #getMBeanServerId()}
-     *         in a way that doesn't support setting an MBeanServer name.
-     * @see MBeanServerFactory#getMBeanServerName
-     * @since 1.7
-     */
-    public synchronized void setMBeanServerName(String mbeanServerName) {
-        // Sets the name on the delegate. For complex backward
-        // compatibility reasons it is not possible to give the
-        // name to the MBeanServerDelegate constructor.
-        //
-        // The method setMBeanServerName() will call getMBeanServerId()
-        // to check that the name is accurately set in the MBeanServerId.
-        // If not (which could happen if a custom MBeanServerDelegate
-        // implementation overrides getMBeanServerId() and was not updated
-        // with respect to JMX 2.0 spec), this method will throw an
-        // IllegalStateException...
-
-        // will fail if mbeanServerName is illegal
-        final String name = Util.checkServerName(mbeanServerName);
-
-        // can only set mbeanServerDelegate once.
-        if (this.mbeanServerName != null && !this.mbeanServerName.equals(name))
-            throw new IllegalArgumentException(
-                    "MBeanServerName already set to a different value");
-
-        this.mbeanServerName = name;
-
-        // will fail if mbeanServerId already has a different mbeanServerName
-        mbeanServerId =
-           Util.insertMBeanServerName(getMBeanServerId(),name);
-
-        // check that we don't have a subclass which overrides
-        // getMBeanServerId() without setting mbeanServerName
-        if (!name.equals(
-                Util.extractMBeanServerName(getMBeanServerId())))
-            throw new UnsupportedOperationException(
-                    "Can't set MBeanServerName in MBeanServerId - " +
-                    "unsupported by "+this.getClass().getName()+"?");
-        // OK: at this point we know that we have correctly set mbeanServerName.
-    }
-
-    /**
      * Returns the full name of the JMX specification implemented
      * by this product.
      *
@@ -304,7 +215,7 @@
      * @since 1.6
      */
     public static final ObjectName DELEGATE_NAME =
-            ObjectName.valueOf("JMImplementation:type=MBeanServerDelegate");
+            Util.newObjectName("JMImplementation:type=MBeanServerDelegate");
 
     /* Return a timestamp that is monotonically increasing even if
        System.currentTimeMillis() isn't (for example, if you call this
--- a/src/share/classes/javax/management/MBeanServerFactory.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanServerFactory.java	Wed Nov 25 11:08:25 2009 -0800
@@ -29,11 +29,9 @@
 import static com.sun.jmx.defaults.JmxProperties.JMX_INITIAL_BUILDER;
 import static com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER;
 import com.sun.jmx.mbeanserver.GetPropertyAction;
-import com.sun.jmx.mbeanserver.Util;
 import java.security.AccessController;
 import java.security.Permission;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.logging.Level;
 import javax.management.loading.ClassLoaderRepository;
 
@@ -83,53 +81,10 @@
  * returned by the default MBeanServerBuilder implementation, for the purpose
  * of e.g. adding an additional security layer.</p>
  *
- * <p id="MBeanServerName">Since version 2.0 of the JMX API, when creating
- * an MBeanServer,
- * it is possible to specify an {@linkplain #getMBeanServerName
- * MBean Server name}.
- * To create an MBean Server with a name, the MBeanServerFactory provides two
- * new methods:</p>
- * <ul><li>{@link #createNamedMBeanServer
- * createNamedMBeanServer(mbeanServerName, defaultDomain)}: creates a named
- * MBeanServer and keeps an internal reference to the created object. The
- * MBeanServer can be later retrieved using {@link #findMBeanServer
- * findMBeanServer(mbeanServerId)} or
- * {@link #findMBeanServerByName findMBeanServerByName(mbeanServerName)}, and
- * can be released through {@link
- * #releaseMBeanServer releaseMBeanServer(mbeanServer)}.</li>
- * <li>{@link #newNamedMBeanServer
- * newNamedMBeanServer(mbeanServerName, defaultDomain)}:
- * creates a named MBeanServer without keeping any internal reference to the
- * named server.</li>
- * </ul>
- * <p>The name of the MBeanServer is stored in the
- * {@linkplain MBeanServerDelegate MBean Server delegate MBean}
- * and is embedded in its {@link MBeanServerDelegate#getMBeanServerId
- * MBeanServerId} attribute.</p>
- * <p>The name of the MBeanServer is particularly useful when
- * <a href="MBeanServer.html#security">MBean permissions</a> are checked:
- * it makes it
- * possible to distinguish between an MBean named "X" in MBeanServer named
- * "M1", and another MBean of the same name "X" in another MBeanServer named
- * "M2".</p>
- * <p>When naming MBean servers it is recommended to use a name that starts
- * with a Java package name. It is also recommended that the default domain and
- * the MBeanServer name be the same.</p>
- *
  * @since 1.5
  */
 public class MBeanServerFactory {
 
-    /**
-     * The <a href="#MBeanServerName">MBean Server name</a> that will be
-     * checked by a <a href="MBeanServer.html#security">permission you need</a>
-     * when checking access to an MBean registered in an MBeanServer for
-     * which no MBeanServer name was specified.
-     *
-     * @since 1.7
-     */
-    public final static String DEFAULT_MBEANSERVER_NAME = "default";
-
     /*
      * There are no instances of this class so don't generate the
      * default public constructor.
@@ -268,78 +223,13 @@
      * <code>javax.management.builder.initial</code> exists and can be
      * instantiated but is not assignment compatible with {@link
      * MBeanServerBuilder}.
-     *
-     * @see #createNamedMBeanServer
      */
     public static MBeanServer createMBeanServer(String domain)  {
-        return createMBeanServer(null,domain);
-    }
+        checkPermission("createMBeanServer");
 
-    /**
-     * <p>Return a new object implementing the {@link MBeanServer}
-     * interface with the specified
-     * <a href="#MBeanServerName">MBean Server name</a>
-     * and default domain name. The given MBean server name
-     * is used in <a href="MBeanServer.html#security">security checks</a>, and
-     * can also be used to {@linkplain #findMBeanServerByName(java.lang.String)
-     * find an MBeanServer by name}. The given
-     * domain name is used as the domain part in the ObjectName of
-     * MBeans when the domain is specified by the user is null.</p>
-     *
-     * <p>The MBeanServer reference is internally kept. This will
-     * allow <CODE>findMBeanServer</CODE> to return a reference to
-     * this MBeanServer object.</p>
-     *
-     * @param mbeanServerName the name for the created
-     * MBeanServer.  This is the name that will be included in the
-     * {@linkplain MBeanPermission permission you need} when checking
-     * <a href="MBeanServer.html#security">MBean Permissions</a> for accessing
-     * an MBean registered in the returned MBeanServer. The characters
-     * {@code ':'} (colon), {@code ';'} (semicolon), {@code '*'} (star)
-     * and  {@code '?'} are not legal.
-     * It is recommended that the {@code mbeanServerName}
-     * be unique in the context of a JVM, and in the form of a java package
-     * identifier. If {@code mbeanServerName} is {@code null} then the created
-     * MBean Server has no name - and {@value #DEFAULT_MBEANSERVER_NAME} is used.
-     * Calling {@code createNamedMBeanServer(null,domain)} is equivalent
-     * to calling {@link #createMBeanServer(String) createMBeanServer(domain)}.
-     *
-     * @param domain the default domain name for the created
-     * MBeanServer.  This is the value that will be returned by {@link
-     * MBeanServer#getDefaultDomain}. If a non null mbeanServerName is given,
-     * it is recommended to pass the same value as default domain.
-     *
-     * @return the newly created MBeanServer.
-     *
-     * @exception SecurityException if there is a SecurityManager and
-     * the caller's permissions do not include or imply <code>{@link
-     * MBeanServerPermission}("createMBeanServer")</code>.
-     *
-     * @exception JMRuntimeException if the property
-     * <code>javax.management.builder.initial</code> exists but the
-     * class it names cannot be instantiated through a public
-     * no-argument constructor; or if the instantiated builder returns
-     * null from its {@link MBeanServerBuilder#newMBeanServerDelegate
-     * newMBeanServerDelegate} or {@link
-     * MBeanServerBuilder#newMBeanServer newMBeanServer} methods.
-     *
-     * @exception ClassCastException if the property
-     * <code>javax.management.builder.initial</code> exists and can be
-     * instantiated but is not assignment compatible with {@link
-     * MBeanServerBuilder}.
-     *
-     * @exception IllegalArgumentException if the specified
-     * {@code mbeanServerName} is empty, or is {@code "-"}, or contains a
-     * character which is not legal.
-     *
-     * @exception UnsupportedOperationException if the specified
-     * {@code mbeanServerName} cannot be set.
-     *
-     * @since 1.7
-     */
-    public static MBeanServer createNamedMBeanServer(String mbeanServerName,
-            String domain)  {
-        return createMBeanServer(mbeanServerName, domain);
+        final MBeanServer mBeanServer = newMBeanServer(domain);
+        addMBeanServer(mBeanServer);
+        return mBeanServer;
     }
 
     /**
@@ -418,88 +308,6 @@
      * MBeanServerBuilder}.
      */
     public static MBeanServer newMBeanServer(String domain)  {
-        return newMBeanServer(null,domain);
-    }
-
-    /**
-     * <p>Return a new object implementing the MBeanServer interface
-     * with the specified <a href="#MBeanServerName">MBean server name</a>
-     * and default domain name, without keeping an
-     * internal reference to this new object.  The given MBean server name
-     * is used in <a href="MBeanServer.html#security">security checks</a>.
-     * The given domain name
-     * is used as the domain part in the ObjectName of MBeans when the
-     * domain is specified by the user is null.</p>
-     *
-     * <p>No reference is kept. <CODE>findMBeanServer</CODE> and
-     * <CODE>findMBeanServerByName</CODE> will not
-     * be able to return a reference to this MBeanServer object, but
-     * the garbage collector will be able to remove the MBeanServer
-     * object when it is no longer referenced.</p>
-     *
-     * @param mbeanServerName the name for the created
-     * MBeanServer.  This is the name that will be included in the
-     * {@linkplain MBeanPermission permission you need} when checking
-     * <a href="MBeanServer.html#security">MBean Permissions</a> for accessing
-     * an MBean registered in the returned MBeanServer. The characters
-     * {@code ':'} (colon), {@code ';'} (semicolon), {@code '*'} (star)
-     * and  {@code '?'} are not legal.
-     * It is recommended that the mbeanServerName
-     * be unique in the context of a JVM, and in the form of a java package
-     * identifier. If {@code mbeanServerName} is {@code null} then the created
-     * MBean Server has no name - and {@value #DEFAULT_MBEANSERVER_NAME} is used.
-     * Calling {@code newNamedMBeanServer(null,domain)} is equivalent
-     * to calling {@link #newMBeanServer(String) newMBeanServer(domain)}.
-     *
-     * @param domain the default domain name for the created
-     * MBeanServer.  This is the value that will be returned by {@link
-     * MBeanServer#getDefaultDomain}.
-     *
-     * @return the newly created MBeanServer.
-     *
-     * @exception SecurityException if there is a SecurityManager and the
-     * caller's permissions do not include or imply <code>{@link
-     * MBeanServerPermission}("newMBeanServer")</code>.
-     *
-     * @exception JMRuntimeException if the property
-     * <code>javax.management.builder.initial</code> exists but the
-     * class it names cannot be instantiated through a public
-     * no-argument constructor; or if the instantiated builder returns
-     * null from its {@link MBeanServerBuilder#newMBeanServerDelegate
-     * newMBeanServerDelegate} or {@link
-     * MBeanServerBuilder#newMBeanServer newMBeanServer} methods.
-     *
-     * @exception ClassCastException if the property
-     * <code>javax.management.builder.initial</code> exists and can be
-     * instantiated but is not assignment compatible with {@link
-     * MBeanServerBuilder}.
-     *
-     * @exception IllegalArgumentException if the specified
-     * {@code mbeanServerName} is empty, or is {@code "-"},
-     * or contains a character which is not legal.
-     *
-     * @exception UnsupportedOperationException if the specified
-     * {@code mbeanServerName} cannot be set.
-     *
-     * @since 1.7
-     */
-    public static MBeanServer newNamedMBeanServer(String mbeanServerName,
-            String domain)  {
-        return newMBeanServer(mbeanServerName, domain);
-    }
-
-    private static MBeanServer createMBeanServer(String mbeanServerName,
-            String domain)  {
-        checkPermission("createMBeanServer");
-
-        final MBeanServer mBeanServer =
-                newMBeanServer(mbeanServerName,domain);
-        addMBeanServer(mBeanServer);
-        return mBeanServer;
-    }
-
-    private static MBeanServer newMBeanServer(String mbeanServerName,
-            String domain) {
         checkPermission("newMBeanServer");
 
         // Get the builder. Creates a new one if necessary.
@@ -516,22 +324,6 @@
                         "returned null";
                 throw new JMRuntimeException(msg);
             }
-
-            // Sets the name on the delegate. For complex backward
-            // compatibility reasons it is not possible to give the
-            // name to the MBeanServerDelegate constructor.
-            //
-            // The method setMBeanServerName() will call getMBeanServerId()
-            // to check that the name is accurately set in the MBeanServerId.
-            // If not (which could happen if a custom MBeanServerDelegate
-            // implementation overrides getMBeanServerId() and was not updated
-            // with respect to JMX 2.0 spec, this method will throw an
-            // IllegalStateException...
-            //
-            if (!Util.isMBeanServerNameUndefined(mbeanServerName)) {
-                delegate.setMBeanServerName(mbeanServerName);
-            }
-
             final MBeanServer mbeanServer =
                     mbsBuilder.newMBeanServer(domain,null,delegate);
             if (mbeanServer == null) {
@@ -539,20 +331,6 @@
                         "MBeanServerBuilder.newMBeanServer() returned null";
                 throw new JMRuntimeException(msg);
             }
-
-            // double check that the MBeanServer name is correctly set.
-            // "*" might mean that the caller doesn't have the permission
-            // to see the MBeanServer name.
-            //
-            final String mbsName = Util.getMBeanServerSecurityName(mbeanServer);
-            if (!mbsName.equals(Util.checkServerName(mbeanServerName))
-                && !mbsName.equals("*")) {
-                throw new UnsupportedOperationException(
-                        "can't create MBeanServer with name \""+
-                        mbeanServerName+"\" using "+
-                        builder.getClass().getName());
-            }
-
             return mbeanServer;
         }
     }
@@ -594,96 +372,6 @@
     }
 
     /**
-     * <p>Returns a list of registered MBeanServer objects with the given name.  A
-     * registered MBeanServer object is one that was created by one of
-     * the <code>createMBeanServer</code> or <code>createNamedMBeanServer</code>
-     * methods and not subsequently released with <code>releaseMBeanServer</code>.</p>
-     * <p>See the section about <a href="#MBeanServerName">MBean Server names</a>
-     * above.</p>
-     *
-     * @param mbeanServerName The name of the MBeanServer to
-     * retrieve.  If this parameter is null, all registered MBeanServers
-     * in this JVM are returned.
-     * Otherwise, only those MBeanServers that have a name
-     * matching <code>mbeanServerName</code> are returned: this
-     * parameter can be a pattern, where {@code '*'} matches any
-     * sequence of characters and {@code '?'} matches any character.<br>
-     * The name of an MBeanServer, if specified, is embedded in the
-     * <code>MBeanServerId</code> attribute of its delegate MBean:
-     * this method will parse the <code>MBeanServerId</code> to get the
-     * MBeanServer name. If this parameter is equal to {@code "*"} then
-     * all registered MBeanServers in this JVM are returned, whether they have
-     * a name or not: {@code findMBeanServerByName(null)},
-     * {@code findMBeanServerByName("*")} and {@code findMBeanServer(null)},
-     * are equivalent. It is also possible to get all MBeanServers for which
-     * no name was specified by calling <code>findMBeanServerByName({@value
-     * #DEFAULT_MBEANSERVER_NAME})</code>.
-     *
-     * @return A list of MBeanServer objects.
-     *
-     * @exception SecurityException if there is a SecurityManager and the
-     * caller's permissions do not include or imply <code>{@link
-     * MBeanServerPermission}("findMBeanServer")</code>.
-     *
-     * @see #getMBeanServerName(MBeanServer)
-     * @since 1.7
-     */
-    public synchronized static
-            List<MBeanServer> findMBeanServerByName(String mbeanServerName) {
-
-        checkPermission("findMBeanServer");
-
-        if (mbeanServerName==null || "*".equals(mbeanServerName))
-            return new ArrayList<MBeanServer>(mBeanServerList);
-
-        // noname=true iff we are looking for MBeanServers for which no name
-        // were specified.
-        ArrayList<MBeanServer> result = new ArrayList<MBeanServer>();
-        for (MBeanServer mbs : mBeanServerList) {
-            final String name = Util.getMBeanServerSecurityName(mbs);
-            if (Util.wildmatch(name, mbeanServerName)) result.add(mbs);
-        }
-        return result;
-    }
-
-    /**
-     * Returns the name of the MBeanServer embedded in the MBeanServerId of
-     * the given {@code server}. If the given MBeanServerId doesn't contain
-     * any name, {@value #DEFAULT_MBEANSERVER_NAME} is returned.
-     * The MBeanServerId is expected to be of the form:
-     * {@code *[;mbeanServerName=<mbeanServerName>[;*]]}
-     * <br>where {@code *} denotes any sequence of characters, and {@code [ ]}
-     * indicate optional parts.
-     * </p>
-     * <p>For instance, if an MBeanServer is created using {@link
-     * #createNamedMBeanServer(java.lang.String, java.lang.String)
-     * server =
-     * MBeanServerFactory.createNamedMBeanServer("com.mycompany.myapp.server1",
-     * null)} then {@code MBeanServerFactory.getMBeanServerName(server)}
-     * will return {@code "com.mycompany.myapp.server1"} and
-     * <code>server.getAttribute({@link
-     * javax.management.MBeanServerDelegate#DELEGATE_NAME
-     * MBeanServerDelegate.DELEGATE_NAME}, "MBeanServerId")</code> will return
-     * something like
-     * {@code "myhost_1213353064145;mbeanServerName=com.mycompany.myapp.server1"}.
-     * </p>
-     * <p>See the section about <a href="#MBeanServerName">MBean Server names</a>
-     * above.</p>
-     * @param  server A named (or unnamed) MBeanServer.
-     * @return the name of the MBeanServer if found, or
-     *         {@value #DEFAULT_MBEANSERVER_NAME} if no name is
-     *         present in its MBeanServerId, or "*" if its
-     *         MBeanServerId couldn't be obtained. Returning "*" means that
-     *         only {@link MBeanPermission}s that allow all MBean Server names
-     *         will apply to this MBean Server.
-     * @see MBeanServerDelegate
-     * @since 1.7
-     */
-    public static String getMBeanServerName(MBeanServer server) {
-        return Util.getMBeanServerSecurityName(server);
-    }
-
-    /**
      * Return the ClassLoaderRepository used by the given MBeanServer.
      * This method is equivalent to {@link
      * MBeanServer#getClassLoaderRepository() server.getClassLoaderRepository()}.
--- a/src/share/classes/javax/management/MBeanServerInvocationHandler.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanServerInvocationHandler.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,9 +33,6 @@
 import java.lang.reflect.Proxy;
 import java.util.Arrays;
 import java.util.WeakHashMap;
-import javax.management.openmbean.MXBeanMappingFactory;
-
-import static javax.management.JMX.MBeanOptions;
 
 /**
  * <p>{@link InvocationHandler} that forwards methods in an MBean's
@@ -114,7 +111,7 @@
     public MBeanServerInvocationHandler(MBeanServerConnection connection,
                                         ObjectName objectName) {
 
-        this(connection, objectName, null);
+        this(connection, objectName, false);
     }
 
     /**
@@ -141,14 +138,6 @@
     public MBeanServerInvocationHandler(MBeanServerConnection connection,
                                         ObjectName objectName,
                                         boolean isMXBean) {
-        this(connection, objectName, isMXBean ? MBeanOptions.MXBEAN : null);
-    }
-
-    public MBeanServerInvocationHandler(MBeanServerConnection connection,
-                                        ObjectName objectName,
-                                        MBeanOptions options) {
-        if (options == null)
-            options = new MBeanOptions();
         if (connection == null) {
             throw new IllegalArgumentException("Null connection");
         }
@@ -157,7 +146,7 @@
         }
         this.connection = connection;
         this.objectName = objectName;
-        this.options = options.canonical();
+        this.isMXBean = isMXBean;
     }
 
     /**
@@ -193,16 +182,7 @@
      * @since 1.6
      */
     public boolean isMXBean() {
-        return options.isMXBean();
-    }
-
-    /**
-     * <p>Return the {@link MBeanOptions} used for this proxy.</p>
-     *
-     * @return the MBeanOptions.
-     */
-    public MBeanOptions getMBeanOptions() {
-        return options.uncanonical();
+        return isMXBean;
     }
 
     /**
@@ -346,40 +326,30 @@
          */
     }
 
-    private MXBeanProxy findMXBeanProxy(Class<?> mxbeanInterface) {
-        MXBeanMappingFactory mappingFactory = options.getMXBeanMappingFactory();
+    private static MXBeanProxy findMXBeanProxy(Class<?> mxbeanInterface) {
         synchronized (mxbeanProxies) {
-            ClassToProxy classToProxy = mxbeanProxies.get(mappingFactory);
-            if (classToProxy == null) {
-                classToProxy = new ClassToProxy();
-                mxbeanProxies.put(mappingFactory, classToProxy);
+            WeakReference<MXBeanProxy> proxyRef =
+                    mxbeanProxies.get(mxbeanInterface);
+            MXBeanProxy p = (proxyRef == null) ? null : proxyRef.get();
+            if (p == null) {
+                try {
+                    p = new MXBeanProxy(mxbeanInterface);
+                } catch (IllegalArgumentException e) {
+                    String msg = "Cannot make MXBean proxy for " +
+                            mxbeanInterface.getName() + ": " + e.getMessage();
+                    IllegalArgumentException iae =
+                            new IllegalArgumentException(msg, e.getCause());
+                    iae.setStackTrace(e.getStackTrace());
+                    throw iae;
+                }
+                mxbeanProxies.put(mxbeanInterface,
+                                  new WeakReference<MXBeanProxy>(p));
             }
-            WeakReference<MXBeanProxy> wr = classToProxy.get(mxbeanInterface);
-            MXBeanProxy p;
-            if (wr != null) {
-                p = wr.get();
-                if (p != null)
-                    return p;
-            }
-            try {
-                p = new MXBeanProxy(mxbeanInterface, mappingFactory);
-            } catch (IllegalArgumentException e) {
-                String msg = "Cannot make MXBean proxy for " +
-                        mxbeanInterface.getName() + ": " + e.getMessage();
-                throw new IllegalArgumentException(msg, e.getCause());
-            }
-            classToProxy.put(mxbeanInterface, new WeakReference<MXBeanProxy>(p));
             return p;
         }
     }
-    private static final WeakHashMap<MXBeanMappingFactory, ClassToProxy>
-            mxbeanProxies = newWeakHashMap();
-    private static class ClassToProxy
-            extends WeakHashMap<Class<?>, WeakReference<MXBeanProxy>> {}
-
-    private static <K, V> WeakHashMap<K, V> newWeakHashMap() {
-        return new WeakHashMap<K, V>();
-    }
+    private static final WeakHashMap<Class<?>, WeakReference<MXBeanProxy>>
+            mxbeanProxies = new WeakHashMap<Class<?>, WeakReference<MXBeanProxy>>();
 
     private Object invokeBroadcasterMethod(Object proxy, Method method,
                                            Object[] args) throws Exception {
@@ -523,5 +493,5 @@
 
     private final MBeanServerConnection connection;
     private final ObjectName objectName;
-    private final MBeanOptions options;
+    private final boolean isMXBean;
 }
--- a/src/share/classes/javax/management/MBeanServerNotification.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MBeanServerNotification.java	Wed Nov 25 11:08:25 2009 -0800
@@ -64,13 +64,13 @@
  *     mbeanServer.addNotificationListener(
  *             MBeanServerDelegate.DELEGATE_NAME, printListener, null, null);
  * </pre>
+ *
  * <p id="group">
  * An MBean which is not an {@link MBeanServerDelegate} may also emit
- * MBeanServerNotifications. In particular, a custom subclass of the
- * {@link javax.management.namespace.JMXDomain JMXDomain} MBean or a custom
- * subclass of the {@link javax.management.namespace.JMXNamespace JMXNamespace}
- * MBean may emit an MBeanServerNotification for a group of MBeans.<br>
- * An MBeanServerNotification emitted to denote the registration or
+ * MBeanServerNotifications. In particular, there is a convention for
+ * MBeans to emit an MBeanServerNotification for a group of MBeans.</p>
+ *
+ * <p>An MBeanServerNotification emitted to denote the registration or
  * unregistration of a group of MBeans has the following characteristics:
  * <ul><li>Its {@linkplain Notification#getType() notification type} is
  *     {@code "JMX.mbean.registered.group"} or
@@ -92,58 +92,6 @@
  * declare them in their {@link MBeanInfo#getNotifications()
  * MBeanNotificationInfo}.
  * </p>
- * <P>
- * To receive a group MBeanServerNotification, you need to register a listener
- * with the MBean that emits it. For instance, assuming that the {@link
- * javax.management.namespace.JMXNamespace JMXNamespace} MBean handling
- * namespace {@code "foo"} has declared that it emits such a notification,
- * you will need to register your notification listener with that MBean, which
- * will be named {@link
- * javax.management.namespace.JMXNamespaces#getNamespaceObjectName(java.lang.String)
- * foo//:type=JMXNamespace}.
- * </p>
- * <p>The following code prints a message every time a group of MBean is
- * registered or unregistered in the namespace {@code "foo"}, assumimg its
- * {@link javax.management.namespace.JMXNamespace handler} supports
- * group MBeanServerNotifications:</p>
- *
- * <pre>
- * private static final NotificationListener printListener = new NotificationListener() {
- *     public void handleNotification(Notification n, Object handback) {
- *         if (!(n instanceof MBeanServerNotification)) {
- *             System.out.println("Ignored notification of class " + n.getClass().getName());
- *             return;
- *         }
- *         MBeanServerNotification mbsn = (MBeanServerNotification) n;
- *         String what;
- *         ObjectName[] names = null;
- *         if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION)) {
- *             what = "MBean registered";
- *         } else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION)) {
- *             what = "MBean unregistered";
- *         } else if (n.getType().equals(MBeanServerNotification.REGISTRATION_NOTIFICATION+".group")) {
- *             what = "Group of MBeans registered matching";
- *             if (mbsn.getUserData() instanceof ObjectName[])
- *                names =  (ObjectName[]) mbsn.getUserData();
- *         } else if (n.getType().equals(MBeanServerNotification.UNREGISTRATION_NOTIFICATION+".group")) {
- *             what = "Group of MBeans unregistered matching";
- *             if (mbsn.getUserData() instanceof ObjectName[])
- *                names = (ObjectName[]) mbsn.getUserData();
- *         } else
- *             what = "Unknown type " + n.getType();
- *         System.out.println("Received MBean Server notification: " + what + ": " +
- *                 mbsn.getMBeanName());
- *         if (names != null) {
- *              for (ObjectName mb : names)
- *                  System.out.println("\t"+mb);
- *         }
- *     }
- * };
- *
- * ...
- *     mbeanServer.addNotificationListener(
- *             JMXNamespaces.getNamespaceObjectName("foo"), printListener, null, null);
- * </pre>
  *
  * @since 1.5
  */
--- a/src/share/classes/javax/management/MXBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/MXBean.java	Wed Nov 25 11:08:25 2009 -0800
@@ -27,7 +27,6 @@
 
 import java.lang.annotation.Documented;
 import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
@@ -44,10 +43,6 @@
 import javax.management.openmbean.CompositeDataSupport;
 import javax.management.openmbean.CompositeDataView;
 import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.MXBeanMapping;
-import javax.management.openmbean.MXBeanMappingClass;
-import javax.management.openmbean.MXBeanMappingFactory;
-import javax.management.openmbean.MXBeanMappingFactoryClass;
 import javax.management.openmbean.OpenDataException;
 import javax.management.openmbean.OpenMBeanInfo;
 import javax.management.openmbean.OpenType;
@@ -57,13 +52,11 @@
 import javax.management.openmbean.TabularType;
 
 /**
-    <p>Annotation to mark a class or interface explicitly as being an MXBean,
-    or as not being an MXBean.  By default, an
+    <p>Annotation to mark an interface explicitly as being an MXBean
+    interface, or as not being an MXBean interface.  By default, an
     interface is an MXBean interface if its name ends with {@code
-    MXBean}, as in {@code SomethingMXBean}.  A class is never an MXBean by
-    default.</p>
-
-    <p>The following interfaces are MXBean interfaces:</p>
+    MXBean}, as in {@code SomethingMXBean}.  The following interfaces
+    are MXBean interfaces:</p>
 
     <pre>
     public interface WhatsitMXBean {}
@@ -84,12 +77,7 @@
     public interface MisleadingMXBean {}
     </pre>
 
-    <p>A class can be annotated with {@code @MXBean} to indicate that it
-    is an MXBean.  In this case, its methods should have <code>&#64;{@link
-    ManagedAttribute}</code> or <code>&#64;{@link ManagedOperation}</code>
-    annotations, as described for <code>&#64;{@link MBean}</code>.</p>
-
-    <h3 id="MXBean-spec">MXBean specification</h3>
+    <h3 id="MXBean-spec">MXBean specification</a></h3>
 
     <p>The MXBean concept provides a simple way to code an MBean
       that only references a predefined set of types, the ones defined
@@ -486,11 +474,7 @@
       from type <em>opendata(J)</em> to type <em>J</em>, a null value is
       mapped to a null value.</p>
 
-    <p>In addition to the default type mapping rules, you can specify
-      custom type mappings, as described <a
-      href="#custom">below</a>.</p>
-
-    <p>The following table summarizes the default type mapping rules.</p>
+    <p>The following table summarizes the type mapping rules.</p>
 
     <table border="1" cellpadding="5">
       <tr>
@@ -1051,77 +1035,6 @@
 }
 </pre>
 
-    <p>Alternatively, you can define a custom mapping for your recursive
-      type; see the next section.</p>
-
-    <h3 id="custom">Custom MXBean type mappings</h3>
-
-    <p>You can augment or replace the default type mappings described
-      above with custom mappings.  An example appears in the
-      documentation for {@link MXBeanMapping}.</p>
-
-    <p>If an MXBean uses custom mappings, then an MXBean proxy for
-      that MXBean must use the same mappings for correct behavior.
-      This requires more careful synchronization between client and
-      server than is necessary with the default mappings.  For example
-      it typically requires the client to have the same implementation
-      of any {@link MXBeanMapping} subclasses as the server.  For this
-      reason, custom mappings should be avoided if possible.</p>
-
-    <p>Every MXBean has an associated {@link MXBeanMappingFactory}.
-      Call this <code><em>f</em></code>.  Then every type that appears
-      in that MXBean has an associated {@link MXBeanMapping}
-      determined by <code><em>f</em></code>.  If the type is
-      <code><em>J</em></code>, say, then the mapping is {@link
-      MXBeanMappingFactory#mappingForType
-      <em>f</em>.mappingForType}<code>(<em>J</em>,
-      <em>f</em>)</code>.</p>
-
-    <p>The {@code MXBeanMappingFactory} <code><em>f</em></code> for an
-      MXBean is determined as follows.</p>
-
-    <ul>
-      <li><p>If a {@link JMX.MBeanOptions} argument is supplied to
-          the {@link StandardMBean} constructor that makes an MXBean,
-          or to the {@link JMX#newMBeanProxy(MBeanServerConnection,
-          ObjectName, Class, JMX.MBeanOptions) JMX.newMBeanProxy}
-          method, and the {@code MBeanOptions} object defines a non-null
-          {@code MXBeanMappingFactory}, then that is the value of
-          <code><em>f</em></code>.</p></li>
-
-      <li><p>Otherwise, if the MXBean interface has an {@link
-          MXBeanMappingFactoryClass} annotation, then that annotation
-          must identify a subclass of {@code MXBeanMappingFactory}
-          with a no-argument constructor.  Then
-          <code><em>f</em></code> is the result of calling this
-          constructor.  If the class does not have a no-argument
-          constructor, or if calling the constructor produces an
-          exception, then the MXBean is invalid and an attempt to
-          register it in the MBean Server will produce a {@link
-          NotCompliantMBeanException}.</p>
-
-        <p>This annotation is not inherited from any parent
-          interfaces.  If an MXBean interface has this annotation,
-          then usually any MXBean subinterfaces must repeat the same
-          annotation for correct behavior.</p></li>
-
-      <li><p>Otherwise, if the package in which the MXBean interface
-          appears has an {@code MXBeanMappingFactoryClass} annotation,
-          then <code><em>f</em></code> is determined as if that
-          annotation appeared on the MXBean interface.</p></li>
-
-      <li><p>Otherwise, <code><em>f</em></code> is the default mapping
-          factory, {@link MXBeanMappingFactory#DEFAULT}.</p></li>
-    </ul>
-
-    <p>The default mapping factory recognizes the {@link
-      MXBeanMappingClass} annotation on a class or interface.  If
-      <code><em>J</em></code> is a class or interface that has such an
-      annotation, then the {@code MXBeanMapping} for
-      <code><em>J</em></code> produced by the default mapping factory
-      will be determined by the value of the annotation as described
-      in its {@linkplain MXBeanMappingClass documentation}.</p>
-
     <h3>MBeanInfo contents for an MXBean</h3>
 
     <p>An MXBean is a type of Open MBean.  However, for compatibility
@@ -1250,29 +1163,12 @@
       appropriate), or <em>C</em> is true of <em>e</em>.{@link
       Throwable#getCause() getCause()}".</p>
 
-   @see MXBeanMapping
-
    @since 1.6
 */
 
-/*
- * This annotation is @Inherited because if an MXBean is defined as a
- * class using annotations, then its subclasses are also MXBeans.
- * For example:
- * @MXBean
- * public class Super {
- *     @ManagedAttribute
- *     public String getName() {...}
- * }
- * public class Sub extends Super {}
- * Here Sub is an MXBean.
- *
- * The @Inherited annotation has no effect when applied to an interface.
- */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
-@Inherited
 public @interface MXBean {
     /**
        True if the annotated interface is an MXBean interface.
--- a/src/share/classes/javax/management/ManagedAttribute.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>Indicates that a method in an MBean class defines an MBean attribute.
- * This annotation must be applied to a public method of a public class
- * that is itself annotated with an {@link MBean @MBean} or
- * {@link MXBean @MXBean} annotation, or inherits such an annotation from
- * a superclass.</p>
- *
- * <p>The annotated method must be a getter or setter.  In other words,
- * it must look like one of the following...</p>
- *
- * <pre>
- * <i>T</i> get<i>Foo</i>()
- * void set<i>Foo</i>(<i>T</i> param)
- * </pre>
- *
- * <p>...where <i>{@code T}</i> is any type and <i>{@code Foo}</i> is the
- * name of the attribute.  For any attribute <i>{@code Foo}</i>, if only
- * a {@code get}<i>{@code Foo}</i> method has a {@code ManagedAttribute}
- * annotation, then <i>{@code Foo}</i> is a read-only attribute.  If only
- * a {@code set}<i>{@code Foo}</i> method has a {@code ManagedAttribute}
- * annotation, then <i>{@code Foo}</i> is a write-only attribute.  If
- * both {@code get}<i>{@code Foo}</i> and {@code set}<i>{@code Foo}</i>
- * methods have the annotation, then <i>{@code Foo}</i> is a read-write
- * attribute.  In this last case, the type <i>{@code T}</i> must be the
- * same in both methods.</p>
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-@Documented
-public @interface ManagedAttribute {
-}
--- a/src/share/classes/javax/management/ManagedOperation.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>Indicates that a method in an MBean class defines an MBean operation.
- * This annotation can be applied to:</p>
- *
- * <ul>
- * <li>A public method of a public class
- * that is itself annotated with an {@link MBean @MBean} or
- * {@link MXBean @MXBean} annotation, or inherits such an annotation from
- * a superclass.</li>
- * <li>A method of an MBean or MXBean interface.
- * </ul>
- *
- * <p>Every method in an MBean or MXBean interface defines an MBean
- * operation even without this annotation, but the annotation allows
- * you to specify the impact of the operation:</p>
- *
- * <pre>
- * public interface ConfigurationMBean {
- *     {@code @ManagedOperation}(impact = {@link Impact#ACTION Impact.ACTION})
- *     public void save();
- *     ...
- * }
- * </pre>
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-@Documented
-public @interface ManagedOperation {
-    /**
-     * <p>The impact of this operation, as shown by
-     * {@link MBeanOperationInfo#getImpact()}.
-     */
-    Impact impact() default Impact.UNKNOWN;
-}
--- a/src/share/classes/javax/management/NotQueryExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/NotQueryExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -90,10 +90,4 @@
     public String toString()  {
         return "not (" + exp + ")";
     }
-
-    @Override
-    String toQueryString() {
-        return "not (" + Query.toString(exp) + ")";
-    }
-
  }
--- a/src/share/classes/javax/management/Notification.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/Notification.java	Wed Nov 25 11:08:25 2009 -0800
@@ -54,7 +54,7 @@
  * @since 1.5
  */
 @SuppressWarnings("serial")  // serialVersionUID is not constant
-public class Notification extends EventObject implements Cloneable {
+public class Notification extends EventObject {
 
     // Serialization compatibility stuff:
     // Two serial forms are supported in this class. The selected form depends
@@ -244,26 +244,6 @@
     }
 
     /**
-     * <p>Creates and returns a copy of this object.  The copy is created as
-     * described for {@link Object#clone()}.  This means, first, that the
-     * class of the object will be the same as the class of this object, and,
-     * second, that the copy is a "shallow copy".  Fields of this notification
-     * are not themselves copied.  In particular, the {@linkplain
-     * #getUserData user data} of the copy is the same object as the
-     * original.</p>
-     *
-     * @return a copy of this object.
-     */
-    @Override
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    /**
      * Sets the source.
      *
      * @param source the new source for this object.
@@ -341,24 +321,12 @@
      *
      * @return The message string of this notification object.
      *
-     * @see #setMessage
      */
     public String getMessage() {
         return message ;
     }
 
     /**
-     * Set the notification message.
-     *
-     * @param message the new notification message.
-     *
-     * @see #getMessage
-     */
-    public void setMessage(String message) {
-        this.message = message;
-    }
-
-    /**
      * Get the user data.
      *
      * @return The user data object. It is used for whatever data
--- a/src/share/classes/javax/management/NotificationBroadcasterSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/NotificationBroadcasterSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-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
@@ -58,8 +58,7 @@
  *
  * @since 1.5
  */
-public class NotificationBroadcasterSupport
-        implements NotificationEmitter, SendNotification {
+public class NotificationBroadcasterSupport implements NotificationEmitter {
     /**
      * Constructs a NotificationBroadcasterSupport where each listener is invoked by the
      * thread sending the notification. This constructor is equivalent to
@@ -249,26 +248,6 @@
             }
         }
     }
-    /**
-     * Returns true if there are any listeners.
-     *
-     * @return true if there is at least one listener that has been added with
-     * {@code addNotificationListener} and not subsequently removed with
-     * {@code removeNotificationListener} or {@code removeAllNotificationListeners}.
-     * @since 1.7
-     */
-    public boolean isListenedTo() {
-        return listenerList.size() > 0;
-    }
-
-    /**
-     * Removes all listeners.
-     *
-     * @since 1.7
-     */
-    public void removeAllNotificationListeners() {
-        listenerList.clear();
-    }
 
     /**
      * <p>This method is called by {@link #sendNotification
--- a/src/share/classes/javax/management/NotificationInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>Specifies the kinds of notification an MBean can emit.  In both the
- * following examples, the MBean emits notifications of type
- * {@code "com.example.notifs.create"} and of type
- * {@code "com.example.notifs.destroy"}:</p>
- *
- * <pre>
- * // Example one: a Standard MBean
- * {@code @NotificationInfo}(types={"com.example.notifs.create",
- *                          "com.example.notifs.destroy"})
- * public interface CacheMBean {...}
- *
- * public class Cache
- *         extends NotificationBroadcasterSupport implements CacheMBean {
- *     public Cache() {
- *         super();   // do not supply any MBeanNotificationInfo[]
- *     }
- *     ...
- * }
- * </pre>
- *
- * <pre>
- * // Example two: an annotated MBean
- * {@link MBean @MBean}
- * {@code @NotificationInfo}(types={"com.example.notifs.create",
- *                          "com.example.notifs.destroy"})
- * public class Cache {
- *     <a href="MBeanRegistration.html#injection">{@code @Resource}</a>
- *     private volatile SendNotification sendNotification;
- *     ...
- * }
- * </pre>
- *
- * <p>Each {@code @NotificationInfo} produces an {@link
- * MBeanNotificationInfo} inside the {@link MBeanInfo} of each MBean
- * to which the annotation applies.</p>
- *
- * <p>If you need to specify different notification classes, or different
- * descriptions for different notification types, then you can group
- * several {@code @NotificationInfo} annotations into a containing
- * {@link NotificationInfos @NotificationInfos} annotation.
- *
- * <p>The {@code @NotificationInfo} and {@code @NotificationInfos} annotations
- * are ignored on an MBean that is not a {@linkplain JMX#isNotificationSource
- * notification source} or that implements {@link NotificationBroadcaster} and
- * returns a non-empty array from its {@link
- * NotificationBroadcaster#getNotificationInfo() getNotificationInfo()}
- * method.</p>
- *
- * <p>The {@code NotificationInfo} and {@code NotificationInfos}
- * annotations can be applied to the MBean implementation class, or to
- * any parent class or interface.  These annotations on a class take
- * precedence over annotations on any superclass or superinterface.
- * If an MBean does not have these annotations on its class or any
- * superclass, then superinterfaces are examined.  It is an error for
- * more than one superinterface to have these annotations, unless one
- * of them is a descendant of all the others; registering such an erroneous
- * MBean will cause a {@link NotCompliantMBeanException}.</p>
- */
-@Documented
-@Inherited
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface NotificationInfo {
-    /**
-     * <p>The {@linkplain Notification#getType() notification types}
-     * that this MBean can emit.</p>
-     */
-    String[] types();
-
-    /**
-     * <p>The class that emitted notifications will have.  It is recommended
-     * that this be {@link Notification}, or one of its standard subclasses
-     * in the JMX API.</p>
-     */
-    Class<? extends Notification> notificationClass() default Notification.class;
-
-    /**
-     * <p>The description of this notification.  For example:
-     *
-     * <pre>
-     * {@code @NotificationInfo}(
-     *         types={"com.example.notifs.create"},
-     *         description={@code @Description}("object created"))
-     * </pre>
-     */
-    Description description() default @Description("");
-
-    /**
-     * <p>Additional descriptor fields for the derived {@code
-     * MBeanNotificationInfo}.  They are specified in the same way as
-     * for the {@link DescriptorFields @DescriptorFields} annotation,
-     * for example:</p>
-     * <pre>
-     * {@code @NotificationInfo}(
-     *         types={"com.example.notifs.create"},
-     *         descriptorFields={"severity=6"})
-     * </pre>
-     */
-    String[] descriptorFields() default {};
-}
--- a/src/share/classes/javax/management/NotificationInfos.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.management.remote.JMXConnectionNotification;
-
-/**
- * <p>Specifies the kinds of notification an MBean can emit, when this
- * cannot be represented by a single {@link NotificationInfo
- * &#64;NotificationInfo} annotation.</p>
- *
- * <p>For example, this annotation specifies that an MBean can emit
- * {@link AttributeChangeNotification} and {@link
- * JMXConnectionNotification}:</p>
- *
- * <pre>
- * {@code @NotificationInfos}(
- *     {@code @NotificationInfo}(
- *         types = {{@link AttributeChangeNotification#ATTRIBUTE_CHANGE}},
- *         notificationClass = AttributeChangeNotification.class),
- *     {@code @NotificationInfo}(
- *         types = {{@link JMXConnectionNotification#OPENED},
- *                  {@link JMXConnectionNotification#CLOSED}},
- *         notificationClass = JMXConnectionNotification.class)
- * )
- * </pre>
- *
- * <p>If an MBean has both {@code NotificationInfo} and {@code
- * NotificationInfos} on the same class or interface, the effect is
- * the same as if the {@code NotificationInfo} were moved inside the
- * {@code NotificationInfos}.</p>
- */
-@Documented
-@Inherited
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface NotificationInfos {
-    /**
-     * <p>The {@link NotificationInfo} annotations.</p>
-     */
-    NotificationInfo[] value();
-}
--- a/src/share/classes/javax/management/ObjectName.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/ObjectName.java	Wed Nov 25 11:08:25 2009 -0800
@@ -27,8 +27,6 @@
 
 import com.sun.jmx.mbeanserver.GetPropertyAction;
 import com.sun.jmx.mbeanserver.Util;
-import com.sun.jmx.namespace.serial.JMXNamespaceContext;
-
 import java.io.IOException;
 import java.io.InvalidObjectException;
 import java.io.ObjectInputStream;
@@ -56,38 +54,14 @@
  * properties.</p>
  *
  * <p>The <em>domain</em> is a string of characters not including
- * the character colon (<code>:</code>).</p>
- * <p>Starting with the version 2.0 of the JMX specification, the
- * <em>domain</em> can also start with a {@linkplain
- * javax.management.namespace#NamespacePrefix namespace prefix} identifying
- * the {@linkplain javax.management.namespace namespace} in which the
- * MBean is registered. A namespace prefix is a path string where
- * elements are separated by a double slash (<code>//</code>).
- * It identifies the {@linkplain  javax.management.namespace namespace} in
- * which the MBean so named is registered.</p>
- *
- * <p>For instance the ObjectName <em>bar//baz:k=v</em> identifiies an MBean
- * named <em>baz:k=v</em> in the namespace <em>bar</em>. Similarly the
- * ObjectName <em>foo//bar//baz:k=v</em> identifiies an MBean named
- * <em>baz:k=v</em> in the namespace <em>foo//bar</em>. See the {@linkplain
- * javax.management.namespace namespace} documentation for more details.</p>
+ * the character colon (<code>:</code>).  It is recommended that the domain
+ * should not contain the string "{@code //}", which is reserved for future use.
  *
  * <p>If the domain includes at least one occurrence of the wildcard
  * characters asterisk (<code>*</code>) or question mark
  * (<code>?</code>), then the object name is a pattern.  The asterisk
  * matches any sequence of zero or more characters, while the question
- * mark matches any single character. <br>
- * A namespace separator <code>//</code> does not match wildcard
- * characters unless it is at the very end of the domain string.
- * So <em>foo*bar*:*</em> does not match <em>foo//bar:k=v</em> but it
- * does match <em>fooxbar//:k=v</em>.
- * </p>
- *
- * <p>When included in a namespace path the special path element
- * <code>**</code> matches any number of sub namespaces
- * recursively, but only if used as a complete namespace path element,
- * as in <code>*&#42;//b//c//D:k=v</code> or <code>a//*&#42;//c//D:k=v</code>
- * - see <a href="#metawildcard">below</a>.
+ * mark matches any single character.</p>
  *
  * <p>If the domain is empty, it will be replaced in certain contexts
  * by the <em>default domain</em> of the MBean server in which the
@@ -195,51 +169,6 @@
  *     with {@code \}.</li>
  * </ul>
  *
- * <p id="metawildcard"><b>Pattern and namespaces:</b></p>
- * <p>In an object name pattern, a path element
- *    of exactly <code>**</code> corresponds to a meta
- *    wildcard that will match any number of sub namespaces.<br>Hence:</p>
- * <table border="0" cellpadding="5">
- * <thead><th>pattern</th><th>matches</th><th>doesn't match</th></thead>
- * <tbody>
- * <tr><td><ul><li><code>*&#42;//D:k=v</code></li></ul></td>
- *     <td><code>a//D:k=v</code><br>
- *         <code>a//b//D:k=v</code><br>
- *         <code>a//b//c//D:k=v</code></td>
- *     <td><code>D:k=v</code></td></tr>
- * <tr><td><ul><li><code>a//*&#42;//D:k=v</code></li></ul></td>
- *     <td><code>a//b//D:k=v</code><br>
- *         <code>a//b//c//D:k=v</code></td>
- *     <td><code>b//b//c//D:k=v</code><br>
- *         <code>a//D:k=v</code><br>
- *         <code>D:k=v</code></td></tr>
- * <tr><td><ul><li><code>a//*&#42;//e//D:k=v</code></li></ul></td>
- *     <td><code>a//b//e//D:k=v</code><br>
- *         <code>a//b//c//e//D:k=v</code></td>
- *     <td><code>a//b//c//c//D:k=v</code><br>
- *         <code>b//b//c//e//D:k=v</code><br>
- *         <code>a//e//D:k=v</code><br>
- *         <code>e//D:k=v</code></td></tr>
- * <tr><td><ul><li><code>a//b*&#42;//e//D:k=v</code></li></ul></td>
- *      <td><code>a//b//e//D:k=v</code></td>
- *      <td><code>a//b//c//e//D:k=v</code><br>
- *          because in that case <code>b*&#42;</code><br>
- *         is not a meta-wildcard - and <code>b**</code><br>
- *         is thus equivalent to <code>b*</code>.</td></tr>
- * </tbody>
- * </table>
- *</ul>
- * </p>
- * <p>
- * <b>Note:</b> Although ObjectName patterns where the characters
- * <code>*</code> and <code>?</code> appear in the namespace path are legal,
- * they are not valid in the {@code name} parameter of the MBean Server's
- * {@link MBeanServer#queryNames queryNames} and {@link MBeanServer#queryMBeans
- * queryMBeans} methods. See the
- * <a href="namespace/package-summary.html#RejectedNamespacePatterns"><!--
- * -->namespaces documentation</a> for more details.
- * </p>
- *
  * <p>An ObjectName can be written as a String with the following
  * elements in order:</p>
  *
@@ -294,17 +223,6 @@
 public class ObjectName implements Comparable<ObjectName>, QueryExp {
 
     /**
-     * The sequence of characters used to separate name spaces in a name space
-     * path.
-     *
-     * @see javax.management.namespace
-     * @since 1.7
-     **/
-    public static final String NAMESPACE_SEPARATOR = "//";
-    private static final int NAMESPACE_SEPARATOR_LENGTH =
-            NAMESPACE_SEPARATOR.length();
-
-    /**
      * A structure recording property structure and
      * proposing minimal services
      */
@@ -333,17 +251,16 @@
         /**
          * Returns a key string for receiver key
          */
-        String getKeyString(String name, int offset) {
-            final int start = _key_index+offset;
-            return name.substring(start, start + _key_length);
+        String getKeyString(String name) {
+            return name.substring(_key_index, _key_index + _key_length);
         }
 
         /**
          * Returns a value string for receiver key
          */
-        String getValueString(String name, int offset) {
-            final int in_begin = _key_index + offset + _key_length + 1;
-            final int out_end = in_begin + _value_length;
+        String getValueString(String name) {
+            int in_begin = _key_index + _key_length + 1;
+            int out_end = in_begin + _value_length;
             return name.substring(in_begin, out_end);
         }
     }
@@ -476,40 +393,6 @@
      */
     private transient boolean _property_value_pattern = false;
 
-    private ObjectName(String newDomain, ObjectName aname)
-        throws MalformedObjectNameException{
-        copyToOtherDomain(newDomain,aname);
-    }
-
-    private void copyToOtherDomain(String domain, ObjectName aname)
-        throws MalformedObjectNameException {
-
-        // The domain cannot be null
-        if (domain == null)
-            throw new NullPointerException("domain cannot be null");
-
-        // The key property list cannot be null
-        if (aname == null)
-            throw new MalformedObjectNameException(
-                        "key property list cannot be empty");
-
-        // checks domain validity. A side effect of this method is also to
-        // set the _domain_pattern flag.
-        if (!isDomain(domain))
-            throw new MalformedObjectNameException("Invalid domain: " + domain);
-
-        // init canonicalname
-        _domain_length = domain.length();
-
-        _canonicalName = (domain +
-             aname._canonicalName.substring(aname._domain_length)).intern();
-        _kp_array = aname._kp_array;
-        _ca_array = aname._ca_array;
-        _propertyList = aname._propertyList;
-        _property_list_pattern = aname._property_list_pattern;
-        _property_value_pattern = aname._property_value_pattern;
-    }
-
     // Instance private fields <=======================================
 
     // Private fields <========================================
@@ -754,12 +637,10 @@
 
             // we got the key and value part, prepare a property for this
             if (!value_pattern) {
-                prop = new Property(key_index-_domain_length,
-                                    key_length, value_length);
+                prop = new Property(key_index, key_length, value_length);
             } else {
                 _property_value_pattern = true;
-                prop = new PatternProperty(key_index-_domain_length,
-                                    key_length, value_length);
+                prop = new PatternProperty(key_index, key_length, value_length);
             }
             key_name = name.substring(key_index, key_index + key_length);
 
@@ -844,12 +725,12 @@
             boolean value_pattern = checkValue(value);
             sb.append(value);
             if (!value_pattern) {
-                prop = new Property(key_index-_domain_length,
+                prop = new Property(key_index,
                                     key.length(),
                                     value.length());
             } else {
                 _property_value_pattern = true;
-                prop = new PatternProperty(key_index-_domain_length,
+                prop = new PatternProperty(key_index,
                                            key.length(),
                                            value.length());
             }
@@ -929,9 +810,9 @@
                 prop = _ca_array[i];
                 // length of prop including '=' char
                 prop_len = prop._key_length + prop._value_length + 1;
-                System.arraycopy(specified_chars, prop._key_index+_domain_length,
+                System.arraycopy(specified_chars, prop._key_index,
                                  canonical_chars, prop_index, prop_len);
-                prop.setKeyIndex(prop_index-_domain_length);
+                prop.setKeyIndex(prop_index);
                 prop_index += prop_len;
                 if (i != last_index) {
                     canonical_chars[prop_index] = ',';
@@ -1268,37 +1149,15 @@
             cn = (String)in.readObject();
         }
 
-        final JMXNamespaceContext ctxt =
-                JMXNamespaceContext.getDeserializationContext();
         try {
-            construct(changeContext(ctxt,cn));
+            construct(cn);
         } catch (NullPointerException e) {
             throw new InvalidObjectException(e.toString());
-        } catch (IllegalArgumentException e) {
-            throw new InvalidObjectException(e.toString());
         } catch (MalformedObjectNameException e) {
             throw new InvalidObjectException(e.toString());
         }
     }
 
-    private String changeContext(JMXNamespaceContext context, String nameString) {
-        final String old = context.prefixToRemove;
-        final String nw  = context.prefixToAdd;
-        final int ol = old.length();
-        if (nameString.startsWith(NAMESPACE_SEPARATOR)) return nameString;
-        if (ol>0) {
-            if (!nameString.startsWith(old) ||
-                    !nameString.startsWith(NAMESPACE_SEPARATOR,ol))
-                throw new IllegalArgumentException(
-                        "Serialized ObjectName does not start with " + old +
-                        ": " + nameString);
-            nameString = nameString.substring(ol+NAMESPACE_SEPARATOR_LENGTH);
-        }
-        if (!nw.equals("")) {
-            nameString = nw + NAMESPACE_SEPARATOR + nameString;
-        }
-        return nameString;
-    }
 
     /**
      * Serializes an {@link ObjectName} to an {@link ObjectOutputStream}.
@@ -1361,22 +1220,15 @@
     private void writeObject(ObjectOutputStream out)
             throws IOException {
 
-      final JMXNamespaceContext ctxt =
-                JMXNamespaceContext.getSerializationContext();
-
       if (compat)
       {
         // Serializes this instance in the old serial form
         // Read CR 6441274 before making any changes to this code
         ObjectOutputStream.PutField fields = out.putFields();
-        final String domain =
-                changeContext(ctxt,_canonicalName.substring(0, _domain_length));
-        final String cn =
-                changeContext(ctxt,_canonicalName);
-        fields.put("domain", domain);
+        fields.put("domain", _canonicalName.substring(0, _domain_length));
         fields.put("propertyList", getKeyPropertyList());
         fields.put("propertyListString", getKeyPropertyListString());
-        fields.put("canonicalName", cn);
+        fields.put("canonicalName", _canonicalName);
         fields.put("pattern", (_domain_pattern || _property_list_pattern));
         fields.put("propertyPattern", _property_list_pattern);
         out.writeFields();
@@ -1386,8 +1238,7 @@
         // Serializes this instance in the new serial form
         //
         out.defaultWriteObject();
-
-        out.writeObject(changeContext(ctxt,getSerializedNameString()));
+        out.writeObject(getSerializedNameString());
       }
     }
 
@@ -1416,10 +1267,9 @@
      * @exception NullPointerException The <code>name</code> parameter
      * is null.
      *
-     * @see #valueOf(String)
      */
     public static ObjectName getInstance(String name)
-            throws MalformedObjectNameException {
+            throws MalformedObjectNameException, NullPointerException {
         return new ObjectName(name);
     }
 
@@ -1444,7 +1294,6 @@
      * follow the rules for quoting.
      * @exception NullPointerException One of the parameters is null.
      *
-     * @see #valueOf(String, String, String)
      */
     public static ObjectName getInstance(String domain, String key,
                                          String value)
@@ -1476,7 +1325,6 @@
      * quoting.
      * @exception NullPointerException One of the parameters is null.
      *
-     * @see #valueOf(String, Hashtable)
      */
     public static ObjectName getInstance(String domain,
                                          Hashtable<String,String> table)
@@ -1516,143 +1364,7 @@
     public static ObjectName getInstance(ObjectName name) {
         if (name.getClass().equals(ObjectName.class))
             return name;
-        return valueOf(name.getSerializedNameString());
-    }
-
-    /**
-     * <p>Return an instance of ObjectName that can be used anywhere
-     * an object obtained with {@link #ObjectName(String) new
-     * ObjectName(name)} can be used.  The returned object may be of
-     * a subclass of ObjectName.  Calling this method twice with the
-     * same parameters may return the same object or two equal but
-     * not identical objects.</p>
-     *
-     * <p>This method is equivalent to {@link #getInstance(String)} except that
-     * it does not throw any checked exceptions.</p>
-     *
-     * @param name  A string representation of the object name.
-     *
-     * @return an ObjectName corresponding to the given String.
-     *
-     * @exception IllegalArgumentException The string passed as a
-     * parameter does not have the right format.  The {@linkplain
-     * Throwable#getCause() cause} of this exception will be a
-     * {@link MalformedObjectNameException}.
-     * @exception NullPointerException The <code>name</code> parameter
-     * is null.
-     *
-     * @since 1.7
-     */
-    public static ObjectName valueOf(String name) {
-        try {
-            return getInstance(name);
-        } catch (MalformedObjectNameException e) {
-            throw new IllegalArgumentException(e.getMessage(), e);
-            // Just plain IllegalArgumentException(e) produces an exception
-            // message "javax.management.MalformedObjectNameException: ..."
-            // which is distracting.
-        }
-    }
-
-    /**
-     * <p>Return an instance of ObjectName that can be used anywhere
-     * an object obtained with {@link #ObjectName(String, String,
-     * String) new ObjectName(domain, key, value)} can be used.  The
-     * returned object may be of a subclass of ObjectName.  Calling
-     * this method twice with the same parameters may return the same
-     * object or two equal but not identical objects.</p>
-     *
-     * <p>This method is equivalent to {@link #getInstance(String, String,
-     * String)} except that it does not throw any checked exceptions.</p>
-     *
-     * @param domain  The domain part of the object name.
-     * @param key  The attribute in the key property of the object name.
-     * @param value The value in the key property of the object name.
-     *
-     * @return an ObjectName corresponding to the given domain,
-     * key, and value.
-     *
-     * @exception IllegalArgumentException The
-     * <code>domain</code>, <code>key</code>, or <code>value</code>
-     * contains an illegal character, or <code>value</code> does not
-     * follow the rules for quoting.  The {@linkplain
-     * Throwable#getCause() cause} of this exception will be a
-     * {@link MalformedObjectNameException}.
-     * @exception NullPointerException One of the parameters is null.
-     *
-     * @since 1.7
-     */
-    public static ObjectName valueOf(String domain, String key, String value) {
-        try {
-            return getInstance(domain, key, value);
-        } catch (MalformedObjectNameException e) {
-            throw new IllegalArgumentException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * <p>Return an instance of ObjectName that can be used anywhere
-     * an object obtained with {@link #ObjectName(String, Hashtable)
-     * new ObjectName(domain, table)} can be used.  The returned
-     * object may be of a subclass of ObjectName.  Calling this method
-     * twice with the same parameters may return the same object or
-     * two equal but not identical objects.</p>
-     *
-     * <p>This method is equivalent to {@link #getInstance(String, Hashtable)}
-     * except that it does not throw any checked exceptions.</p>
-     *
-     * @param domain  The domain part of the object name.
-     * @param table A hash table containing one or more key
-     * properties.  The key of each entry in the table is the key of a
-     * key property in the object name.  The associated value in the
-     * table is the associated value in the object name.
-     *
-     * @return an ObjectName corresponding to the given domain and
-     * key mappings.
-     *
-     * @exception IllegalArgumentException The <code>domain</code>
-     * contains an illegal character, or one of the keys or values in
-     * <code>table</code> contains an illegal character, or one of the
-     * values in <code>table</code> does not follow the rules for
-     * quoting.  The {@linkplain Throwable#getCause() cause} of this exception
-     * will be a {@link MalformedObjectNameException}.
-     * @exception NullPointerException One of the parameters is null.
-     *
-     * @since 1.7
-     */
-    public static ObjectName valueOf(String domain,
-                                     Hashtable<String,String> table) {
-        try {
-            return new ObjectName(domain, table);
-        } catch (MalformedObjectNameException e) {
-            throw new IllegalArgumentException(e.getMessage(), e);
-        }
-    }
-
-    /**
-     * Returns an {@code ObjectName} that is the same as this one but
-     * with the specified domain.
-     * This method preserves the original key order in the new instance.
-     * If the provided name has a key property pattern, it will also be
-     * preserved in the returned instance.
-     *
-     * @param newDomain The new domain for the returned instance;
-     *        must not be null.
-     * @return A new {@code ObjectName} that is the same as {@code this}
-     *         except the domain is {@code newDomain}.
-     * @throws NullPointerException if {@code newDomain} is null.
-     * @exception IllegalArgumentException The {@code newDomain} passed as a
-     * parameter does not have the right format.  The {@linkplain
-     * Throwable#getCause() cause} of this exception will be a
-     * {@link MalformedObjectNameException}.
-     * @since 1.7
-     **/
-    public final ObjectName withDomain(String newDomain) {
-        try {
-            return new ObjectName(newDomain, this);
-        } catch (MalformedObjectNameException x) {
-            throw new IllegalArgumentException(x.getMessage(),x);
-        }
+        return Util.newObjectName(name.getSerializedNameString());
     }
 
     /**
@@ -1664,8 +1376,6 @@
      * parameter does not have the right format.
      * @exception NullPointerException The <code>name</code> parameter
      * is null.
-     *
-     * @see #valueOf(String)
      */
     public ObjectName(String name)
         throws MalformedObjectNameException {
@@ -1684,8 +1394,6 @@
      * contains an illegal character, or <code>value</code> does not
      * follow the rules for quoting.
      * @exception NullPointerException One of the parameters is null.
-     *
-     * @see #valueOf(String, String, String)
      */
     public ObjectName(String domain, String key, String value)
         throws MalformedObjectNameException {
@@ -1711,8 +1419,6 @@
      * values in <code>table</code> does not follow the rules for
      * quoting.
      * @exception NullPointerException One of the parameters is null.
-     *
-     * @see #valueOf(String, Hashtable)
      */
     public ObjectName(String domain, Hashtable<String,String> table)
             throws MalformedObjectNameException {
@@ -1814,7 +1520,7 @@
             throw new NullPointerException("key property can't be null");
         for (int i = 0; i < _ca_array.length; i++) {
             Property prop = _ca_array[i];
-            String key = prop.getKeyString(_canonicalName,_domain_length);
+            String key = prop.getKeyString(_canonicalName);
             if (key.equals(property))
                 return (prop instanceof PatternProperty);
         }
@@ -1894,10 +1600,8 @@
                 Property prop;
                 for (int i = len - 1; i >= 0; i--) {
                     prop = _ca_array[i];
-                    _propertyList.put(prop.getKeyString(_canonicalName,
-                                            _domain_length),
-                                      prop.getValueString(_canonicalName,
-                                            _domain_length));
+                    _propertyList.put(prop.getKeyString(_canonicalName),
+                                      prop.getValueString(_canonicalName));
                 }
             }
         }
@@ -1982,8 +1686,7 @@
             }
         }
 
-        final String name = new String(dest_chars);
-        return name;
+        return new String(dest_chars);
     }
 
     /**
@@ -2009,7 +1712,7 @@
         for (int i = 0; i < len; i++) {
             final Property prop = _kp_array[i];
             final int prop_len = prop._key_length + prop._value_length + 1;
-            System.arraycopy(value, prop._key_index+_domain_length, dest_chars, index,
+            System.arraycopy(value, prop._key_index, dest_chars, index,
                              prop_len);
             index += prop_len;
             if (i < last ) dest_chars[index++] = ',';
@@ -2054,10 +1757,6 @@
         return getSerializedNameString();
     }
 
-    String toQueryString() {
-        return "like " + Query.value(toString());
-    }
-
     /**
      * Compares the current object name with another object name.  Two
      * ObjectName instances are equal if and only if their canonical
@@ -2218,7 +1917,7 @@
      *
      * @since 1.6
      */
-    public static final ObjectName WILDCARD = valueOf("*:*");
+    public static final ObjectName WILDCARD = Util.newObjectName("*:*");
 
     // Category : Utilities <===================================
 
@@ -2264,7 +1963,7 @@
             // wildmatch domains
             // This ObjectName is the pattern
             // The other ObjectName is the string.
-            return Util.wildpathmatch(name.getDomain(),getDomain());
+            return Util.wildmatch(name.getDomain(),getDomain());
         }
         return getDomain().equals(name.getDomain());
     }
@@ -2290,7 +1989,7 @@
                 // index in receiver
                 //
                 final Property p = props[i];
-                final String   k = p.getKeyString(cn,_domain_length);
+                final String   k = p.getKeyString(cn);
                 final String   v = nameProps.get(k);
                 // Did we find a value for this key ?
                 //
@@ -2300,12 +1999,12 @@
                 if (_property_value_pattern && (p instanceof PatternProperty)) {
                     // wildmatch key property values
                     // p is the property pattern, v is the string
-                    if (Util.wildmatch(v,p.getValueString(cn,_domain_length)))
+                    if (Util.wildmatch(v,p.getValueString(cn)))
                         continue;
                     else
                         return false;
                 }
-                if (v.equals(p.getValueString(cn,_domain_length))) continue;
+                if (v.equals(p.getValueString(cn))) continue;
                 return false;
             }
             return true;
--- a/src/share/classes/javax/management/ObjectNameTemplate.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * 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 javax.management;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Annotation to allow an MBean to provide its name.
- * This annotation can be used on the following types:
- * <ul>
- *   <li>MBean or MXBean Java interface.</li>
- *   <li>Java class annotated with {@link javax.management.MBean &#64;MBean}</code>
- * annotation.</li>
- *   <li>Java class annotated with {@link javax.management.MXBean &#64;MXBean}</code>
- * annotation.</li>
- * </ul>
- *
- * <p>The value of this annotation is used to build the <code>ObjectName</code>
- * when instances of the annotated type are registered in
- * an <code>MBeanServer</code> and no explicit name is given to the
- * {@code createMBean} or {@code registerMBean} method (the {@code ObjectName}
- * is {@code null}).</p>
- *
- * <p>For Dynamic MBeans, which define their own {@code MBeanInfo}, you can
- * produce the same effect as this annotation by including a field
- * <a href="Descriptor.html#objectNameTemplate">{@code objectNameTemplate}</a>
- * in the {@link Descriptor} for the {@code MBeanInfo} returned by
- * {@link DynamicMBean#getMBeanInfo()}.</p>
- *
- * <p>For Standard MBeans and MXBeans, this annotation automatically produces
- * an {@code objectNameTemplate} field in the {@code Descriptor}.</p>
- *
- * <p>The template can contain variables so that the name of the MBean
- * depends on the value of one or more of its attributes.
- * A variable that identifies an MBean attribute is of the form
- * <code>{<em>attribute name</em>}</code>. For example, to make an MBean name
- * depend on the <code>Name</code> attribute, use the variable
- * <code>{Name}</code>. Attribute names are case sensitive.
- * Naming attributes can be of any type. The <code>String</code> returned by
- * <code>toString()</code> is included in the constructed name.</p>
- *
- * <p>If you need the attribute value to be quoted
- * by a call to {@link ObjectName#quote(String) ObjectName.quote},
- * surround the variable with quotes. Quoting only applies to key values.
- * For example, <code>@ObjectNameTemplate("java.lang:type=MemoryPool,name=\"{Name}\"")</code>,
- * quotes the <code>Name</code> attribute value. You can notice the "\"
- * character needed to escape a quote within a <code>String</code>. A name
- * produced by this template might look like
- * {@code java.lang:type=MemoryPool,name="Code Cache"}.</p>
- *
- * <p>Variables can be used anywhere in the <code>String</code>.
- * Be sure to make the template derived name comply with
- * {@link ObjectName ObjectName} syntax.</p>
- *
- * <p>If an MBean is registered with a null name and it implements
- * {@link javax.management.MBeanRegistration MBeanRegistration}, then
- * the computed name is provided to the <code>preRegister</code> method.
- * Similarly,
- * if the MBean uses <a href="MBeanRegistration.html#injection">resource
- * injection</a> to discover its name, it is the computed name that will
- * be injected.</p>
- * <p>All of the above can be used with the {@link StandardMBean} class and
- * the annotation is effective in that case too.</p>
- * <p>If any exception occurs (such as unknown attribute, invalid syntax or
- * exception
- * thrown by the MBean) when the name is computed it is wrapped in a
- * <code>NotCompliantMBeanException</code>.</p>
- * <p>Some ObjectName template examples:
- * <ul><li>"com.example:type=Memory". Fixed ObjectName. Used to name a
- * singleton MBean.</li>
- * <li>"com.example:type=MemoryPool,name={Name}". Variable ObjectName.
- * <code>Name</code> attribute is retrieved to compose the <code>name</code>
- * key value.</li>
- * <li>"com.example:type=SomeType,name={InstanceName},id={InstanceId}".
- * Variable ObjectName.
- * <code>InstanceName</code> and <code>InstanceId</code> attributes are
- * retrieved to compose respectively
- * the <code>name</code> and <code>id</code> key values.</li>
- * <li>"com.example:type=OtherType,name=\"{ComplexName}\"". Variable ObjectName.
- * <code>ComplexName</code> attribute is retrieved to compose the
- * <code>name</code> key quoted value.</li> </li>
- * <li>"com.example:{TypeKey}=SomeOtherType". Variable ObjectName.
- * <code>TypeKey</code> attribute is retrieved to compose the
- * first key name.</li>
- * * <li>"{Domain}:type=YetAnotherType". Variable ObjectName.
- * <code>Domain</code> attribute is retrieved to compose the
- * management domain.</li>
- * <li>"{Naming}". Variable ObjectName.
- * <code>Naming</code> attribute is retrieved to compose the
- * complete name.</li>
- * </ul>
- * </p>
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface ObjectNameTemplate {
-
-    /**
-     * The MBean name template.
-     * @return The MBean name template.
-     */
-    @DescriptorKey("objectNameTemplate")
-    public String value();
-}
--- a/src/share/classes/javax/management/OrQueryExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/OrQueryExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -104,24 +104,4 @@
     public String toString() {
         return "(" + exp1 + ") or (" + exp2 + ")";
     }
-
-    @Override
-    String toQueryString() {
-        return parens(exp1) + " or " + parens(exp2);
-    }
-
-    // Add parentheses to avoid possible confusion.  If we have an expression
-    // such as Query.or(Query.and(a, b), c), then we return
-    // (a and b) or c
-    // rather than just
-    // a and b or c
-    // In fact the precedence rules are such that the parentheses are not
-    // strictly necessary, but omitting them would be confusing.
-    private static String parens(QueryExp exp) {
-        String s = Query.toString(exp);
-        if (exp instanceof AndQueryExp)
-            return "(" + s + ")";
-        else
-            return s;
-    }
 }
--- a/src/share/classes/javax/management/QualifiedAttributeValueExp.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/QualifiedAttributeValueExp.java	Wed Nov 25 11:08:25 2009 -0800
@@ -113,8 +113,7 @@
     @Override
     public String toString()  {
         if (className != null) {
-            return QueryParser.quoteId(className) + "#" +
-                QueryParser.quoteId(super.toString());
+            return className + "." + super.toString();
         } else {
             return super.toString();
         }
--- a/src/share/classes/javax/management/Query.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/Query.java	Wed Nov 25 11:08:25 2009 -0800
@@ -40,14 +40,6 @@
  * but the methods in this class return only standard classes that are
  * part of the JMX implementation.</p>
  *
- * <p>There are two ways to create {@code QueryExp} objects using the methods
- * in this class.  The first is to build them by chaining together calls to
- * the various methods.  The second is to use the Query Language described
- * <a href="#ql">below</a> and produce the {@code QueryExp} by calling
- * {@link #fromString Query.fromString}.  The two ways are equivalent:
- * every {@code QueryExp} returned by {@code fromString} can also be
- * constructed by chaining method calls.</p>
- *
  * <p>As an example, suppose you wanted to find all MBeans where the {@code
  * Enabled} attribute is {@code true} and the {@code Owner} attribute is {@code
  * "Duke"}. Here is how you could construct the appropriate {@code QueryExp} by
@@ -59,307 +51,6 @@
  *               Query.eq(Query.attr("Owner"), Query.value("Duke")));
  * </pre>
  *
- * <p>Here is how you could construct the same {@code QueryExp} using the
- * Query Language:</p>
- *
- * <pre>
- * QueryExp query = Query.fromString("Enabled = true and Owner = 'Duke'");
- * </pre>
- *
- * <p>The principal advantage of the method-chaining approach is that the
- * compiler will check that the query makes sense.  The principal advantage
- * of the Query Language approach is that it is easier to write and especially
- * read.</p>
- *
- *
- * <h4 id="ql">Query Language</h4>
- *
- * <p>The query language is closely modeled on the WHERE clause of
- * SQL SELECT statements. The formal specification of the language
- * appears <a href="#formal-ql">below</a>, but it is probably easier to
- * understand it with examples such as the following.</p>
- *
- * <dl>
- * <dt>{@code Message = 'OK'}
- * <dd>Selects MBeans that have a {@code Message} attribute whose value
- *     is the string {@code OK}.
- *
- * <dt>{@code FreeSpacePercent < 10}
- * <dd>Selects MBeans that have a {@code FreeSpacePercent} attribute whose
- *     value is a number less than 10.
- *
- * <dt>{@code FreeSpacePercent < 10 and WarningSent = false}
- * <dd>Selects the same MBeans as the previous example, but they must
- *     also have a boolean attribute {@code WarningSent} whose value
- *     is false.
- *
- * <dt>{@code SpaceUsed > TotalSpace * (2.0 / 3.0)}
- * <dd>Selects MBeans that have {@code SpaceUsed} and {@code TotalSpace}
- *     attributes where the first is more than two-thirds the second.
- *
- * <dt>{@code not (FreeSpacePercent between 10 and 90)}
- * <dd>Selects MBeans that have a {@code FreeSpacePercent} attribute whose
- *     value is not between 10 and 90, inclusive.
- *
- * <dt>{@code FreeSpacePercent not between 10 and 90}
- * <dd>Another way of writing the previous query.
- *
- * <dt>{@code Status in ('STOPPED', 'STARTING', 'STARTED')}
- * <dd>Selects MBeans that have a {@code Status} attribute whose value
- *     is one of those three strings.
- *
- * <dt>{@code Message like 'OK: *'}
- * <dd>Selects MBeans that have a {@code Message} attribute whose value
- *     is a string beginning with {@code "OK: "}.  <b>Notice that the
- *     wildcard characters are not the ones that SQL uses.</b>  In SQL,
- *     {@code %} means "any sequence of characters" and {@code _}
- *     means "any single character".  Here, as in the rest of the JMX API,
- *     those are represented by {@code *} and {@code ?} respectively.
- *
- * <dt>{@code instanceof 'javax.management.NotificationBroadcaster'}
- * <dd>Selects MBeans that are instances of
- *     {@link javax.management.NotificationBroadcaster}, as reported by
- *     {@link javax.management.MBeanServer#isInstanceOf MBeanServer.isInstanceOf}.
- *
- * <dt>{@code like 'mydomain:*'}
- * <dd>Selects MBeans whose {@link ObjectName}s have the domain {@code mydomain}.
- *
- * </dl>
- *
- * <p>The last two examples do not correspond to valid SQL syntax, but all
- * the others do.</p>
- *
- * <p>The remainder of this description is a formal specification of the
- * query language.</p>
- *
- *
- * <h4 id="formal-ql">Lexical elements</h4>
- *
- * <p>Keywords such as <b>and</b>, <b>like</b>, and <b>between</b> are not
- * case sensitive.  You can write <b>between</b>, <b>BETWEEN</b>, or
- * <b>BeTwEeN</b> with the same effect.</p>
- *
- * <p>On the other hand, attribute names <i>are</i> case sensitive.  The
- * attribute {@code Name} is not the same as the attribute {@code name}.</p>
- *
- * <p>To access an attribute whose name, ignoring case, is the same as one of
- * the keywords {@code not}, {@code instanceof}, {@code like}, {@code true},
- * or {@code false}, you can use double quotes, for example {@code "not"}.
- * Double quotes can also be used to include non-identifier characters in
- * the name of an attribute, for example {@code "attribute-name-with-hyphens"}.
- * To include the double quote character in the attribute name, write it
- * twice.  {@code "foo""bar""baz"} represents the attribute called
- * {@code foo"bar"baz}.
- *
- * <p>String constants are written with single quotes like {@code 'this'}.  A
- * single quote within a string constant must be doubled, for example
- * {@code 'can''t'}.</p>
- *
- * <p>Integer constants are written as a sequence of decimal digits,
- * optionally preceded by a plus or minus sign.  An integer constant must be
- * a valid input to {@link Long#valueOf(String)}.</p>
- *
- * <p>Floating-point constants are written using the Java syntax.  A
- * floating-point constant must be a valid input to
- * {@link Double#valueOf(String)}.</p>
- *
- * <p>A boolean constant is either {@code true} or {@code false}, ignoring
- * case.</p>
- *
- * <p>Spaces cannot appear inside identifiers (unless written with double
- * quotes) or keywords or multi-character tokens such as {@code <=}. Spaces can
- * appear anywhere else, but are not required except to separate tokens. For
- * example, the query {@code a < b and 5 = c} could also be written {@code a<b
- * and 5=c}, but no further spaces can be removed.</p>
- *
- *
- * <h4 id="grammar-ql">Grammar</h4>
- *
- * <dl>
- * <dt id="query">query:
- * <dd><a href="#andquery">andquery</a> [<b>OR</b> <a href="#query">query</a>]
- *
- * <dt id="andquery">andquery:
- * <dd><a href="#predicate">predicate</a> [<b>AND</b> <a href="#andquery">andquery</a>]
- *
- * <dt id="predicate">predicate:
- * <dd><b>(</b> <a href="#query">query</a> <b>)</b> |<br>
- *     <b>NOT</b> <a href="#predicate">predicate</a> |<br>
- *     <b>INSTANCEOF</b> <a href="#stringvalue">stringvalue</a> |<br>
- *     <b>LIKE</b> <a href="#objectnamepattern">objectnamepattern</a> |<br>
- *     <a href="#value">value</a> <a href="#predrhs">predrhs</a>
- *
- * <dt id="predrhs">predrhs:
- * <dd><a href="#compare">compare</a> <a href="#value">value</a> |<br>
- *     [<b>NOT</b>] <b>BETWEEN</b> <a href="#value">value</a> <b>AND</b>
- *         <a href="#value">value</a> |<br>
- *     [<b>NOT</b>] <b>IN (</b> <a href="#value">value</a>
- *           <a href="#commavalues">commavalues</a> <b>)</b> |<br>
- *     [<b>NOT</b>] <b>LIKE</b> <a href="#stringvalue">stringvalue</a>
- *
- * <dt id="commavalues">commavalues:
- * <dd>[ <b>,</b> <a href="#value">value</a> <a href="#commavalues">commavalues</a> ]
- *
- * <dt id="compare">compare:
- * <dd><b>=</b> | <b>&lt;</b> | <b>&gt;</b> |
- *     <b>&lt;=</b> | <b>&gt;=</b> | <b>&lt;&gt;</b> | <b>!=</b>
- *
- * <dt id="value">value:
- * <dd><a href="#factor">factor</a> [<a href="#plusorminus">plusorminus</a>
- *     <a href="#value">value</a>]
- *
- * <dt id="plusorminus">plusorminus:
- * <dd><b>+</b> | <b>-</b>
- *
- * <dt id="factor">factor:
- * <dd><a href="#term">term</a> [<a href="#timesordivide">timesordivide</a>
- *     <a href="#factor">factor</a>]
- *
- * <dt id="timesordivide">timesordivide:
- * <dd><b>*</b> | <b>/</b>
- *
- * <dt id="term">term:
- * <dd><a href="#attr">attr</a> | <a href="#literal">literal</a> |
- *     <b>(</b> <a href="#value">value</a> <b>)</b>
- *
- * <dt id="attr">attr:
- * <dd><a href="#name">name</a> [<b>#</b> <a href="#name">name</a>]
- *
- * <dt id="name">name:
- * <dd><a href="#identifier">identifier</a> [<b>.</b><a href="#name">name</a>]
- *
- * <dt id="identifier">identifier:
- * <dd><i>Java-identifier</i> | <i>double-quoted-identifier</i>
- *
- * <dt id="literal">literal:
- * <dd><a href="#booleanlit">booleanlit</a> | <i>longlit</i> |
- *     <i>doublelit</i> | <i>stringlit</i>
- *
- * <dt id="booleanlit">booleanlit:
- * <dd><b>FALSE</b> | <b>TRUE</b>
- *
- * <dt id="stringvalue">stringvalue:
- * <dd><i>stringlit</i>
- *
- * <dt id="objectnamepattern">objectnamepattern:
- * <dd><i>stringlit</i>
- *
- * </dl>
- *
- *
- * <h4>Semantics</h4>
- *
- * <p>The meaning of the grammar is described in the table below.
- * This defines a function <i>q</i> that maps a string to a Java object
- * such as a {@link QueryExp} or a {@link ValueExp}.</p>
- *
- * <table border="1" cellpadding="5">
- * <tr><th>String <i>s</i></th><th><i>q(s)</th></tr>
- *
- * <tr><td><i>query1</i> <b>OR</b> <i>query2</i>
- *     <td>{@link Query#or Query.or}(<i>q(query1)</i>, <i>q(query2)</i>)
- *
- * <tr><td><i>query1</i> <b>AND</b> <i>query2</i>
- *     <td>{@link Query#and Query.and}(<i>q(query1)</i>, <i>q(query2)</i>)
- *
- * <tr><td><b>(</b> <i>queryOrValue</i> <b>)</b>
- *     <td><i>q(queryOrValue)</i>
- *
- * <tr><td><b>NOT</b> <i>query</i>
- *     <td>{@link Query#not Query.not}(<i>q(query)</i>)
- *
- * <tr><td><b>INSTANCEOF</b> <i>stringLiteral</i>
- *     <td>{@link Query#isInstanceOf Query.isInstanceOf}(<!--
- * -->{@link Query#value(String) Query.value}(<i>q(stringLiteral)</i>))
- *
- * <tr><td><b>LIKE</b> <i>stringLiteral</i>
- *     <td>{@link ObjectName#ObjectName(String) new ObjectName}(<!--
- * --><i>q(stringLiteral)</i>)
- *
- * <tr><td><i>value1</i> <b>=</b> <i>value2</i>
- *     <td>{@link Query#eq Query.eq}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>&lt;</b> <i>value2</i>
- *     <td>{@link Query#lt Query.lt}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>&gt;</b> <i>value2</i>
- *     <td>{@link Query#gt Query.gt}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>&lt;=</b> <i>value2</i>
- *     <td>{@link Query#leq Query.leq}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>&gt;=</b> <i>value2</i>
- *     <td>{@link Query#geq Query.geq}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>&lt;&gt;</b> <i>value2</i>
- *     <td>{@link Query#not Query.not}({@link Query#eq Query.eq}(<!--
- * --><i>q(value1)</i>, <i>q(value2)</i>))
- *
- * <tr><td><i>value1</i> <b>!=</b> <i>value2</i>
- *     <td>{@link Query#not Query.not}({@link Query#eq Query.eq}(<!--
- * --><i>q(value1)</i>, <i>q(value2)</i>))
- *
- * <tr><td><i>value1</i> <b>BETWEEN</b> <i>value2</i> AND <i>value3</i>
- *     <td>{@link Query#between Query.between}(<i>q(value1)</i>,
- *         <i>q(value2)</i>, <i>q(value3)</i>)
- *
- * <tr><td><i>value1</i> <b>NOT BETWEEN</b> <i>value2</i> AND <i>value3</i>
- *     <td>{@link Query#not Query.not}({@link Query#between Query.between}(<!--
- * --><i>q(value1)</i>, <i>q(value2)</i>, <i>q(value3)</i>))
- *
- * <tr><td><i>value1</i> <b>IN (</b> <i>value2</i>, <i>value3</i> <b>)</b>
- *     <td>{@link Query#in Query.in}(<i>q(value1)</i>,
- *         <code>new ValueExp[] {</code>
- *         <i>q(value2)</i>, <i>q(value3)</i><code>}</code>)
- *
- * <tr><td><i>value1</i> <b>NOT IN (</b> <i>value2</i>, <i>value3</i> <b>)</b>
- *     <td>{@link Query#not Query.not}({@link Query#in Query.in}(<i>q(value1)</i>,
- *         <code>new ValueExp[] {</code>
- *         <i>q(value2)</i>, <i>q(value3)</i><code>}</code>))
- *
- * <tr><td><i>value</i> <b>LIKE</b> <i>stringLiteral</i>
- *     <td>{@link Query#match Query.match}(<i>q(value)</i>,
- *         <i>q(stringLiteral)</i>)
- *
- * <tr><td><i>value</i> <b>NOT LIKE</b> <i>stringLiteral</i>
- *     <td>{@link Query#not Query.not}({@link Query#match Query.match}(<i>q(value)</i>,
- *         <i>q(stringLiteral)</i>))
- *
- * <tr><td><i>value1</i> <b>+</b> <i>value2</i>
- *     <td>{@link Query#plus Query.plus}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>-</b> <i>value2</i>
- *     <td>{@link Query#minus Query.minus}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>*</b> <i>value2</i>
- *     <td>{@link Query#times Query.times}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>value1</i> <b>/</b> <i>value2</i>
- *     <td>{@link Query#div Query.div}(<i>q(value1)</i>, <i>q(value2)</i>)
- *
- * <tr><td><i>name</i>
- *     <td>{@link Query#attr(String) Query.attr}(<i>q(name)</i>)
- *
- * <tr><td><i>name1<b>#</b>name2</i>
- *     <td>{@link Query#attr(String,String) Query.attr}(<i>q(name1)</i>,
- *         <i>q(name2)</i>)
- *
- * <tr><td><b>FALSE</b>
- *     <td>{@link Query#value(boolean) Query.value}(false)
- *
- * <tr><td><b>TRUE</b>
- *     <td>{@link Query#value(boolean) Query.value}(true)
- *
- * <tr><td><i>decimalLiteral</i>
- *     <td>{@link Query#value(long) Query.value}(<!--
- * -->{@link Long#valueOf(String) Long.valueOf}(<i>decimalLiteral</i>))
- *
- * <tr><td><i>floatingPointLiteral</i>
- *     <td>{@link Query#value(double) Query.value}(<!--
- * -->{@link Double#valueOf(String) Double.valueOf}(<!--
- * --><i>floatingPointLiteral</i>))
- * </table>
- *
  * @since 1.5
  */
  public class Query extends Object   {
@@ -600,6 +291,11 @@
       * <p>Returns a new attribute expression.  See {@link AttributeValueExp}
       * for a detailed description of the semantics of the expression.</p>
       *
+      * <p>Evaluating this expression for a given
+      * <code>objectName</code> includes performing {@link
+      * MBeanServer#getAttribute MBeanServer.getAttribute(objectName,
+      * name)}.</p>
+      *
       * @param name The name of the attribute.
       *
       * @return An attribute expression for the attribute named {@code name}.
@@ -944,73 +640,6 @@
      }
 
      /**
-      * <p>Return a string representation of the given query.  The string
-      * returned by this method can be converted back into an equivalent
-      * query using {@link #fromString fromString}.</p>
-      *
-      * <p>(Two queries are equivalent if they produce the same result in
-      * all cases.  Equivalent queries are not necessarily identical:
-      * for example the queries {@code Query.lt(Query.attr("A"), Query.attr("B"))}
-      * and {@code Query.not(Query.ge(Query.attr("A"), Query.attr("B")))} are
-      * equivalent but not identical.)</p>
-      *
-      * <p>The string returned by this method is only guaranteed to be converted
-      * back into an equivalent query if {@code query} was constructed, or
-      * could have been constructed, using the methods of this class.
-      * If you make a custom query {@code myQuery} by implementing
-      * {@link QueryExp} yourself then the result of
-      * {@code Query.toString(myQuery)} is unspecified.</p>
-      *
-      * @param query the query to convert.  If it is null, the result will
-      * also be null.
-      * @return the string representation of the query, or null if the
-      * query is null.
-      *
-      * @since 1.7
-      */
-     public static String toString(QueryExp query) {
-         if (query == null)
-             return null;
-
-         // This is ugly. At one stage we had a non-public class called
-         // ToQueryString with the toQueryString() method, and every class
-         // mentioned here inherited from that class. But that interfered
-         // with serialization of custom subclasses of e.g. QueryEval. Even
-         // though we could make it work by adding a public constructor to this
-         // non-public class, that seemed fragile because according to the
-         // serialization spec it shouldn't work. If only non-public interfaces
-         // could have non-public methods.
-         if (query instanceof ObjectName)
-             return ((ObjectName) query).toQueryString();
-         if (query instanceof QueryEval)
-             return ((QueryEval) query).toQueryString();
-
-         return query.toString();
-     }
-
-     /**
-      * <p>Produce a query from the given string.  The query returned
-      * by this method can be converted back into a string using
-      * {@link #toString(QueryExp) toString}.  The resultant string will
-      * not necessarily be equal to {@code s}.</p>
-      *
-      * @param s the string to convert.
-      *
-      * @return a {@code QueryExp} derived by parsing the string, or
-      * null if the string is null.
-      *
-      * @throws IllegalArgumentException if the string is not a valid
-      * query string.
-      *
-      * @since 1.7
-      */
-     public static QueryExp fromString(String s) {
-         if (s == null)
-             return null;
-         return new QueryParser(s).parseQuery();
-     }
-
-     /**
       * Utility method to escape strings used with
       * Query.{initial|any|final}SubString() methods.
       */
--- a/src/share/classes/javax/management/QueryEval.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/QueryEval.java	Wed Nov 25 11:08:25 2009 -0800
@@ -75,10 +75,4 @@
     public static MBeanServer getMBeanServer() {
         return server.get();
     }
-
-    // Subclasses in this package can override this method to return a different
-    // string.
-    String toQueryString() {
-        return toString();
-    }
 }
--- a/src/share/classes/javax/management/QueryNotificationFilter.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,415 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-import com.sun.jmx.mbeanserver.NotificationMBeanSupport;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * <p>General-purpose notification filter.  This filter can be used to
- * filter notifications from a possibly-remote MBean.  Most filtering
- * decisions can be coded using this filter, which avoids having to
- * write a custom implementation of the {@link NotificationFilter}
- * class.  Writing a custom implementation requires you to deploy it
- * on both the client and the server in the remote case, so using this class
- * instead is recommended where possible.</p>
- *
- * <p>Because this class was introduced in version 2.0 of the JMX API,
- * it may not be present on a remote JMX agent that is running an earlier
- * version.  The method {@link JMX#getSpecificationVersion
- * JMX.getSpecificationVersion} can be used to determine the remote version.</p>
- *
- * <p>This class uses the {@linkplain Query Query API} to specify the
- * filtering logic.  For example, to select only notifications where the
- * {@linkplain Notification#getType() type} is {@code "com.example.mytype"},
- * you could use</p>
- *
- * <pre>
- * NotificationFilter filter =
- *     new QueryNotificationFilter("Type = 'com.example.mytype'");
- * </pre>
- *
- * <p>or equivalently</p>
- *
- * <pre>
- * NotificationFilter filter =
- *     new QueryNotificationFilter(
- *             Query.eq(Query.attr("Type"), Query.value("com.example.mytype")));
- * </pre>
- *
- * <p>(This particular example could also use
- * {@link NotificationFilterSupport}.)</p>
- *
- * <p>Here are some other examples of filters you can specify with this class.</p>
- *
- * <dl>
- *
- * <dt>{@code QueryNotificationFilter("Type = 'com.example.type1' or
- * Type = 'com.example.type2'")}
- * <dd>Notifications where the type is either of the given strings.
- *
- * <dt>{@code QueryNotificationFilter("Type in ('com.example.type1',
- * 'com.example.type2')")}
- * <dd>Another way to write the previous example.
- *
- * <dt>{@code QueryNotificationFilter("SequenceNumber > 1000")}
- * <dd>Notifications where the {@linkplain Notification#getSequenceNumber()
- * sequence number} is greater than 1000.
- *
- * <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class, null)}
- * <dd>Notifications where the notification class is
- * {@link AttributeChangeNotification} or a subclass of it.
- *
- * <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class,
- * "AttributeName = 'Size'")}
- * <dd>Notifications where the notification class is
- * {@link AttributeChangeNotification} or a subclass, and where the
- * {@linkplain AttributeChangeNotification#getAttributeName() name of the
- * changed attribute} is {@code Size}.
- *
- * <dt>{@code QueryNotificationFilter(AttributeChangeNotification.class,
- * "AttributeName = 'Size' and NewValue - OldValue > 100")}
- * <dd>As above, but the difference between the
- * {@linkplain AttributeChangeNotification#getNewValue() new value} and the
- * {@linkplain AttributeChangeNotification#getOldValue() old value} must be
- * greater than 100.
- *
- * <dt>{@code QueryNotificationFilter("like 'com.example.mydomain:*'")}
- * <dd>Notifications where the {@linkplain Notification#getSource() source}
- * is an ObjectName that matches the pattern.
- *
- * <dt>{@code QueryNotificationFilter("Source.canonicalName like
- * 'com.example.mydomain:%'")}
- * <dd>Another way to write the previous example.
- *
- * <dt>{@code QueryNotificationFilter(MBeanServerNotification.class,
- * "Type = 'JMX.mbean.registered' and MBeanName.canonicalName like
- * 'com.example.mydomain:%'")}
- * <dd>Notifications of class {@link MBeanServerNotification} representing
- * an object registered in the domain {@code com.example.mydomain}.
- *
- * </dl>
- *
- * <h4>How it works</h4>
- *
- * <p>Although the examples above are clear, looking closely at the
- * Query API reveals a subtlety.  A {@link QueryExp} is evaluated on
- * an {@link ObjectName}, not a {@code Notification}.</p>
- *
- * <p>Every time a {@code Notification} is to be filtered by a
- * {@code QueryNotificationFilter}, a special {@link MBeanServer} is created.
- * This {@code MBeanServer} contains exactly one MBean, which represents the
- * {@code Notification}.  If the {@linkplain Notification#getSource()
- * source} of the notification is an {@code ObjectName}, which is
- * recommended practice, then the name of the MBean representing the
- * {@code Notification} will be this {@code ObjectName}.  Otherwise the
- * name is unspecified.</p>
- *
- * <p>The query specified in the {@code QueryNotificationFilter} constructor
- * is evaluated against this {@code MBeanServer} and {@code ObjectName},
- * and the filter returns true if and only if the query does.  If the
- * query throws an exception, then the filter will return false.</p>
- *
- * <p>The MBean representing the {@code Notification} has one attribute for
- * every property of the {@code Notification}. Specifically, for every public
- * method {@code T getX()} in the {@code NotificationClass}, the MBean will
- * have an attribute called {@code X} of type {@code T}. For example, if the
- * {@code Notification} is an {@code AttributeChangeNotification}, then the
- * MBean will have an attribute called {@code AttributeName} of type
- * {@code "java.lang.String"}, corresponding to the method {@link
- * AttributeChangeNotification#getAttributeName}.</p>
- *
- * <p>Query evaluation usually involves calls to the methods of {@code
- * MBeanServer}.  The methods have the following behavior:</p>
- *
- * <ul>
- * <li>The {@link MBeanServer#getAttribute getAttribute} method returns the
- * value of the corresponding property.
- * <li>The {@link MBeanServer#getObjectInstance getObjectInstance}
- * method returns an {@link ObjectInstance} where the {@link
- * ObjectInstance#getObjectName ObjectName} is the name of the MBean and the
- * {@link ObjectInstance#getClassName ClassName} is the class name of the
- * {@code Notification}.
- * <li>The {@link MBeanServer#isInstanceOf isInstanceOf} method returns true
- * if and only if the {@code Notification}'s {@code ClassLoader} can load the
- * named class, and the {@code Notification} is an {@linkplain Class#isInstance
- * instance} of that class.
- * </ul>
- *
- * <p>These are the only {@code MBeanServer} methods that are needed to
- * evaluate standard queries. The behavior of the other {@code MBeanServer}
- * methods is unspecified.</p>
- *
- * @since 1.7
- */
-public class QueryNotificationFilter implements NotificationFilter {
-    private static final long serialVersionUID = -8408613922660635231L;
-
-    private static final ObjectName DEFAULT_NAME =
-            ObjectName.valueOf(":type=Notification");
-    private static final QueryExp trueQuery;
-    static {
-        ValueExp zero = Query.value(0);
-        trueQuery = Query.eq(zero, zero);
-    }
-
-    private final QueryExp query;
-
-    /**
-     * Construct a {@code QueryNotificationFilter} that evaluates the given
-     * {@code QueryExp} to determine whether to accept a notification.
-     *
-     * @param query the {@code QueryExp} to evaluate.  Can be null,
-     * in which case all notifications are accepted.
-     */
-    public QueryNotificationFilter(QueryExp query) {
-        if (query == null)
-            this.query = trueQuery;
-        else
-            this.query = query;
-    }
-
-    /**
-     * Construct a {@code QueryNotificationFilter} that evaluates the query
-     * in the given string to determine whether to accept a notification.
-     * The string is converted into a {@code QueryExp} using
-     * {@link Query#fromString Query.fromString}.
-     *
-     * @param query the string specifying the query to evaluate.  Can be null,
-     * in which case all notifications are accepted.
-     *
-      * @throws IllegalArgumentException if the string is not a valid
-      * query string.
-     */
-    public QueryNotificationFilter(String query) {
-        this(Query.fromString(query));
-    }
-
-    /**
-     * <p>Construct a {@code QueryNotificationFilter} that evaluates the query
-     * in the given string to determine whether to accept a notification,
-     * and where the notification must also be an instance of the given class.
-     * The string is converted into a {@code QueryExp} using
-     * {@link Query#fromString Query.fromString}.</p>
-     *
-     * @param notifClass the class that the notification must be an instance of.
-     * Cannot be null.
-     *
-     * @param query the string specifying the query to evaluate.  Can be null,
-     * in which case all notifications are accepted.
-     *
-     * @throws IllegalArgumentException if the string is not a valid
-     * query string, or if {@code notifClass} is null.
-     */
-    public QueryNotificationFilter(
-            Class<? extends Notification> notifClass, String query) {
-        this(Query.and(Query.isInstanceOf(Query.value(notNull(notifClass).getName())),
-                       Query.fromString(query)));
-    }
-
-    private static <T> T notNull(T x) {
-        if (x == null)
-            throw new IllegalArgumentException("Null argument");
-        return x;
-    }
-
-    /**
-     * Retrieve the query that this notification filter will evaluate for
-     * each notification.
-     *
-     * @return the query.
-     */
-    public QueryExp getQuery() {
-        return query;
-    }
-
-    public boolean isNotificationEnabled(Notification notification) {
-        ObjectName name;
-
-        Object source = notification.getSource();
-        if (source instanceof ObjectName)
-            name = (ObjectName) source;
-        else
-            name = DEFAULT_NAME;
-
-        MBS mbsImpl = new MBS(notification, name);
-        MBeanServer mbs = (MBeanServer) Proxy.newProxyInstance(
-                MBeanServer.class.getClassLoader(),
-                new Class<?>[] {MBeanServer.class},
-                new ForwardIH(mbsImpl));
-        return evalQuery(query, mbs, name);
-    }
-
-    private static boolean evalQuery(
-            QueryExp query, MBeanServer mbs, ObjectName name) {
-        MBeanServer oldMBS = QueryEval.getMBeanServer();
-        try {
-            if (mbs != null)
-                query.setMBeanServer(mbs);
-            return query.apply(name);
-        } catch (Exception e) {
-            return false;
-        } finally {
-            query.setMBeanServer(oldMBS);
-        }
-    }
-
-    private static class ForwardIH implements InvocationHandler {
-        private final MBS mbs;
-
-        ForwardIH(MBS mbs) {
-            this.mbs = mbs;
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-                throws Throwable {
-            Method forward;
-            try {
-                forward = MBS.class.getMethod(
-                        method.getName(), method.getParameterTypes());
-            } catch (NoSuchMethodException e) {
-                throw new UnsupportedOperationException(method.getName());
-            }
-            try {
-                return forward.invoke(mbs, args);
-            } catch (InvocationTargetException e) {
-                throw e.getCause();
-            }
-        }
-    }
-
-    private static class MBS {
-        private final Notification notification;
-        private final ObjectName objectName;
-        private final ObjectInstance objectInstance;
-        private volatile DynamicMBean mbean;
-
-        MBS(Notification n, ObjectName name) {
-            this.notification = n;
-            this.objectName = name;
-            this.objectInstance = new ObjectInstance(name, n.getClass().getName());
-        }
-
-        private void checkName(ObjectName name) throws InstanceNotFoundException {
-            if (!objectName.equals(name))
-                throw new InstanceNotFoundException(String.valueOf(name));
-        }
-
-        private DynamicMBean mbean(ObjectName name)
-                throws InstanceNotFoundException, ReflectionException {
-            if (mbean == null) {
-                try {
-                    mbean = new NotificationMBeanSupport(notification);
-                } catch (NotCompliantMBeanException e) {
-                    throw new ReflectionException(e);
-                }
-            }
-            return mbean;
-        }
-
-        public ObjectInstance getObjectInstance(ObjectName name)
-                throws InstanceNotFoundException {
-            checkName(name);
-            return objectInstance;
-        }
-
-        public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
-            Set<ObjectName> names = queryNames(name, query);
-            switch (names.size()) {
-            case 0:
-                return Collections.emptySet();
-            case 1:
-                return Collections.singleton(objectInstance);
-            default:
-                throw new UnsupportedOperationException("Internal error");
-            }
-        }
-
-        public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-            if ((name != null && !name.apply(objectName)) ||
-                    (query != null && !evalQuery(query, null, name)))
-                return Collections.emptySet();
-            return Collections.singleton(objectName);
-        }
-
-        public boolean isRegistered(ObjectName name) {
-            return objectName.equals(name);
-        }
-
-        public Integer getMBeanCount() {
-            return 1;
-        }
-
-        public Object getAttribute(ObjectName name, String attribute)
-                throws MBeanException, AttributeNotFoundException,
-                       InstanceNotFoundException, ReflectionException {
-            return mbean(name).getAttribute(attribute);
-        }
-
-        public AttributeList getAttributes(ObjectName name, String[] attributes)
-                throws InstanceNotFoundException, ReflectionException {
-            return mbean(name).getAttributes(attributes);
-        }
-
-        public String getDefaultDomain() {
-            return objectName.getDomain();
-        }
-
-        public String[] getDomains() {
-            return new String[] {objectName.getDomain()};
-        }
-
-        public MBeanInfo getMBeanInfo(ObjectName name)
-                throws InstanceNotFoundException, ReflectionException {
-            return mbean(name).getMBeanInfo();
-        }
-
-        public boolean isInstanceOf(ObjectName name, String className)
-                throws InstanceNotFoundException {
-            try {
-                mbean(name);
-                ClassLoader loader = notification.getClass().getClassLoader();
-                Class<?> c = Class.forName(className, false, loader);
-                return c.isInstance(notification);
-            } catch (ReflectionException e) {
-                return false;
-            } catch (ClassNotFoundException e) {
-                return false;
-            }
-        }
-
-        public ClassLoader getClassLoaderFor(ObjectName mbeanName)
-                throws InstanceNotFoundException {
-            checkName(mbeanName);
-            return notification.getClass().getClassLoader();
-        }
-    }
-}
--- a/src/share/classes/javax/management/QueryParser.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,626 +0,0 @@
-/*
- * 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 javax.management;
-
-import java.util.ArrayList;
-import java.util.Formatter;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * <p>Parser for JMX queries represented in an SQL-like language.</p>
- */
-/*
- * Note that if a query starts with ( then we don't know whether it is
- * a predicate or just a value that is parenthesized.  So, inefficiently,
- * we try to parse a predicate and if that doesn't work we try to parse
- * a value.
- */
-class QueryParser {
-    // LEXER STARTS HERE
-
-    private static class Token {
-        final String string;
-        Token(String s) {
-            this.string = s;
-        }
-
-        @Override
-        public String toString() {
-            return string;
-        }
-    }
-
-    private static final Token
-            END = new Token("<end of string>"),
-            LPAR = new Token("("), RPAR = new Token(")"),
-            COMMA = new Token(","), DOT = new Token("."), SHARP = new Token("#"),
-            PLUS = new Token("+"), MINUS = new Token("-"),
-            TIMES = new Token("*"), DIVIDE = new Token("/"),
-            LT = new Token("<"), GT = new Token(">"),
-            LE = new Token("<="), GE = new Token(">="),
-            NE = new Token("<>"), EQ = new Token("="),
-            NOT = new Id("NOT"), INSTANCEOF = new Id("INSTANCEOF"),
-            FALSE = new Id("FALSE"), TRUE = new Id("TRUE"),
-            BETWEEN = new Id("BETWEEN"), AND = new Id("AND"),
-            OR = new Id("OR"), IN = new Id("IN"),
-            LIKE = new Id("LIKE"), CLASS = new Id("CLASS");
-
-    // Keywords that can appear where an identifier can appear.
-    // If an attribute is one of these, then it must be quoted when
-    // converting a query into a string.
-    // We use a TreeSet so we can look up case-insensitively.
-    private static final Set<String> idKeywords =
-            new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
-    static {
-        for (Token t : new Token[] {NOT, INSTANCEOF, FALSE, TRUE, LIKE, CLASS})
-            idKeywords.add(t.string);
-    };
-
-    public static String quoteId(String id) {
-        if (id.contains("\"") || idKeywords.contains(id))
-            return '"' + id.replace("\"", "\"\"") + '"';
-        else
-            return id;
-    }
-
-    private static class Id extends Token {
-        Id(String id) {
-            super(id);
-        }
-
-        // All other tokens use object identity, which means e.g. that one
-        // occurrence of the string constant 'x' is not the same as another.
-        // For identifiers, we ignore case when testing for equality so that
-        // for a keyword such as AND you can also spell it as "And" or "and".
-        // But we keep the original case of the identifier, so if it's not
-        // a keyword we will distinguish between the attribute Foo and the
-        // attribute FOO.
-        @Override
-        public boolean equals(Object o) {
-            return (o instanceof Id && (((Id) o).toString().equalsIgnoreCase(toString())));
-        }
-    }
-
-    private static class QuotedId extends Token {
-        QuotedId(String id) {
-            super(id);
-        }
-
-        @Override
-        public String toString() {
-            return '"' + string.replace("\"", "\"\"") + '"';
-        }
-    }
-
-    private static class StringLit extends Token {
-        StringLit(String s) {
-            super(s);
-        }
-
-        @Override
-        public String toString() {
-            return '\'' + string.replace("'", "''") + '\'';
-        }
-    }
-
-    private static class LongLit extends Token {
-        long number;
-
-        LongLit(long number) {
-            super(Long.toString(number));
-            this.number = number;
-        }
-    }
-
-    private static class DoubleLit extends Token {
-        double number;
-
-        DoubleLit(double number) {
-            super(Double.toString(number));
-            this.number = number;
-        }
-    }
-
-    private static class Tokenizer {
-        private final String s;
-        private final int len;
-        private int i = 0;
-
-        Tokenizer(String s) {
-            this.s = s;
-            this.len = s.length();
-        }
-
-        private int thisChar() {
-            if (i == len)
-                return -1;
-            return s.codePointAt(i);
-        }
-
-        private void advance() {
-            i += Character.charCount(thisChar());
-        }
-
-        private int thisCharAdvance() {
-            int c = thisChar();
-            advance();
-            return c;
-        }
-
-        Token nextToken() {
-            // In this method, c is the character we're looking at, and
-            // thisChar() is the character after that.  Everything must
-            // preserve these invariants.  When we return we then have
-            // thisChar() being the start of the following token, so
-            // the next call to nextToken() will begin from there.
-            int c;
-
-            // Skip space
-            do {
-                if (i == len)
-                    return null;
-                c = thisCharAdvance();
-            } while (Character.isWhitespace(c));
-
-            // Now c is the first character of the token, and tokenI points
-            // to the character after that.
-            switch (c) {
-                case '(': return LPAR;
-                case ')': return RPAR;
-                case ',': return COMMA;
-                case '.': return DOT;
-                case '#': return SHARP;
-                case '*': return TIMES;
-                case '/': return DIVIDE;
-                case '=': return EQ;
-                case '-': return MINUS;
-                case '+': return PLUS;
-
-                case '>':
-                    if (thisChar() == '=') {
-                        advance();
-                        return GE;
-                    } else
-                        return GT;
-
-                case '<':
-                    c = thisChar();
-                    switch (c) {
-                        case '=': advance(); return LE;
-                        case '>': advance(); return NE;
-                        default: return LT;
-                    }
-
-                case '!':
-                    if (thisCharAdvance() != '=')
-                        throw new IllegalArgumentException("'!' must be followed by '='");
-                    return NE;
-
-                case '"':
-                case '\'': {
-                    int quote = c;
-                    StringBuilder sb = new StringBuilder();
-                    while (true) {
-                        while ((c = thisChar()) != quote) {
-                            if (c < 0) {
-                                throw new IllegalArgumentException(
-                                        "Unterminated string constant");
-                            }
-                            sb.appendCodePoint(thisCharAdvance());
-                        }
-                        advance();
-                        if (thisChar() == quote) {
-                            sb.appendCodePoint(quote);
-                            advance();
-                        } else
-                            break;
-                    }
-                    if (quote == '\'')
-                        return new StringLit(sb.toString());
-                    else
-                        return new QuotedId(sb.toString());
-                }
-            }
-
-            // Is it a numeric constant?
-            if (Character.isDigit(c) || c == '.') {
-                StringBuilder sb = new StringBuilder();
-                int lastc = -1;
-                while (true) {
-                    sb.appendCodePoint(c);
-                    c = Character.toLowerCase(thisChar());
-                    if (c == '+' || c == '-') {
-                        if (lastc != 'e')
-                            break;
-                    } else if (!Character.isDigit(c) && c != '.' && c != 'e')
-                        break;
-                    lastc = c;
-                    advance();
-                }
-                String s = sb.toString();
-                if (s.indexOf('.') >= 0 || s.indexOf('e') >= 0) {
-                    double d = parseDoubleCheckOverflow(s);
-                    return new DoubleLit(d);
-                } else {
-                    // Like the Java language, we allow the numeric constant
-                    // x where -x = Long.MIN_VALUE, even though x is not
-                    // representable as a long (it is Long.MAX_VALUE + 1).
-                    // Code in the parser will reject this value if it is
-                    // not the operand of unary minus.
-                    long l = -Long.parseLong("-" + s);
-                    return new LongLit(l);
-                }
-            }
-
-            // It must be an identifier.
-            if (!Character.isJavaIdentifierStart(c)) {
-                StringBuilder sb = new StringBuilder();
-                Formatter f = new Formatter(sb);
-                f.format("Bad character: %c (%04x)", c, c);
-                throw new IllegalArgumentException(sb.toString());
-            }
-
-            StringBuilder id = new StringBuilder();
-            while (true) { // identifier
-                id.appendCodePoint(c);
-                c = thisChar();
-                if (!Character.isJavaIdentifierPart(c))
-                    break;
-                advance();
-            }
-
-            return new Id(id.toString());
-        }
-    }
-
-    /* Parse a double as a Java compiler would do it, throwing an exception
-     * if the input does not fit in a double.  We assume that the input
-     * string is not "Infinity" and does not have a leading sign.
-     */
-    private static double parseDoubleCheckOverflow(String s) {
-        double d = Double.parseDouble(s);
-        if (Double.isInfinite(d))
-            throw new NumberFormatException("Overflow: " + s);
-        if (d == 0.0) {  // Underflow checking is hard!  CR 6604864
-            String ss = s;
-            int e = s.indexOf('e');  // we already forced E to lowercase
-            if (e > 0)
-                ss = s.substring(0, e);
-            ss = ss.replace("0", "").replace(".", "");
-            if (!ss.equals(""))
-                throw new NumberFormatException("Underflow: " + s);
-        }
-        return d;
-    }
-
-    // PARSER STARTS HERE
-
-    private final List<Token> tokens;
-    private int tokenI;
-    // The current token is always tokens[tokenI].
-
-    QueryParser(String s) {
-        // Construct the complete list of tokens immediately and append
-        // a sentinel (END).
-        tokens = new ArrayList<Token>();
-        Tokenizer tokenizer = new Tokenizer(s);
-        Token t;
-        while ((t = tokenizer.nextToken()) != null)
-            tokens.add(t);
-        tokens.add(END);
-    }
-
-    private Token current() {
-        return tokens.get(tokenI);
-    }
-
-    // If the current token is t, then skip it and return true.
-    // Otherwise, return false.
-    private boolean skip(Token t) {
-        if (t.equals(current())) {
-            tokenI++;
-            return true;
-        }
-        return false;
-    }
-
-    // If the current token is one of the ones in 'tokens', then skip it
-    // and return its index in 'tokens'.  Otherwise, return -1.
-    private int skipOne(Token... tokens) {
-        for (int i = 0; i < tokens.length; i++) {
-            if (skip(tokens[i]))
-                return i;
-        }
-        return -1;
-    }
-
-    // If the current token is t, then skip it and return.
-    // Otherwise throw an exception.
-    private void expect(Token t) {
-        if (!skip(t))
-            throw new IllegalArgumentException("Expected " + t + ", found " + current());
-    }
-
-    private void next() {
-        tokenI++;
-    }
-
-    QueryExp parseQuery() {
-        QueryExp qe = query();
-        if (current() != END)
-            throw new IllegalArgumentException("Junk at end of query: " + current());
-        return qe;
-    }
-
-    // The remainder of this class is a classical recursive-descent parser.
-    // We only need to violate the recursive-descent scheme in one place,
-    // where parentheses make the grammar not LL(1).
-
-    private QueryExp query() {
-        QueryExp lhs = andquery();
-        while (skip(OR))
-            lhs = Query.or(lhs, andquery());
-        return lhs;
-    }
-
-    private QueryExp andquery() {
-        QueryExp lhs = predicate();
-        while (skip(AND))
-            lhs = Query.and(lhs, predicate());
-        return lhs;
-    }
-
-    private QueryExp predicate() {
-        // Grammar hack.  If we see a paren, it might be (query) or
-        // it might be (value).  We try to parse (query), and if that
-        // fails, we parse (value).  For example, if the string is
-        // "(2+3)*4 < 5" then we will try to parse the query
-        // "2+3)*4 < 5", which will fail at the ), so we'll back up to
-        // the paren and let value() handle it.
-        if (skip(LPAR)) {
-            int parenIndex = tokenI - 1;
-            try {
-                QueryExp qe = query();
-                expect(RPAR);
-                return qe;
-            } catch (IllegalArgumentException e) {
-                // OK: try parsing a value
-            }
-            tokenI = parenIndex;
-        }
-
-        if (skip(NOT))
-            return Query.not(predicate());
-
-        if (skip(INSTANCEOF))
-            return Query.isInstanceOf(stringvalue());
-
-        if (skip(LIKE)) {
-            StringValueExp sve = stringvalue();
-            String s = sve.getValue();
-            try {
-                return new ObjectName(s);
-            } catch (MalformedObjectNameException e) {
-                throw new IllegalArgumentException(
-                        "Bad ObjectName pattern after LIKE: '" + s + "'", e);
-            }
-        }
-
-        ValueExp lhs = value();
-
-        return predrhs(lhs);
-    }
-
-    // The order of elements in the following arrays is important.  The code
-    // in predrhs depends on integer indexes.  Change with caution.
-    private static final Token[] relations = {
-            EQ, LT, GT, LE, GE, NE,
-         // 0,  1,  2,  3,  4,  5,
-    };
-    private static final Token[] betweenLikeIn = {
-            BETWEEN, LIKE, IN
-         // 0,       1,    2,
-    };
-
-    private QueryExp predrhs(ValueExp lhs) {
-        Token start = current(); // for errors
-
-        // Look for < > = etc
-        int i = skipOne(relations);
-        if (i >= 0) {
-            ValueExp rhs = value();
-            switch (i) {
-                case 0: return Query.eq(lhs, rhs);
-                case 1: return Query.lt(lhs, rhs);
-                case 2: return Query.gt(lhs, rhs);
-                case 3: return Query.leq(lhs, rhs);
-                case 4: return Query.geq(lhs, rhs);
-                case 5: return Query.not(Query.eq(lhs, rhs));
-                // There is no Query.ne so <> is shorthand for the above.
-                default:
-                    throw new AssertionError();
-            }
-        }
-
-        // Must be BETWEEN LIKE or IN, optionally preceded by NOT
-        boolean not = skip(NOT);
-        i = skipOne(betweenLikeIn);
-        if (i < 0)
-            throw new IllegalArgumentException("Expected relation at " + start);
-
-        QueryExp q;
-        switch (i) {
-            case 0: { // BETWEEN
-                ValueExp lower = value();
-                expect(AND);
-                ValueExp upper = value();
-                q = Query.between(lhs, lower, upper);
-                break;
-            }
-
-            case 1: { // LIKE
-                if (!(lhs instanceof AttributeValueExp)) {
-                    throw new IllegalArgumentException(
-                            "Left-hand side of LIKE must be an attribute");
-                }
-                AttributeValueExp alhs = (AttributeValueExp) lhs;
-                StringValueExp sve = stringvalue();
-                q = Query.match(alhs, sve);
-                break;
-            }
-
-            case 2: { // IN
-                expect(LPAR);
-                List<ValueExp> values = new ArrayList<ValueExp>();
-                values.add(value());
-                while (skip(COMMA))
-                    values.add(value());
-                expect(RPAR);
-                q = Query.in(lhs, values.toArray(new ValueExp[values.size()]));
-                break;
-            }
-
-            default:
-                throw new AssertionError();
-        }
-
-        if (not)
-            q = Query.not(q);
-
-        return q;
-    }
-
-    private ValueExp value() {
-        ValueExp lhs = factor();
-        int i;
-        while ((i = skipOne(PLUS, MINUS)) >= 0) {
-            ValueExp rhs = factor();
-            if (i == 0)
-                lhs = Query.plus(lhs, rhs);
-            else
-                lhs = Query.minus(lhs, rhs);
-        }
-        return lhs;
-    }
-
-    private ValueExp factor() {
-        ValueExp lhs = term();
-        int i;
-        while ((i = skipOne(TIMES, DIVIDE)) >= 0) {
-            ValueExp rhs = term();
-            if (i == 0)
-                lhs = Query.times(lhs, rhs);
-            else
-                lhs = Query.div(lhs, rhs);
-        }
-        return lhs;
-    }
-
-    private ValueExp term() {
-        boolean signed = false;
-        int sign = +1;
-        if (skip(PLUS))
-            signed = true;
-        else if (skip(MINUS)) {
-            signed = true; sign = -1;
-        }
-
-        Token t = current();
-        next();
-
-        if (t instanceof DoubleLit)
-            return Query.value(sign * ((DoubleLit) t).number);
-        if (t instanceof LongLit) {
-            long n = ((LongLit) t).number;
-            if (n == Long.MIN_VALUE && sign != -1)
-                throw new IllegalArgumentException("Illegal positive integer: " + n);
-            return Query.value(sign * n);
-        }
-        if (signed)
-            throw new IllegalArgumentException("Expected number after + or -");
-
-        if (t == LPAR) {
-            ValueExp v = value();
-            expect(RPAR);
-            return v;
-        }
-        if (t.equals(FALSE) || t.equals(TRUE)) {
-            return Query.value(t.equals(TRUE));
-        }
-        if (t.equals(CLASS))
-            return Query.classattr();
-
-        if (t instanceof StringLit)
-            return Query.value(t.string); // Not toString(), which would requote '
-
-        // At this point, all that remains is something that will call Query.attr
-
-        if (!(t instanceof Id) && !(t instanceof QuotedId))
-            throw new IllegalArgumentException("Unexpected token " + t);
-
-        String name1 = name(t);
-
-        if (skip(SHARP)) {
-            Token t2 = current();
-            next();
-            String name2 = name(t2);
-            return Query.attr(name1, name2);
-        }
-        return Query.attr(name1);
-    }
-
-    // Initially, t is the first token of a supposed name and current()
-    // is the second.
-    private String name(Token t) {
-        StringBuilder sb = new StringBuilder();
-        while (true) {
-            if (!(t instanceof Id) && !(t instanceof QuotedId))
-                throw new IllegalArgumentException("Unexpected token " + t);
-            sb.append(t.string);
-            if (current() != DOT)
-                break;
-            sb.append('.');
-            next();
-            t = current();
-            next();
-        }
-        return sb.toString();
-    }
-
-    private StringValueExp stringvalue() {
-        // Currently the only way to get a StringValueExp when constructing
-        // a QueryExp is via Query.value(String), so we only recognize
-        // string literals here.  But if we expand queries in the future
-        // that might no longer be true.
-        Token t = current();
-        next();
-        if (!(t instanceof StringLit))
-            throw new IllegalArgumentException("Expected string: " + t);
-        return Query.value(t.string);
-    }
-}
--- a/src/share/classes/javax/management/SendNotification.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management;
-
-/**
- * Interface implemented by objects that can be asked to send a notification.
- */
-public interface SendNotification {
-    /**
-     * Sends a notification.
-     *
-     * @param notification The notification to send.
-     */
-    public void sendNotification(Notification notification);
-}
--- a/src/share/classes/javax/management/StandardEmitterMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/StandardEmitterMBean.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,10 +25,6 @@
 
 package javax.management;
 
-import com.sun.jmx.mbeanserver.MBeanInjector;
-import com.sun.jmx.mbeanserver.MBeanIntrospector;
-import static javax.management.JMX.MBeanOptions;
-
 /**
  * <p>An MBean whose management interface is determined by reflection
  * on a Java interface, and that emits notifications.</p>
@@ -66,7 +62,7 @@
  * @since 1.6
  */
 public class StandardEmitterMBean extends StandardMBean
-        implements NotificationEmitter, SendNotification {
+        implements NotificationEmitter {
 
     private final NotificationEmitter emitter;
     private final MBeanNotificationInfo[] notificationInfo;
@@ -80,10 +76,9 @@
      * for {@code implementation} and {@code emitter} to be the same object.</p>
      *
      * <p>If {@code emitter} is an instance of {@code
-     * SendNotification} (for example, a {@link NotificationBroadcasterSupport}),
-     * then the MBean's {@link #sendNotification
+     * NotificationBroadcasterSupport} then the MBean's {@link #sendNotification
      * sendNotification} method will call {@code emitter.}{@link
-     * SendNotification#sendNotification sendNotification}.</p>
+     * NotificationBroadcasterSupport#sendNotification sendNotification}.</p>
      *
      * <p>The array returned by {@link #getNotificationInfo()} on the
      * new MBean is a copy of the array returned by
@@ -95,18 +90,20 @@
      *
      * @param implementation the implementation of the MBean interface.
      * @param mbeanInterface a Standard MBean interface.
-     * @param emitter the object that will handle notifications.  If null,
-     * a new {@code NotificationEmitter} will be constructed that also
-     * implements {@link SendNotification}.
+     * @param emitter the object that will handle notifications.
      *
      * @throws IllegalArgumentException if the {@code mbeanInterface}
      *    does not follow JMX design patterns for Management Interfaces, or
      *    if the given {@code implementation} does not implement the
-     *    specified interface.
+     *    specified interface, or if {@code emitter} is null.
      */
     public <T> StandardEmitterMBean(T implementation, Class<T> mbeanInterface,
                                     NotificationEmitter emitter) {
-        this(implementation, mbeanInterface, false, emitter);
+        super(implementation, mbeanInterface, false);
+        if (emitter == null)
+            throw new IllegalArgumentException("Null emitter");
+        this.emitter = emitter;
+        this.notificationInfo = emitter.getNotificationInfo();
     }
 
     /**
@@ -121,10 +118,9 @@
      * same object.</p>
      *
      * <p>If {@code emitter} is an instance of {@code
-     * SendNotification} (for example, a {@link NotificationBroadcasterSupport}),
-     * then the MBean's {@link #sendNotification
+     * NotificationBroadcasterSupport} then the MBean's {@link #sendNotification
      * sendNotification} method will call {@code emitter.}{@link
-     * SendNotification#sendNotification sendNotification}.</p>
+     * NotificationBroadcasterSupport#sendNotification sendNotification}.</p>
      *
      * <p>The array returned by {@link #getNotificationInfo()} on the
      * new MBean is a copy of the array returned by
@@ -138,71 +134,21 @@
      * @param mbeanInterface a Standard MBean interface.
      * @param isMXBean If true, the {@code mbeanInterface} parameter
      * names an MXBean interface and the resultant MBean is an MXBean.
-     * @param emitter the object that will handle notifications.  If null,
-     * a new {@code NotificationEmitter} will be constructed that also
-     * implements {@link SendNotification}.
+     * @param emitter the object that will handle notifications.
      *
      * @throws IllegalArgumentException if the {@code mbeanInterface}
      *    does not follow JMX design patterns for Management Interfaces, or
      *    if the given {@code implementation} does not implement the
-     *    specified interface.
+     *    specified interface, or if {@code emitter} is null.
      */
     public <T> StandardEmitterMBean(T implementation, Class<T> mbeanInterface,
                                     boolean isMXBean,
                                     NotificationEmitter emitter) {
-        this(implementation, mbeanInterface,
-                isMXBean ? MBeanOptions.MXBEAN : null, emitter);
-    }
-
-    /**
-     * <p>Make an MBean whose management interface is specified by {@code
-     * mbeanInterface}, with the given implementation and options, and where
-     * notifications are handled by the given {@code NotificationEmitter}.
-     * Options select whether to make a Standard MBean or an MXBean, and
-     * whether the result of {@link #getWrappedObject()} is the {@code
-     * StandardEmitterMBean} object or the given implementation. The resultant
-     * MBean implements the {@code NotificationEmitter} interface by forwarding
-     * its methods to {@code emitter}. It is legal and useful for {@code
-     * implementation} and {@code emitter} to be the same object.</p>
-     *
-     * <p>If {@code emitter} is an instance of {@code
-     * SendNotification} (for example, a {@link NotificationBroadcasterSupport}),
-     * then the MBean's {@link #sendNotification
-     * sendNotification} method will call {@code emitter.}{@link
-     * SendNotification#sendNotification sendNotification}.</p>
-     *
-     * <p>The array returned by {@link #getNotificationInfo()} on the
-     * new MBean is a copy of the array returned by
-     * {@code emitter.}{@link NotificationBroadcaster#getNotificationInfo
-     * getNotificationInfo()} at the time of construction.  If the array
-     * returned by {@code emitter.getNotificationInfo()} later changes,
-     * that will have no effect on this object's
-     * {@code getNotificationInfo()}.</p>
-     *
-     * @param implementation the implementation of the MBean interface.
-     * @param mbeanInterface a Standard MBean interface.
-     * @param options MBeanOptions that control the operation of the resulting
-     * MBean.
-     * @param emitter the object that will handle notifications.  If null,
-     * a new {@code NotificationEmitter} will be constructed that also
-     * implements {@link SendNotification}.
-     *
-     * @throws IllegalArgumentException if the {@code mbeanInterface}
-     *    does not follow JMX design patterns for Management Interfaces, or
-     *    if the given {@code implementation} does not implement the
-     *    specified interface.
-     */
-    public <T> StandardEmitterMBean(T implementation, Class<T> mbeanInterface,
-                                    MBeanOptions options,
-                                    NotificationEmitter emitter) {
-        super(implementation, mbeanInterface, options);
-        MBeanNotificationInfo[] defaultMBNIs = defaultMBNIs(implementation);
+        super(implementation, mbeanInterface, isMXBean);
         if (emitter == null)
-            emitter = defaultEmitter(defaultMBNIs);
+            throw new IllegalArgumentException("Null emitter");
         this.emitter = emitter;
-        this.notificationInfo =
-                firstNonEmpty(emitter.getNotificationInfo(), defaultMBNIs);
-        injectEmitter();
+        this.notificationInfo = emitter.getNotificationInfo();
     }
 
     /**
@@ -213,10 +159,9 @@
      * by forwarding its methods to {@code emitter}.</p>
      *
      * <p>If {@code emitter} is an instance of {@code
-     * SendNotification} (for example, a {@link NotificationBroadcasterSupport}),
-     * then the MBean's {@link #sendNotification
+     * NotificationBroadcasterSupport} then the MBean's {@link #sendNotification
      * sendNotification} method will call {@code emitter.}{@link
-     * SendNotification#sendNotification sendNotification}.</p>
+     * NotificationBroadcasterSupport#sendNotification sendNotification}.</p>
      *
      * <p>The array returned by {@link #getNotificationInfo()} on the
      * new MBean is a copy of the array returned by
@@ -230,17 +175,20 @@
      * the given {@code mbeanInterface}.</p>
      *
      * @param mbeanInterface a StandardMBean interface.
-     * @param emitter the object that will handle notifications.  If null,
-     * a new {@code NotificationEmitter} will be constructed that also
-     * implements {@link SendNotification}.
+     * @param emitter the object that will handle notifications.
      *
      * @throws IllegalArgumentException if the {@code mbeanInterface}
      *    does not follow JMX design patterns for Management Interfaces, or
-     *    if {@code this} does not implement the specified interface.
+     *    if {@code this} does not implement the specified interface, or
+     *    if {@code emitter} is null.
      */
     protected StandardEmitterMBean(Class<?> mbeanInterface,
                                    NotificationEmitter emitter) {
-        this(mbeanInterface, false, emitter);
+        super(mbeanInterface, false);
+        if (emitter == null)
+            throw new IllegalArgumentException("Null emitter");
+        this.emitter = emitter;
+        this.notificationInfo = emitter.getNotificationInfo();
     }
 
     /**
@@ -252,10 +200,9 @@
      * forwarding its methods to {@code emitter}.</p>
      *
      * <p>If {@code emitter} is an instance of {@code
-     * SendNotification} (for example, a {@link NotificationBroadcasterSupport}),
-     * then the MBean's {@link #sendNotification
+     * NotificationBroadcasterSupport} then the MBean's {@link #sendNotification
      * sendNotification} method will call {@code emitter.}{@link
-     * SendNotification#sendNotification sendNotification}.</p>
+     * NotificationBroadcasterSupport#sendNotification sendNotification}.</p>
      *
      * <p>The array returned by {@link #getNotificationInfo()} on the
      * new MBean is a copy of the array returned by
@@ -271,102 +218,20 @@
      * @param mbeanInterface a StandardMBean interface.
      * @param isMXBean If true, the {@code mbeanInterface} parameter
      * names an MXBean interface and the resultant MBean is an MXBean.
-     * @param emitter the object that will handle notifications.  If null,
-     * a new {@code NotificationEmitter} will be constructed that also
-     * implements {@link SendNotification}.
-     *
-     * @throws IllegalArgumentException if the {@code mbeanInterface}
-     *    does not follow JMX design patterns for Management Interfaces, or
-     *    if {@code this} does not implement the specified interface.
-     */
-    protected StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean,
-                                   NotificationEmitter emitter) {
-        this(mbeanInterface, isMXBean ? MBeanOptions.MXBEAN : null, emitter);
-    }
-
-    /**
-     * <p>Make an MBean whose management interface is specified by {@code
-     * mbeanInterface}, with the given options, and where notifications are
-     * handled by the given {@code NotificationEmitter}. This constructor can
-     * be used to make either Standard MBeans or MXBeans. The resultant MBean
-     * implements the {@code NotificationEmitter} interface by forwarding its
-     * methods to {@code emitter}.</p>
-     *
-     * <p>If {@code emitter} is an instance of {@code
-     * SendNotification} (for example, a {@link NotificationBroadcasterSupport}),
-     * then the MBean's {@link #sendNotification
-     * sendNotification} method will call {@code emitter.}{@link
-     * SendNotification#sendNotification sendNotification}.</p>
-     *
-     * <p>The array returned by {@link #getNotificationInfo()} on the
-     * new MBean is a copy of the array returned by
-     * {@code emitter.}{@link NotificationBroadcaster#getNotificationInfo
-     * getNotificationInfo()} at the time of construction.  If the array
-     * returned by {@code emitter.getNotificationInfo()} later changes,
-     * that will have no effect on this object's
-     * {@code getNotificationInfo()}.</p>
-     *
-     * <p>This constructor must be called from a subclass that implements
-     * the given {@code mbeanInterface}.</p>
-     *
-     * @param mbeanInterface a StandardMBean interface.
-     * @param options MBeanOptions that control the operation of the resulting
-     * MBean.
-     * @param emitter the object that will handle notifications.  If null,
-     * a new {@code NotificationEmitter} will be constructed that also
-     * implements {@link SendNotification}.
+     * @param emitter the object that will handle notifications.
      *
      * @throws IllegalArgumentException if the {@code mbeanInterface}
      *    does not follow JMX design patterns for Management Interfaces, or
-     *    if {@code this} does not implement the specified interface.
+     *    if {@code this} does not implement the specified interface, or
+     *    if {@code emitter} is null.
      */
-    protected StandardEmitterMBean(Class<?> mbeanInterface, MBeanOptions options,
+    protected StandardEmitterMBean(Class<?> mbeanInterface, boolean isMXBean,
                                    NotificationEmitter emitter) {
-        super(mbeanInterface, options);
-        MBeanNotificationInfo[] defaultMBNIs = defaultMBNIs(this);
+        super(mbeanInterface, isMXBean);
         if (emitter == null)
-            emitter = defaultEmitter(defaultMBNIs);
+            throw new IllegalArgumentException("Null emitter");
         this.emitter = emitter;
-        this.notificationInfo =
-                firstNonEmpty(emitter.getNotificationInfo(), defaultMBNIs);
-        injectEmitter();
-    }
-
-    private static MBeanNotificationInfo[] defaultMBNIs(Object mbean) {
-        return MBeanIntrospector.findNotificationsFromAnnotations(
-                mbean.getClass());
-    }
-
-    private NotificationEmitter defaultEmitter(MBeanNotificationInfo[] defaultMBNIs) {
-        MBeanNotificationInfo[] mbnis =
-                firstNonEmpty(getNotificationInfo(), defaultMBNIs);
-        // Will be null unless getNotificationInfo() is overridden,
-        // since the notificationInfo field has not been set at this point.
-        if (mbnis == null)
-            mbnis = getMBeanInfo().getNotifications();
-        return new NotificationBroadcasterSupport(mbnis);
-    }
-
-    private static <T> T[] firstNonEmpty(T[]... items) {
-        for (T[] t : items) {
-            if (t != null && t.length != 0)
-                return t;
-        }
-        return null;
-    }
-
-    private void injectEmitter() {
-        if (emitter instanceof SendNotification) {
-            try {
-                Object resource = getImplementation();
-                SendNotification send = (SendNotification) emitter;
-                MBeanInjector.injectSendNotification(resource, send);
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new IllegalArgumentException(e);
-            }
-        }
+        this.notificationInfo = emitter.getNotificationInfo();
     }
 
     public void removeNotificationListener(NotificationListener listener)
@@ -394,10 +259,10 @@
     /**
      * <p>Sends a notification.</p>
      *
-     * <p>If the {@code emitter} parameter to the constructor was
-     * an instance of {@link SendNotification}, such as {@link
-     * NotificationBroadcasterSupport}, then this method will call {@code
-     * emitter.}{@link SendNotification#sendNotification
+     * <p>If the {@code emitter} parameter to the constructor was an
+     * instance of {@code NotificationBroadcasterSupport} then this
+     * method will call {@code emitter.}{@link
+     * NotificationBroadcasterSupport#sendNotification
      * sendNotification}.</p>
      *
      * @param n the notification to send.
@@ -406,12 +271,13 @@
      * constructor was not a {@code NotificationBroadcasterSupport}.
      */
     public void sendNotification(Notification n) {
-        if (emitter instanceof SendNotification)
-            ((SendNotification) emitter).sendNotification(n);
+        if (emitter instanceof NotificationBroadcasterSupport)
+            ((NotificationBroadcasterSupport) emitter).sendNotification(n);
         else {
             final String msg =
                 "Cannot sendNotification when emitter is not an " +
-                "instance of SendNotification: " + emitter.getClass().getName();
+                "instance of NotificationBroadcasterSupport: " +
+                emitter.getClass().getName();
             throw new ClassCastException(msg);
         }
     }
--- a/src/share/classes/javax/management/StandardMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/StandardMBean.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,27 +25,20 @@
 
 package javax.management;
 
+import static com.sun.jmx.defaults.JmxProperties.MISC_LOGGER;
 import com.sun.jmx.mbeanserver.DescriptorCache;
 import com.sun.jmx.mbeanserver.Introspector;
-import com.sun.jmx.mbeanserver.MBeanInjector;
-import com.sun.jmx.mbeanserver.MBeanInstantiator;
-import com.sun.jmx.mbeanserver.MBeanIntrospector;
 import com.sun.jmx.mbeanserver.MBeanSupport;
 import com.sun.jmx.mbeanserver.MXBeanSupport;
 import com.sun.jmx.mbeanserver.StandardMBeanSupport;
 import com.sun.jmx.mbeanserver.Util;
-import java.lang.reflect.Method;
+
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.logging.Level;
-import javax.management.openmbean.MXBeanMappingFactory;
 import javax.management.openmbean.OpenMBeanAttributeInfo;
 import javax.management.openmbean.OpenMBeanAttributeInfoSupport;
 import javax.management.openmbean.OpenMBeanConstructorInfo;
@@ -55,9 +48,6 @@
 import javax.management.openmbean.OpenMBeanParameterInfo;
 import javax.management.openmbean.OpenMBeanParameterInfoSupport;
 
-import static com.sun.jmx.defaults.JmxProperties.MISC_LOGGER;
-import static javax.management.JMX.MBeanOptions;
-
 /**
  * <p>An MBean whose management interface is determined by reflection
  * on a Java interface.</p>
@@ -133,121 +123,7 @@
  *
  * @since 1.5
  */
-public class StandardMBean implements DynamicWrapperMBean, MBeanRegistration {
-
-    /**
-     * <p>Options controlling the behavior of {@code StandardMBean} instances.</p>
-     */
-    public static class Options extends JMX.MBeanOptions {
-        private static final long serialVersionUID = 5107355471177517164L;
-
-        private boolean wrappedVisible;
-        private boolean forwardRegistration;
-
-        /**
-         * <p>Construct an {@code Options} object where all options have
-         * their default values.</p>
-         */
-        public Options() {}
-
-        @Override
-        public Options clone() {
-            return (Options) super.clone();
-        }
-
-        /**
-         * <p>Defines whether the {@link StandardMBean#getWrappedObject()
-         * getWrappedObject} method returns the wrapped object.</p>
-         *
-         * <p>If this option is true, then {@code getWrappedObject()} will return
-         * the same object as {@link StandardMBean#getImplementation()
-         * getImplementation}.  Otherwise, it will return the
-         * StandardMBean instance itself.  The setting of this option
-         * affects the behavior of {@link MBeanServer#getClassLoaderFor
-         * MBeanServer.getClassLoaderFor} and {@link MBeanServer#isInstanceOf
-         * MBeanServer.isInstanceOf}.  The default value is false for
-         * compatibility reasons, but true is a better value for most new code.</p>
-         *
-         * @return true if this StandardMBean's {@link
-         * StandardMBean#getWrappedObject getWrappedObject} returns the wrapped
-         * object.
-         */
-        public boolean isWrappedObjectVisible() {
-            return this.wrappedVisible;
-        }
-
-        /**
-         * <p>Set the {@link #isWrappedObjectVisible WrappedObjectVisible} option
-         * to the given value.</p>
-         * @param visible the new value.
-         */
-        public void setWrappedObjectVisible(boolean visible) {
-            this.wrappedVisible = visible;
-        }
-
-        /**
-         * <p>Defines whether the {@link MBeanRegistration MBeanRegistration}
-         * callbacks are forwarded to the wrapped object.</p>
-         *
-         * <p>If this option is true, then
-         * {@link #preRegister(MBeanServer, ObjectName) preRegister},
-         * {@link #postRegister(Boolean) postRegister},
-         * {@link #preDeregister preDeregister} and
-         * {@link #postDeregister postDeregister} methods are forwarded
-         * to the wrapped object, in addition to the behaviour specified
-         * for the StandardMBean instance itself.
-         * The default value is false for compatibility reasons, but true
-         * is a better value for most new code.</p>
-         *
-         * @return true if the <code>MBeanRegistration</code> callbacks
-         * are forwarded to the wrapped object.
-         */
-        public boolean isMBeanRegistrationForwarded() {
-            return this.forwardRegistration;
-        }
-
-        /**
-         * <p>Set the
-         * {@link #isMBeanRegistrationForwarded MBeanRegistrationForwarded}
-         * option to the given value.</p>
-         * @param forward the new value.
-         */
-        public void setMBeanRegistrationForwarded(boolean forward) {
-            this.forwardRegistration = forward;
-        }
-
-        // Canonical objects for each of
-        // (MXBean,!MXBean) x (WVisible,!WVisible) x (Forward,!Forward)
-        private static final Options[] CANONICALS = {
-            new Options(), new Options(), new Options(), new Options(),
-            new Options(), new Options(), new Options(), new Options(),
-        };
-        static {
-            CANONICALS[1].setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-            CANONICALS[2].setWrappedObjectVisible(true);
-            CANONICALS[3].setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-            CANONICALS[3].setWrappedObjectVisible(true);
-            CANONICALS[4].setMBeanRegistrationForwarded(true);
-            CANONICALS[5].setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-            CANONICALS[5].setMBeanRegistrationForwarded(true);
-            CANONICALS[6].setWrappedObjectVisible(true);
-            CANONICALS[6].setMBeanRegistrationForwarded(true);
-            CANONICALS[7].setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-            CANONICALS[7].setWrappedObjectVisible(true);
-            CANONICALS[7].setMBeanRegistrationForwarded(true);
-        }
-        @Override
-        MBeanOptions[] canonicals() {
-            return CANONICALS;
-        }
-
-        @Override
-        boolean same(MBeanOptions opts) {
-            return (super.same(opts) && opts instanceof Options &&
-                    ((Options) opts).wrappedVisible == wrappedVisible &&
-                    ((Options) opts).forwardRegistration ==forwardRegistration);
-        }
-    }
+public class StandardMBean implements DynamicMBean, MBeanRegistration {
 
     private final static DescriptorCache descriptors =
         DescriptorCache.getInstance(JMX.proof);
@@ -263,11 +139,6 @@
     private volatile MBeanInfo cachedMBeanInfo;
 
     /**
-     * The MBeanOptions for this StandardMBean.
-     **/
-    private MBeanOptions options;
-
-    /**
      * Make a DynamicMBean out of <var>implementation</var>, using the
      * specified <var>mbeanInterface</var> class.
      * @param implementation The implementation of this MBean.
@@ -282,14 +153,12 @@
      *        implementation is allowed. If null implementation is allowed,
      *        and a null implementation is passed, then the implementation
      *        is assumed to be <var>this</var>.
-     * @param options MBeanOptions to apply to this instance.
      * @exception IllegalArgumentException if the given
      *    <var>implementation</var> is null, and null is not allowed.
      **/
-    @SuppressWarnings("unchecked")  // cast to T
     private <T> void construct(T implementation, Class<T> mbeanInterface,
                                boolean nullImplementationAllowed,
-                               MBeanOptions options)
+                               boolean isMXBean)
                                throws NotCompliantMBeanException {
         if (implementation == null) {
             // Have to use (T)this rather than mbeanInterface.cast(this)
@@ -298,23 +167,20 @@
                 implementation = Util.<T>cast(this);
             else throw new IllegalArgumentException("implementation is null");
         }
-        if (options == null)
-            options = new MBeanOptions();
-        MXBeanMappingFactory mappingFactory = options.getMXBeanMappingFactory();
-        boolean mx = (mappingFactory != null);
-        if (mbeanInterface == null) {
-            mbeanInterface = Util.cast(Introspector.getStandardOrMXBeanInterface(
-                                       implementation.getClass(), mx));
-        }
-        if (mx) {
-            this.mbean =
-                    new MXBeanSupport(implementation, mbeanInterface,
-                                      mappingFactory);
+        if (isMXBean) {
+            if (mbeanInterface == null) {
+                mbeanInterface = Util.cast(Introspector.getMXBeanInterface(
+                        implementation.getClass()));
+            }
+            this.mbean = new MXBeanSupport(implementation, mbeanInterface);
         } else {
+            if (mbeanInterface == null) {
+                mbeanInterface = Util.cast(Introspector.getStandardMBeanInterface(
+                        implementation.getClass()));
+            }
             this.mbean =
                     new StandardMBeanSupport(implementation, mbeanInterface);
         }
-        this.options = options.canonical();
     }
 
     /**
@@ -343,7 +209,7 @@
      **/
     public <T> StandardMBean(T implementation, Class<T> mbeanInterface)
         throws NotCompliantMBeanException {
-        construct(implementation, mbeanInterface, false, null);
+        construct(implementation, mbeanInterface, false, false);
     }
 
     /**
@@ -363,7 +229,7 @@
      **/
     protected StandardMBean(Class<?> mbeanInterface)
         throws NotCompliantMBeanException {
-        construct(null, mbeanInterface, true, null);
+        construct(null, mbeanInterface, true, false);
     }
 
     /**
@@ -400,17 +266,7 @@
     public <T> StandardMBean(T implementation, Class<T> mbeanInterface,
                              boolean isMXBean) {
         try {
-            MBeanOptions opts = new MBeanOptions();
-            if (mbeanInterface == null) {
-                mbeanInterface = Util.cast(Introspector.getStandardOrMXBeanInterface(
-                        implementation.getClass(), isMXBean));
-            }
-            if (isMXBean) {
-                MXBeanMappingFactory f = MXBeanMappingFactory.forInterface(
-                        mbeanInterface);
-                opts.setMXBeanMappingFactory(f);
-            }
-            construct(implementation, mbeanInterface, false, opts);
+            construct(implementation, mbeanInterface, false, isMXBean);
         } catch (NotCompliantMBeanException e) {
             throw new IllegalArgumentException(e);
         }
@@ -441,77 +297,7 @@
      **/
     protected StandardMBean(Class<?> mbeanInterface, boolean isMXBean) {
         try {
-            MBeanOptions opts = new MBeanOptions();
-            if (mbeanInterface == null) {
-                mbeanInterface = Introspector.getStandardOrMXBeanInterface(
-                        getClass(), isMXBean);
-            }
-            if (isMXBean) {
-                MXBeanMappingFactory f = MXBeanMappingFactory.forInterface(
-                        mbeanInterface);
-                opts.setMXBeanMappingFactory(f);
-            }
-            construct(null, mbeanInterface, true, opts);
-        } catch (NotCompliantMBeanException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    /**
-     * <p>Make a DynamicMBean out of the object
-     * <var>implementation</var>, using the specified
-     * <var>mbeanInterface</var> class and the specified options.</p>
-     *
-     * @param implementation The implementation of this MBean.
-     * @param mbeanInterface The Management Interface exported by this
-     *        MBean's implementation. If <code>null</code>, then this
-     *        object will use standard JMX design pattern to determine
-     *        the management interface associated with the given
-     *        implementation.
-     * @param options MBeanOptions that control the operation of the resulting
-     *        MBean.
-     * @param <T> Allows the compiler to check
-     * that {@code implementation} does indeed implement the class
-     * described by {@code mbeanInterface}.  The compiler can only
-     * check this if {@code mbeanInterface} is a class literal such
-     * as {@code MyMBean.class}.
-     *
-     * @exception IllegalArgumentException if the given
-     *    <var>implementation</var> is null, or if the <var>mbeanInterface</var>
-     *    does not follow JMX design patterns for Management Interfaces, or
-     *    if the given <var>implementation</var> does not implement the
-     *    specified interface.
-     **/
-    public <T> StandardMBean(T implementation,
-                             Class<T> mbeanInterface,
-                             MBeanOptions options) {
-        try {
-            construct(implementation, mbeanInterface, false, options);
-        } catch (NotCompliantMBeanException e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    /**
-     * <p>Make a DynamicMBean out of <var>this</var>, using the specified
-     * <var>mbeanInterface</var> class and the specified options.</p>
-     *
-     * <p>Calls {@link #StandardMBean(Object, Class, JMX.MBeanOptions)
-     *       this(this,mbeanInterface,options)}.
-     * This constructor is reserved to subclasses.</p>
-     *
-     * @param mbeanInterface The Management Interface exported by this
-     *        MBean.
-     * @param options MBeanOptions that control the operation of the resulting
-     *        MBean.
-     *
-     * @exception IllegalArgumentException if the <var>mbeanInterface</var>
-     *    does not follow JMX design patterns for Management Interfaces, or
-     *    if <var>this</var> does not implement the specified interface.
-     **/
-    protected StandardMBean(Class<?> mbeanInterface, MBeanOptions options) {
-        try {
-            construct(null, mbeanInterface, true, options);
+            construct(null, mbeanInterface, true, isMXBean);
         } catch (NotCompliantMBeanException e) {
             throw new IllegalArgumentException(e);
         }
@@ -527,9 +313,7 @@
      *
      * @exception IllegalArgumentException if the given
      * <var>implementation</var> is null.
-     * @exception IllegalStateException if the
-     * {@link Options#isMBeanRegistrationForwarded MBeanRegistrationForwarded}
-     * option is true.
+     *
      * @exception NotCompliantMBeanException if the given
      * <var>implementation</var> does not implement the
      * Standard MBean (or MXBean) interface that was
@@ -543,24 +327,12 @@
         if (implementation == null)
             throw new IllegalArgumentException("implementation is null");
 
-        if(options instanceof Options &&
-                ((Options) options).isMBeanRegistrationForwarded())
-           throw new IllegalStateException("Implementation can't be changed " +
-                   "because MBeanRegistrationForwarded option is true");
-
-        setImplementation2(implementation);
-    }
-
-    private <T> void setImplementation2(T implementation)
-    throws NotCompliantMBeanException {
-        Class<? super T> intf = Util.cast(getMBeanInterface());
-
-        if (this.mbean.isMXBean()) {
+        if (isMXBean()) {
             this.mbean = new MXBeanSupport(implementation,
-                    intf,
-                    options.getMXBeanMappingFactory());
+                    Util.<Class<Object>>cast(getMBeanInterface()));
         } else {
-            this.mbean = new StandardMBeanSupport(implementation, intf);
+            this.mbean = new StandardMBeanSupport(implementation,
+                    Util.<Class<Object>>cast(getMBeanInterface()));
         }
     }
 
@@ -571,67 +343,7 @@
      * @see #setImplementation
      **/
     public Object getImplementation() {
-        return mbean.getWrappedObject();
-    }
-
-    /**
-     * <p>Get the wrapped implementation object or return this object.</p>
-     *
-     * <p>For compatibility reasons, this method only returns the wrapped
-     * implementation object if the {@link Options#isWrappedObjectVisible
-     * WrappedObjectVisible} option was specified when this StandardMBean
-     * was created.  Otherwise it returns {@code this}.</p>
-     *
-     * <p>If you want the MBeanServer's {@link MBeanServer#getClassLoaderFor
-     * getClassLoaderFor} and {@link MBeanServer#isInstanceOf
-     * isInstanceOf} methods to refer to the wrapped implementation and
-     * not this StandardMBean object, then you must set the
-     * {@code WrappedObjectVisible} option, for example using:</p>
-     *
-     * <pre>
-     * StandardMBean.Options opts = new StandardMBean.Options();
-     * opts.setWrappedObjectVisible(true);
-     * StandardMBean mbean = new StandardMBean(impl, MyMBean.class, opts);
-     * </pre>
-     *
-     * @return The wrapped implementation object, or this StandardMBean
-     * instance.
-     */
-    public Object getWrappedObject() {
-        if (options instanceof Options &&
-                ((Options) options).isWrappedObjectVisible())
-            return getImplementation();
-        else
-            return this;
-    }
-
-    /**
-     * <p>Get the ClassLoader of the wrapped implementation object or of this
-     * object.</p>
-     *
-     * <p>For compatibility reasons, this method only returns the ClassLoader
-     * of the wrapped implementation object if the {@link
-     * Options#isWrappedObjectVisible WrappedObjectVisible} option was
-     * specified when this StandardMBean was created. Otherwise it returns
-     * {@code this.getClass().getClassLoader()}.</p>
-     *
-     * <p>If you want the MBeanServer's {@link MBeanServer#getClassLoaderFor
-     * getClassLoaderFor} and {@link MBeanServer#isInstanceOf
-     * isInstanceOf} methods to refer to the wrapped implementation and
-     * not this StandardMBean object, then you must set the
-     * {@code WrappedObjectVisible} option, for example using:</p>
-     *
-     * <pre>
-     * StandardMBean.Options opts = new StandardMBean.Options();
-     * opts.setWrappedObjectVisible(true);
-     * StandardMBean mbean = new StandardMBean(impl, MyMBean.class, opts);
-     * </pre>
-     *
-     * @return The ClassLoader of the wrapped Cimplementation object, or of
-     * this StandardMBean instance.
-     */
-    public ClassLoader getWrappedClassLoader() {
-        return getWrappedObject().getClass().getClassLoader();
+        return mbean.getResource();
     }
 
     /**
@@ -647,20 +359,7 @@
      * @return The class of the implementation of this Standard MBean (or MXBean).
      **/
     public Class<?> getImplementationClass() {
-        return mbean.getWrappedObject().getClass();
-    }
-
-    /**
-     * Return the MBeanOptions that were specified or implied for this StandardMBean
-     * instance.  If an MBeanOptions object was supplied when this StandardMBean
-     * instance was constructed, and if that object has not been modified in the
-     * meantime, then the returned object will be equal to that object, although
-     * it might not be the same object.
-     * @return The MBeanOptions that were specified or implied for this StandardMBean
-     * instance.
-     */
-    public MBeanOptions getOptions() {
-        return options.uncanonical();
+        return mbean.getResource().getClass();
     }
 
     // ------------------------------------------------------------------
@@ -749,7 +448,7 @@
 
         MBeanSupport<?> msupport = mbean;
         final MBeanInfo bi = msupport.getMBeanInfo();
-        final Object impl = msupport.getWrappedObject();
+        final Object impl = msupport.getResource();
 
         final boolean immutableInfo = immutableInfo(this.getClass());
 
@@ -1027,7 +726,7 @@
      * @return the MBeanNotificationInfo[] for the new MBeanInfo.
      **/
     MBeanNotificationInfo[] getNotifications(MBeanInfo info) {
-        return info.getNotifications();
+        return null;
     }
 
     /**
@@ -1116,6 +815,10 @@
         cachedMBeanInfo = info;
     }
 
+    private boolean isMXBean() {
+        return mbean.isMXBean();
+    }
+
     private static <T> boolean identicalArrays(T[] a, T[] b) {
         if (a == b)
             return true;
@@ -1323,145 +1026,6 @@
         return natts;
     }
 
-    // ------------------------------------------------------------------
-    // Resolve from a type name to a Class.
-    // ------------------------------------------------------------------
-    private static Class<?> resolveClass(MBeanFeatureInfo info, String type,
-            Class<?> mbeanItf)
-            throws ClassNotFoundException {
-        String t = (String) info.getDescriptor().
-                getFieldValue(JMX.ORIGINAL_TYPE_FIELD);
-        if (t == null) {
-            t = type;
-        }
-        Class<?> clazz = MBeanInstantiator.primitiveType(t);
-        if(clazz == null)
-            clazz = Class.forName(t, false, mbeanItf.getClassLoader());
-        return clazz;
-    }
-
-    // ------------------------------------------------------------------
-    // Return the subset of valid Management methods
-    // ------------------------------------------------------------------
-    private static Method getManagementMethod(final Class<?> mbeanType,
-            String opName, Class<?>... parameters) throws NoSuchMethodException,
-            SecurityException {
-        Method m = mbeanType.getMethod(opName, parameters);
-        if (mbeanType.isInterface()) {
-            return m;
-        }
-        final List<Method> methods = new ArrayList<Method>();
-        try {
-            MBeanIntrospector.getAnnotatedMethods(mbeanType, methods);
-        }catch (SecurityException ex) {
-            throw ex;
-        }catch (NoSuchMethodException ex) {
-            throw ex;
-        }catch (Exception ex) {
-            NoSuchMethodException nsme =
-                    new NoSuchMethodException(ex.toString());
-            nsme.initCause(ex);
-            throw nsme;
-        }
-
-        if(methods.contains(m)) return m;
-
-        throw new NoSuchMethodException("Operation " + opName +
-                " not found in management interface " + mbeanType.getName());
-    }
-    /**
-     * Retrieve the set of MBean attribute accessor <code>Method</code>s
-     * located in the <code>mbeanInterface</code> MBean interface that
-     * correspond to the <code>attr</code> <code>MBeanAttributeInfo</code>
-     * parameter.
-     * @param mbeanInterface the management interface.
-     * Can be a standard MBean or MXBean interface, or a Java class
-     * annotated with {@link MBean &#64;MBean} or {@link MXBean &#64;MXBean}.
-     * @param attr The attribute we want the accessors for.
-     * @return The set of accessors.
-     * @throws java.lang.NoSuchMethodException if no accessor exists
-     * for the given {@link MBeanAttributeInfo MBeanAttributeInfo}.
-     * @throws java.lang.IllegalArgumentException if at least one
-     * of the two parameters is null.
-     * @throws java.lang.ClassNotFoundException if the class named in the
-     * attribute type is not found.
-     * @throws java.lang.SecurityException if this exception is
-     * encountered while introspecting the MBean interface.
-     */
-    public static Set<Method> findAttributeAccessors(Class<?> mbeanInterface,
-            MBeanAttributeInfo attr)
-            throws NoSuchMethodException,
-            ClassNotFoundException {
-        if (mbeanInterface == null || attr == null) {
-            throw new IllegalArgumentException("mbeanInterface or attr " +
-                    "parameter is null");
-        }
-        String attributeName = attr.getName();
-        Set<Method> methods = new HashSet<Method>();
-        Class<?> clazz = resolveClass(attr, attr.getType(), mbeanInterface);
-        if (attr.isReadable()) {
-            String radical = "get";
-            if(attr.isIs()) radical = "is";
-            Method getter = getManagementMethod(mbeanInterface, radical +
-                    attributeName);
-            if (getter.getReturnType().equals(clazz)) {
-                methods.add(getter);
-            } else {
-                throw new NoSuchMethodException("Invalid getter return type, " +
-                        "should be " + clazz + ", found " +
-                        getter.getReturnType());
-            }
-        }
-        if (attr.isWritable()) {
-            Method setter = getManagementMethod(mbeanInterface, "set" +
-                    attributeName,
-                    clazz);
-            if (setter.getReturnType().equals(Void.TYPE)) {
-                methods.add(setter);
-            } else {
-                throw new NoSuchMethodException("Invalid setter return type, " +
-                        "should be void, found " + setter.getReturnType());
-            }
-        }
-        return methods;
-    }
-
-    /**
-     * Retrieve the MBean operation <code>Method</code>
-     * located in the <code>mbeanInterface</code> MBean interface that
-     * corresponds to the provided <code>op</code>
-     * <code>MBeanOperationInfo</code> parameter.
-     * @param mbeanInterface the management interface.
-     * Can be a standard MBean or MXBean interface, or a Java class
-     * annotated with {@link MBean &#64;MBean} or {@link MXBean &#64;MXBean}.
-     * @param op The operation we want the method for.
-     * @return the method corresponding to the provided MBeanOperationInfo.
-     * @throws java.lang.NoSuchMethodException if no method exists
-     * for the given {@link MBeanOperationInfo MBeanOperationInfo}.
-     * @throws java.lang.IllegalArgumentException if at least one
-     * of the two parameters is null.
-     * @throws java.lang.ClassNotFoundException if one of the
-     * classes named in the operation signature array is not found.
-     * @throws java.lang.SecurityException if this exception is
-     * encountered while introspecting the MBean interface.
-     */
-    public static Method findOperationMethod(Class<?> mbeanInterface,
-            MBeanOperationInfo op)
-            throws ClassNotFoundException, NoSuchMethodException {
-        if (mbeanInterface == null || op == null) {
-            throw new IllegalArgumentException("mbeanInterface or op " +
-                    "parameter is null");
-        }
-        List<Class<?>> classes = new ArrayList<Class<?>>();
-        for (MBeanParameterInfo info : op.getSignature()) {
-            Class<?> clazz = resolveClass(info, info.getType(), mbeanInterface);
-            classes.add(clazz);
-        }
-        Class<?>[] signature = new Class<?>[classes.size()];
-        classes.toArray(signature);
-        return getManagementMethod(mbeanInterface, op.getName(), signature);
-    }
-
     /**
      * <p>Allows the MBean to perform any operations it needs before
      * being registered in the MBean server.  If the name of the MBean
@@ -1470,14 +1034,10 @@
      * registered in the MBean server.</p>
      *
      * <p>The default implementation of this method returns the {@code name}
-     * parameter. If the
-     * {@link Options#isMBeanRegistrationForwarded MBeanRegistrationForwarded}
-     * option is set to true, then this method is forwarded to the object
-     * returned by the {@link #getImplementation getImplementation()} method.
-     * The name returned by this call is then returned by this method.
-     * It does nothing else for Standard MBeans.  For MXBeans, it records
-     * the {@code MBeanServer} and {@code ObjectName} parameters so they can
-     * be used to translate inter-MXBean references.</p>
+     * parameter.  It does nothing else for
+     * Standard MBeans.  For MXBeans, it records the {@code MBeanServer}
+     * and {@code ObjectName} parameters so they can be used to translate
+     * inter-MXBean references.</p>
      *
      * <p>It is good practice for a subclass that overrides this method
      * to call the overridden method via {@code super.preRegister(...)}.
@@ -1512,13 +1072,7 @@
      */
     public ObjectName preRegister(MBeanServer server, ObjectName name)
             throws Exception {
-        // Forward preRegister before to call register and
-        // inject parameters.
-        if(shouldForwardMBeanRegistration())
-            name = ((MBeanRegistration)getImplementation()).
-                    preRegister(server, name);
         mbean.register(server, name);
-        MBeanInjector.inject(mbean.getWrappedObject(), server, name);
         return name;
     }
 
@@ -1526,11 +1080,7 @@
      * <p>Allows the MBean to perform any operations needed after having been
      * registered in the MBean server or after the registration has failed.</p>
      *
-     * <p>If the
-     * {@link Options#isMBeanRegistrationForwarded MBeanRegistrationForwarded}
-     * option is set to true, then this method is forwarded to the object
-     * returned by the {@link #getImplementation getImplementation()} method.
-     * The default implementation of this method does nothing else for
+     * <p>The default implementation of this method does nothing for
      * Standard MBeans.  For MXBeans, it undoes any work done by
      * {@link #preRegister preRegister} if registration fails.</p>
      *
@@ -1548,21 +1098,13 @@
     public void postRegister(Boolean registrationDone) {
         if (!registrationDone)
             mbean.unregister();
-        if(shouldForwardMBeanRegistration())
-            ((MBeanRegistration)getImplementation()).
-                    postRegister(registrationDone);
     }
 
     /**
      * <p>Allows the MBean to perform any operations it needs before
      * being unregistered by the MBean server.</p>
      *
-     * <p>If the
-     * {@link Options#isMBeanRegistrationForwarded MBeanRegistrationForwarded}
-     * option is set to true, then this method is forwarded to the object
-     * returned by the {@link #getImplementation getImplementation()} method.
-     * Other than that, the default implementation of this method does nothing.
-     * </p>
+     * <p>The default implementation of this method does nothing.</p>
      *
      * <p>It is good practice for a subclass that overrides this method
      * to call the overridden method via {@code super.preDeregister(...)}.</p>
@@ -1574,19 +1116,13 @@
      * @since 1.6
      */
     public void preDeregister() throws Exception {
-        if(shouldForwardMBeanRegistration())
-            ((MBeanRegistration)getImplementation()).preDeregister();
     }
 
     /**
      * <p>Allows the MBean to perform any operations needed after having been
      * unregistered in the MBean server.</p>
      *
-     * <p>If the
-     * {@link Options#isMBeanRegistrationForwarded MBeanRegistrationForwarded}
-     * option is set to true, then this method is forwarded to the object
-     * returned by the {@link #getImplementation getImplementation()} method.
-     * The default implementation of this method does nothing else for
+     * <p>The default implementation of this method does nothing for
      * Standard MBeans.  For MXBeans, it removes any information that
      * was recorded by the {@link #preRegister preRegister} method.</p>
      *
@@ -1599,15 +1135,8 @@
      */
     public void postDeregister() {
         mbean.unregister();
-        if(shouldForwardMBeanRegistration())
-            ((MBeanRegistration)getImplementation()).postDeregister();
     }
 
-    private boolean shouldForwardMBeanRegistration() {
-        return (getImplementation() instanceof MBeanRegistration) &&
-           (options instanceof Options &&
-                ((Options) options).isMBeanRegistrationForwarded());
-    }
     //
     // MBeanInfo immutability
     //
--- a/src/share/classes/javax/management/event/EventClient.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1104 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import com.sun.jmx.event.DaemonThreadFactory;
-import com.sun.jmx.event.LeaseRenewer;
-import com.sun.jmx.event.ReceiverBuffer;
-import com.sun.jmx.event.RepeatedSingletonJob;
-import com.sun.jmx.mbeanserver.PerThreadGroupPool;
-import com.sun.jmx.remote.util.ClassLogger;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.Executor;
-
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.remote.NotificationResult;
-import javax.management.remote.TargetedNotification;
-
-/**
- * <p>This class is used to manage its notification listeners on the client
- * side in the same way as on the MBean server side. This class needs to work
- * with an {@link EventClientDelegateMBean} on the server side.</p>
- *
- * <P>A user can specify an {@link EventRelay} object to specify how to receive
- * notifications forwarded by the {@link EventClientDelegateMBean}. By default,
- * the class {@link FetchingEventRelay} is used.</p>
- *
- * <p>A user can specify an {@link java.util.concurrent.Executor Executor}
- * to distribute notifications to local listeners. If no executor is
- * specified, the thread in the {@link EventRelay} which calls {@link
- * EventReceiver#receive EventReceiver.receive} will be reused to distribute
- * the notifications (in other words, to call the {@link
- * NotificationListener#handleNotification handleNotification} method of the
- * appropriate listeners). It is useful to make a separate thread do this
- * distribution in some cases. For example, if network communication is slow,
- * the forwarding thread can concentrate on communication while, locally,
- * the distributing thread distributes the received notifications. Another
- * usage is to share a thread pool between many clients, for scalability.
- * Note, though, that if the {@code Executor} can create more than one thread
- * then it is possible that listeners will see notifications in a different
- * order from the order in which they were sent.</p>
- *
- * <p>An object of this class sends notifications to listeners added with
- * {@link #addEventClientListener}.  The {@linkplain Notification#getType()
- * type} of each such notification is one of {@link #FAILED}, {@link #NONFATAL},
- * or {@link #NOTIFS_LOST}.</p>
- *
- * @since JMX 2.0
- */
-public class EventClient implements EventConsumer, NotificationManager {
-
-    /**
-     * <p>A notification string type used by an {@code EventClient} object
-     * to inform a listener added by {@link #addEventClientListener} that
-     * it failed to get notifications from a remote server, and that it is
-     * possible that no more notifications will be delivered.</p>
-     *
-     * @see #addEventClientListener
-     * @see EventReceiver#failed
-     */
-    public static final String FAILED = "jmx.event.service.failed";
-
-    /**
-     * <p>Reports that an unexpected exception has been received by the {@link
-     * EventRelay} object but that it is non-fatal. For example, a notification
-     * received is not serializable or its class is not found.</p>
-     *
-     * @see #addEventClientListener
-     * @see EventReceiver#nonFatal
-     */
-    public static final String NONFATAL = "jmx.event.service.nonfatal";
-
-    /**
-     * <p>A notification string type used by an {@code EventClient} object
-     * to inform a listener added by {@link #addEventClientListener
-     * addEventClientListener} that it has detected that notifications have
-     * been lost.  The {@link Notification#getUserData() userData} of the
-     * notification is a Long which is an upper bound on the number of lost
-     * notifications that have just been detected.</p>
-     *
-     * @see #addEventClientListener
-     */
-    public static final String NOTIFS_LOST = "jmx.event.service.notifs.lost";
-
-    /**
-     * The default lease time that EventClient instances will request, in
-     * milliseconds.  This value is {@value}.
-     *
-     * @see EventClientDelegateMBean#lease
-     */
-    public static final long DEFAULT_REQUESTED_LEASE_TIME = 300000;
-
-    /**
-     * <p>Constructs a default {@code EventClient} object.</p>
-     *
-     * <p>This object creates a {@link FetchingEventRelay} object to
-     * receive notifications forwarded by the {@link EventClientDelegateMBean}.
-     * The {@link EventClientDelegateMBean} that it works with is the
-     * one registered with the {@linkplain EventClientDelegate#OBJECT_NAME
-     * default ObjectName}.  The thread from the {@link FetchingEventRelay}
-     * object that fetches the notifications is also used to distribute them.
-     *
-     * @param conn An {@link MBeanServerConnection} object used to communicate
-     * with an {@link EventClientDelegateMBean} MBean.
-     *
-     * @throws IllegalArgumentException If {@code conn} is null.
-     * @throws IOException If an I/O error occurs when communicating with the
-     * {@code EventClientDelegateMBean}.
-     */
-    public EventClient(MBeanServerConnection conn) throws IOException {
-        this(EventClientDelegate.getProxy(conn));
-    }
-
-    /**
-     * Constructs an {@code EventClient} object with a specified
-     * {@link EventClientDelegateMBean}.
-     *
-     * <p>This object creates a {@link FetchingEventRelay} object to receive
-     * notifications forwarded by the {@link EventClientDelegateMBean}.  The
-     * thread from the {@link FetchingEventRelay} object that fetches the
-     * notifications is also used to distribute them.
-     *
-     * @param delegate An {@link EventClientDelegateMBean} object to work with.
-     *
-     * @throws IllegalArgumentException If {@code delegate} is null.
-     * @throws IOException If an I/O error occurs when communicating with the
-     * the {@link EventClientDelegateMBean}.
-     */
-    public EventClient(EventClientDelegateMBean delegate)
-    throws IOException {
-        this(delegate, null, null, null, DEFAULT_REQUESTED_LEASE_TIME);
-    }
-
-    /**
-     * Constructs an {@code EventClient} object with the specified
-     * {@link EventClientDelegateMBean}, {@link EventRelay}
-     * object, and distributing thread.
-     *
-     * @param delegate An {@link EventClientDelegateMBean} object to work with.
-     * Usually, this will be a proxy constructed using
-     * {@link EventClientDelegate#getProxy}.
-     * @param eventRelay An object used to receive notifications
-     * forwarded by the {@link EventClientDelegateMBean}. If {@code null}, a
-     * {@link FetchingEventRelay} object will be used.
-     * @param distributingExecutor Used to distribute notifications to local
-     * listeners. Only one job at a time will be submitted to this Executor.
-     * If {@code distributingExecutor} is {@code null}, the thread that calls
-     * {@link EventReceiver#receive EventReceiver.receive} from the {@link
-     * EventRelay} object is used.
-     * @param leaseScheduler An object that will be used to schedule the
-     * periodic {@linkplain EventClientDelegateMBean#lease lease updates}.
-     * If {@code null}, a default scheduler will be used.
-     * @param requestedLeaseTime The lease time used to keep this client alive
-     * in the {@link EventClientDelegateMBean}.  A value of zero is equivalent
-     * to the {@linkplain #DEFAULT_REQUESTED_LEASE_TIME default value}.
-     *
-     * @throws IllegalArgumentException If {@code delegate} is null.
-     * @throws IOException If an I/O error occurs when communicating with the
-     * {@link EventClientDelegateMBean}.
-     */
-    public EventClient(EventClientDelegateMBean delegate,
-            EventRelay eventRelay,
-            Executor distributingExecutor,
-            ScheduledExecutorService leaseScheduler,
-            long requestedLeaseTime)
-            throws IOException {
-        if (delegate == null) {
-            throw new IllegalArgumentException("Null EventClientDelegateMBean");
-        }
-
-        if (requestedLeaseTime == 0)
-            requestedLeaseTime = DEFAULT_REQUESTED_LEASE_TIME;
-        else if (requestedLeaseTime < 0) {
-            throw new IllegalArgumentException(
-                    "Negative lease time: " + requestedLeaseTime);
-        }
-
-        eventClientDelegate = delegate;
-
-        if (eventRelay != null) {
-            this.eventRelay = eventRelay;
-        } else {
-            try {
-                this.eventRelay = new FetchingEventRelay(delegate);
-            } catch (IOException ioe) {
-                throw ioe;
-            } catch (Exception e) {
-                // impossible?
-                final IOException ioee = new IOException(e.toString());
-                ioee.initCause(e);
-                throw ioee;
-            }
-        }
-
-        if (distributingExecutor == null)
-            distributingExecutor = callerExecutor;
-        this.distributingExecutor = distributingExecutor;
-        this.dispatchingJob = new DispatchingJob();
-
-        clientId = this.eventRelay.getClientId();
-
-        this.requestedLeaseTime = requestedLeaseTime;
-        if (leaseScheduler == null)
-            leaseScheduler = defaultLeaseScheduler();
-        leaseRenewer = new LeaseRenewer(leaseScheduler, renewLease);
-
-        if (logger.traceOn()) {
-            logger.trace("init", "New EventClient: "+clientId);
-        }
-    }
-
-    private static ScheduledExecutorService defaultLeaseScheduler() {
-        // The default lease scheduler uses a ScheduledThreadPoolExecutor
-        // with a maximum of 20 threads.  This means that if you have many
-        // EventClient instances and some of them get blocked (because of an
-        // unresponsive network, for example), then even the instances that
-        // are connected to responsive servers may have their leases expire.
-        // XXX check if the above is true and possibly fix.
-        PerThreadGroupPool.Create<ScheduledThreadPoolExecutor> create =
-                new PerThreadGroupPool.Create<ScheduledThreadPoolExecutor>() {
-            public ScheduledThreadPoolExecutor createThreadPool(ThreadGroup group) {
-                ThreadFactory daemonThreadFactory = new DaemonThreadFactory(
-                        "JMX EventClient lease renewer %d");
-                ScheduledThreadPoolExecutor executor =
-                        new ScheduledThreadPoolExecutor(20, daemonThreadFactory);
-                executor.setKeepAliveTime(1, TimeUnit.SECONDS);
-                executor.allowCoreThreadTimeOut(true);
-                if (setRemoveOnCancelPolicy != null) {
-                    try {
-                        setRemoveOnCancelPolicy.invoke(executor, true);
-                    } catch (Exception e) {
-                        logger.trace("setRemoveOnCancelPolicy", e);
-                    }
-                }
-                // By default, a ScheduledThreadPoolExecutor will keep jobs
-                // in its queue even after they have been cancelled.  They
-                // will only be removed when their scheduled time arrives.
-                // Since the job references the LeaseRenewer which references
-                // this EventClient, this can lead to a moderately large number
-                // of objects remaining referenced until the renewal time
-                // arrives.  Hence the above call, which removes the job from
-                // the queue as soon as it is cancelled.  Since the call is
-                // new with JDK 7, we invoke it via reflection to make it
-                // easier to use this code on JDK 6.
-                return executor;
-            }
-        };
-        return leaseRenewerThreadPool.getThreadPoolExecutor(create);
-    }
-
-    private static final Method setRemoveOnCancelPolicy;
-    static {
-        Method m;
-        try {
-            m = ScheduledThreadPoolExecutor.class.getMethod(
-                    "setRemoveOnCancelPolicy", boolean.class);
-        } catch (Exception e) {
-            m = null;
-        }
-        setRemoveOnCancelPolicy = m;
-    }
-
-    /**
-     * <p>Closes this EventClient, removes all listeners and stops receiving
-     * notifications.</p>
-     *
-     * <p>This method calls {@link
-     * EventClientDelegateMBean#removeClient(String)} and {@link
-     * EventRelay#stop}.  Both operations occur even if one of them
-     * throws an {@code IOException}.
-     *
-     * @throws IOException if an I/O error occurs when communicating with
-     * {@link EventClientDelegateMBean}, or if {@link EventRelay#stop}
-     * throws an {@code IOException}.
-     */
-    public void close() throws IOException {
-        if (logger.traceOn()) {
-            logger.trace("close", clientId);
-        }
-
-        synchronized(listenerInfoMap) {
-            if (closed) {
-                return;
-            }
-
-            closed = true;
-            listenerInfoMap.clear();
-        }
-
-        if (leaseRenewer != null)
-            leaseRenewer.close();
-
-        IOException ioe = null;
-        try {
-            eventRelay.stop();
-        } catch (IOException e) {
-            ioe = e;
-            logger.debug("close", "EventRelay.stop", e);
-        }
-
-        try {
-            eventClientDelegate.removeClient(clientId);
-        } catch (Exception e) {
-            if (e instanceof IOException)
-                ioe = (IOException) e;
-            else
-                ioe = new IOException(e);
-            logger.debug("close",
-                    "Got exception when removing "+clientId, e);
-        }
-
-        if (ioe != null)
-            throw ioe;
-    }
-
-    /**
-     * <p>Determine if this {@code EventClient} is closed.</p>
-     *
-     * @return True if the {@code EventClient} is closed.
-     */
-    public boolean closed() {
-        return closed;
-    }
-
-    /**
-     * <p>Return the {@link EventRelay} associated with this
-     * {@code EventClient}.</p>
-     *
-     * @return The {@link EventRelay} object used.
-     */
-    public EventRelay getEventRelay() {
-        return eventRelay;
-    }
-
-    /**
-     * <p>Return the lease time that this {@code EventClient} requests
-     * on every lease renewal.</p>
-     *
-     * @return The requested lease time.
-     *
-     * @see EventClientDelegateMBean#lease
-     */
-    public long getRequestedLeaseTime() {
-        return requestedLeaseTime;
-    }
-
-    /**
-     * @see javax.management.MBeanServerConnection#addNotificationListener(
-     * ObjectName, NotificationListener, NotificationFilter, Object).
-     */
-    public void addNotificationListener(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback)
-            throws InstanceNotFoundException, IOException {
-        if (logger.traceOn()) {
-            logger.trace("addNotificationListener", "");
-        }
-
-        checkState();
-
-        Integer listenerId;
-        try {
-            listenerId =
-                    eventClientDelegate.addListener(clientId, name, filter);
-        } catch (EventClientNotFoundException ecnfe) {
-            final IOException ioe = new IOException(ecnfe.getMessage());
-            ioe.initCause(ecnfe);
-            throw ioe;
-        }
-
-        synchronized(listenerInfoMap) {
-            listenerInfoMap.put(listenerId,  new ListenerInfo(
-                    name,
-                    listener,
-                    filter,
-                    handback,
-                    false));
-        }
-
-        startListening();
-    }
-
-    /**
-     * @see javax.management.MBeanServerConnection#removeNotificationListener(
-     * ObjectName, NotificationListener).
-     */
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener)
-            throws InstanceNotFoundException,
-            ListenerNotFoundException,
-            IOException {
-        if (logger.traceOn()) {
-            logger.trace("removeNotificationListener", "");
-        }
-        checkState();
-
-        for (Integer id : getListenerInfo(name, listener, false)) {
-            removeListener(id);
-        }
-    }
-
-    /**
-     * @see javax.management.MBeanServerConnection#removeNotificationListener(
-     * ObjectName, NotificationListener, NotificationFilter, Object).
-     */
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback)
-            throws InstanceNotFoundException,
-            ListenerNotFoundException,
-            IOException {
-        if (logger.traceOn()) {
-            logger.trace("removeNotificationListener", "with all arguments.");
-        }
-        checkState();
-        final Integer listenerId =
-                getListenerInfo(name, listener, filter, handback, false);
-
-        removeListener(listenerId);
-    }
-
-    /**
-     * @see javax.management.event.EventConsumer#unsubscribe(
-     * ObjectName, NotificationListener).
-     */
-    public void unsubscribe(ObjectName name,
-            NotificationListener listener)
-            throws ListenerNotFoundException, IOException {
-        if (logger.traceOn()) {
-            logger.trace("unsubscribe", "");
-        }
-        checkState();
-        final Integer listenerId =
-                getMatchedListenerInfo(name, listener, true);
-
-        synchronized(listenerInfoMap) {
-            if (listenerInfoMap.remove(listenerId) == null) {
-                throw new ListenerNotFoundException();
-            }
-        }
-
-        stopListening();
-
-        try {
-            eventClientDelegate.removeListenerOrSubscriber(clientId, listenerId);
-        } catch (InstanceNotFoundException e) {
-            logger.trace("unsubscribe", "removeSubscriber", e);
-        } catch (EventClientNotFoundException cnfe) {
-            logger.trace("unsubscribe", "removeSubscriber", cnfe);
-        }
-    }
-
-    /**
-     * @see javax.management.event.EventConsumer#subscribe(
-     * ObjectName, NotificationListener, NotificationFilter, Object).
-     */
-    public void subscribe(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback) throws IOException {
-        if (logger.traceOn()) {
-            logger.trace("subscribe", "");
-        }
-
-        checkState();
-
-        Integer listenerId;
-        try {
-            listenerId =
-                    eventClientDelegate.addSubscriber(clientId, name, filter);
-        } catch (EventClientNotFoundException ecnfe) {
-            final IOException ioe = new IOException(ecnfe.getMessage());
-            ioe.initCause(ecnfe);
-            throw ioe;
-        }
-
-        synchronized(listenerInfoMap) {
-            listenerInfoMap.put(listenerId,  new ListenerInfo(
-                    name,
-                    listener,
-                    filter,
-                    handback,
-                    true));
-        }
-
-        startListening();
-    }
-
-    /**
-     * <p>Adds a set of listeners to the remote MBeanServer.  This method can
-     * be used to copy the listeners from one {@code EventClient} to another.</p>
-     *
-     * <p>A listener is represented by a {@link ListenerInfo} object. The listener
-     * is added by calling {@link #subscribe(ObjectName,
-     * NotificationListener, NotificationFilter, Object)} if the method
-     * {@link ListenerInfo#isSubscription() isSubscription}
-     * returns {@code true}; otherwise it is added by calling
-     * {@link #addNotificationListener(ObjectName, NotificationListener,
-     * NotificationFilter, Object)}.</p>
-     *
-     * <P>The method returns the listeners which were added successfully. The
-     * elements in the returned collection are a subset of the elements in
-     * {@code listeners}. If all listeners were added successfully, the two
-     * collections are the same. If no listener was added successfully, the
-     * returned collection is empty.</p>
-     *
-     * @param listeners the listeners to add.
-     *
-     * @return The listeners that were added successfully.
-     *
-     * @throws IOException If an I/O error occurs.
-     *
-     * @see #getListeners()
-     */
-    public Collection<ListenerInfo> addListeners(Collection<ListenerInfo> listeners)
-    throws IOException {
-        if (logger.traceOn()) {
-            logger.trace("addListeners", "");
-        }
-
-        checkState();
-
-        if (listeners == null || listeners.isEmpty())
-            return Collections.emptySet();
-
-        final List<ListenerInfo> list = new ArrayList<ListenerInfo>();
-        for (ListenerInfo l : listeners) {
-            try {
-                if (l.isSubscription()) {
-                    subscribe(l.getObjectName(),
-                            l.getListener(),
-                            l.getFilter(),
-                            l.getHandback());
-                } else {
-                    addNotificationListener(l.getObjectName(),
-                            l.getListener(),
-                            l.getFilter(),
-                            l.getHandback());
-                }
-
-                list.add(l);
-            } catch (Exception e) {
-                if (logger.traceOn()) {
-                    logger.trace("addListeners", "failed to add: "+l, e);
-                }
-            }
-        }
-
-        return list;
-    }
-
-    /**
-     * <p>Returns the collection of listeners that have been added through
-     * this {@code EventClient} and not subsequently removed.  The returned
-     * collection contains one entry for every listener added with
-     * {@link #addNotificationListener addNotificationListener} or
-     * {@link #subscribe subscribe} and not subsequently removed with
-     * {@link #removeNotificationListener removeNotificationListener} or
-     * {@link #unsubscribe unsubscribe}, respectively.</p>
-     *
-     * @return A collection of listener information. Empty if there are no
-     * current listeners or if this {@code EventClient} has been {@linkplain
-     * #close closed}.
-     *
-     * @see #addListeners
-     */
-    public Collection<ListenerInfo> getListeners() {
-        if (logger.traceOn()) {
-            logger.trace("getListeners", "");
-        }
-
-        synchronized(listenerInfoMap) {
-            return Collections.unmodifiableCollection(listenerInfoMap.values());
-        }
-    }
-
-    /**
-     * Adds a listener to receive the {@code EventClient} notifications specified in
-     * {@link #getEventClientNotificationInfo}.
-     *
-     * @param listener A listener to receive {@code EventClient} notifications.
-     * @param filter A filter to select which notifications are to be delivered
-     * to the listener, or {@code null} if all notifications are to be delivered.
-     * @param handback An object to be given to the listener along with each
-     * notification. Can be null.
-     * @throws NullPointerException If listener is null.
-     * @see #removeEventClientListener
-     */
-    public void addEventClientListener(NotificationListener listener,
-            NotificationFilter filter,
-            Object handback) {
-        if (logger.traceOn()) {
-            logger.trace("addEventClientListener", "");
-        }
-        broadcaster.addNotificationListener(listener, filter, handback);
-    }
-
-    /**
-     * Removes a listener added to receive {@code EventClient} notifications specified in
-     * {@link #getEventClientNotificationInfo}.
-     *
-     * @param listener A listener to receive {@code EventClient} notifications.
-     * @throws NullPointerException If listener is null.
-     * @throws ListenerNotFoundException If the listener is not added to
-     * this {@code EventClient}.
-     */
-    public void removeEventClientListener(NotificationListener listener)
-    throws ListenerNotFoundException {
-        if (logger.traceOn()) {
-            logger.trace("removeEventClientListener", "");
-        }
-        broadcaster.removeNotificationListener(listener);
-    }
-
-    /**
-     * <p>Get the types of notification that an {@code EventClient} can send
-     * to listeners added with {@link #addEventClientListener
-     * addEventClientListener}.</p>
-     *
-     * @return Types of notification emitted by this {@code EventClient}.
-     *
-     * @see #FAILED
-     * @see #NONFATAL
-     * @see #NOTIFS_LOST
-     */
-    public MBeanNotificationInfo[] getEventClientNotificationInfo() {
-        return myInfo.clone();
-    }
-
-    private static boolean match(ListenerInfo li,
-            ObjectName name,
-            NotificationListener listener,
-            boolean subscribed) {
-        return li.getObjectName().equals(name) &&
-                li.getListener() == listener &&
-                li.isSubscription() == subscribed;
-    }
-
-    private static boolean match(ListenerInfo li,
-            ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback,
-            boolean subscribed) {
-        return li.getObjectName().equals(name) &&
-                li.getFilter() == filter &&
-                li.getListener() == listener &&
-                li.getHandback() == handback &&
-                li.isSubscription() == subscribed;
-    }
-
-// ---------------------------------------------------
-// private classes
-// ---------------------------------------------------
-    private class DispatchingJob extends RepeatedSingletonJob {
-        public DispatchingJob() {
-            super(distributingExecutor);
-        }
-
-        public boolean isSuspended() {
-            return closed || buffer.size() == 0;
-        }
-
-        public void task() {
-            TargetedNotification[] tns ;
-            int lost = 0;
-
-            synchronized(buffer) {
-                tns = buffer.removeNotifs();
-                lost = buffer.removeLost();
-            }
-
-            if ((tns == null || tns.length == 0)
-            && lost == 0) {
-                return;
-            }
-
-            // forwarding
-            if (tns != null && tns.length > 0) {
-                if (logger.traceOn()) {
-                    logger.trace("DispatchingJob-task",
-                            "Forwarding: "+tns.length);
-                }
-                for (TargetedNotification tn : tns) {
-                    final ListenerInfo li = listenerInfoMap.get(tn.getListenerID());
-                    try {
-                        li.getListener().handleNotification(tn.getNotification(),
-                                li.getHandback());
-                    } catch (Exception e) {
-                        logger.fine(
-                                "DispatchingJob.task", "listener got exception", e);
-                    }
-                }
-            }
-
-            if (lost > 0) {
-                if (logger.traceOn()) {
-                    logger.trace("DispatchingJob-task",
-                            "lost: "+lost);
-                }
-                final Notification n = new Notification(NOTIFS_LOST,
-                        EventClient.this,
-                        myNotifCounter.getAndIncrement(),
-                        System.currentTimeMillis(),
-                        "Lost notifications.");
-                n.setUserData(new Long(lost));
-                broadcaster.sendNotification(n);
-            }
-        }
-    }
-
-
-    private class EventReceiverImpl implements EventReceiver {
-        public void receive(NotificationResult nr) {
-            if (logger.traceOn()) {
-                logger.trace("MyEventReceiver-receive", "");
-            }
-
-            synchronized(buffer) {
-                buffer.addNotifs(nr);
-
-                dispatchingJob.resume();
-            }
-        }
-
-        public void failed(Throwable t) {
-            if (logger.traceOn()) {
-                logger.trace("MyEventReceiver-failed", "", t);
-            }
-            final Notification n = new Notification(FAILED,
-                    this,
-                    myNotifCounter.getAndIncrement(),
-                    System.currentTimeMillis());
-            n.setSource(t);
-            broadcaster.sendNotification(n);
-        }
-
-        public void nonFatal(Exception e) {
-            if (logger.traceOn()) {
-                logger.trace("MyEventReceiver-nonFatal", "", e);
-            }
-
-            final Notification n = new Notification(NONFATAL,
-                    this,
-                    myNotifCounter.getAndIncrement(),
-                    System.currentTimeMillis());
-            n.setSource(e);
-            broadcaster.sendNotification(n);
-        }
-    }
-
-// ----------------------------------------------------
-// private class
-// ----------------------------------------------------
-
-
-// ----------------------------------------------------
-// private methods
-// ----------------------------------------------------
-    private Integer getListenerInfo(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback,
-            boolean subscribed) throws ListenerNotFoundException {
-
-        synchronized(listenerInfoMap) {
-            for (Map.Entry<Integer, ListenerInfo> entry :
-                    listenerInfoMap.entrySet()) {
-                ListenerInfo li = entry.getValue();
-                if (match(li, name, listener, filter, handback, subscribed)) {
-                    return entry.getKey();
-                }
-            }
-        }
-
-        throw new ListenerNotFoundException();
-    }
-
-    private Integer getMatchedListenerInfo(ObjectName name,
-            NotificationListener listener,
-            boolean subscribed) throws ListenerNotFoundException {
-
-        synchronized(listenerInfoMap) {
-            for (Map.Entry<Integer, ListenerInfo> entry :
-                    listenerInfoMap.entrySet()) {
-                ListenerInfo li = entry.getValue();
-                if (li.getObjectName().equals(name) &&
-                        li.getListener() == listener &&
-                        li.isSubscription() == subscribed) {
-                    return entry.getKey();
-                }
-            }
-        }
-
-        throw new ListenerNotFoundException();
-    }
-
-    private Collection<Integer> getListenerInfo(ObjectName name,
-            NotificationListener listener,
-            boolean subscribed) throws ListenerNotFoundException {
-
-        final ArrayList<Integer> ids = new ArrayList<Integer>();
-        synchronized(listenerInfoMap) {
-            for (Map.Entry<Integer, ListenerInfo> entry :
-                    listenerInfoMap.entrySet()) {
-                ListenerInfo li = entry.getValue();
-                if (match(li, name, listener, subscribed)) {
-                    ids.add(entry.getKey());
-                }
-            }
-        }
-
-        if (ids.isEmpty()) {
-            throw new ListenerNotFoundException();
-        }
-
-        return ids;
-    }
-
-    private void checkState() throws IOException {
-        synchronized(listenerInfoMap) {
-            if (closed) {
-                throw new IOException("Ended!");
-            }
-        }
-    }
-
-    private void startListening() throws IOException {
-        synchronized(listenerInfoMap) {
-            if (!startedListening && listenerInfoMap.size() > 0) {
-                eventRelay.setEventReceiver(myReceiver);
-            }
-
-            startedListening = true;
-
-            if (logger.traceOn()) {
-                logger.trace("startListening", "listening");
-            }
-        }
-    }
-
-    private void stopListening() throws IOException {
-        synchronized(listenerInfoMap) {
-            if (listenerInfoMap.size() == 0 && startedListening) {
-                eventRelay.setEventReceiver(null);
-
-                startedListening = false;
-
-                if (logger.traceOn()) {
-                    logger.trace("stopListening", "non listening");
-                }
-            }
-        }
-    }
-
-    private void removeListener(Integer id)
-    throws InstanceNotFoundException,
-            ListenerNotFoundException,
-            IOException {
-        synchronized(listenerInfoMap) {
-            if (listenerInfoMap.remove(id) == null) {
-                throw new ListenerNotFoundException();
-            }
-
-            stopListening();
-        }
-
-        try {
-            eventClientDelegate.removeListenerOrSubscriber(clientId, id);
-        } catch (EventClientNotFoundException cnfe) {
-            logger.trace("removeListener", "ecd.removeListener", cnfe);
-        }
-    }
-
-
-// ----------------------------------------------------
-// private variables
-// ----------------------------------------------------
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "EventClient");
-
-    private final Executor distributingExecutor;
-    private final EventClientDelegateMBean eventClientDelegate;
-    private final EventRelay eventRelay;
-    private volatile String clientId = null;
-    private final long requestedLeaseTime;
-
-    private final ReceiverBuffer buffer = new ReceiverBuffer();
-
-    private final EventReceiverImpl myReceiver =
-            new EventReceiverImpl();
-    private final DispatchingJob dispatchingJob;
-
-    private final HashMap<Integer, ListenerInfo> listenerInfoMap =
-            new HashMap<Integer, ListenerInfo>();
-
-    private volatile boolean closed = false;
-
-    private volatile boolean startedListening = false;
-
-    // Could change synchronization here. But at worst a race will mean
-    // sequence numbers are not contiguous, which may not matter much.
-    private final AtomicLong myNotifCounter = new AtomicLong();
-
-    private final static MBeanNotificationInfo[] myInfo =
-            new MBeanNotificationInfo[] {
-        new MBeanNotificationInfo(
-                new String[] {FAILED, NONFATAL, NOTIFS_LOST},
-                Notification.class.getName(),
-                "Notifications that can be sent to a listener added with " +
-                "EventClient.addEventClientListener")};
-
-    private final NotificationBroadcasterSupport broadcaster =
-            new NotificationBroadcasterSupport();
-
-    private final static Executor callerExecutor = new Executor() {
-        // DirectExecutor using caller thread
-        public void execute(Runnable r) {
-            r.run();
-        }
-    };
-
-    private static void checkInit(final MBeanServerConnection conn,
-            final ObjectName delegateName)
-            throws IOException {
-        if (conn == null) {
-            throw new IllegalArgumentException("No connection specified");
-        }
-        if (delegateName != null &&
-                (!conn.isRegistered(delegateName))) {
-            throw new IllegalArgumentException(
-                    delegateName +
-                    ": not found");
-        }
-        if (delegateName == null &&
-                (!conn.isRegistered(
-                EventClientDelegate.OBJECT_NAME))) {
-            throw new IllegalArgumentException(
-                    EventClientDelegate.OBJECT_NAME +
-                    ": not found");
-        }
-    }
-
-// ----------------------------------------------------
-// private event lease issues
-// ----------------------------------------------------
-    private Callable<Long> renewLease = new Callable<Long>() {
-        public Long call() throws IOException, EventClientNotFoundException {
-            return eventClientDelegate.lease(clientId, requestedLeaseTime);
-        }
-    };
-
-    private final LeaseRenewer leaseRenewer;
-
-// ------------------------------------------------------------------------
-    /**
-     * Constructs an {@code MBeanServerConnection} that uses an {@code EventClient} object,
-     * if the underlying connection has an {@link EventClientDelegateMBean}.
-     * <P> The {@code EventClient} object creates a default
-     * {@link FetchingEventRelay} object to
-     * receive notifications forwarded by the {@link EventClientDelegateMBean}.
-     * The {@link EventClientDelegateMBean} it works with is the
-     * default one registered with the ObjectName
-     * {@link EventClientDelegate#OBJECT_NAME
-     * OBJECT_NAME}.
-     * The thread from the {@link FetchingEventRelay} object that fetches the
-     * notifications is also used to distribute them.
-     *
-     * @param conn An {@link MBeanServerConnection} object used to communicate
-     * with an {@link EventClientDelegateMBean}.
-     * @throws IllegalArgumentException If the value of {@code conn} is null,
-     *         or the default {@link EventClientDelegateMBean} is not registered.
-     * @throws IOException If an I/O error occurs.
-     */
-    public static MBeanServerConnection getEventClientConnection(
-            final MBeanServerConnection conn)
-            throws IOException {
-        return getEventClientConnection(conn, null);
-    }
-
-    /**
-     * Constructs an MBeanServerConnection that uses an {@code EventClient}
-     * object with a user-specific {@link EventRelay}
-     * object.
-     * <P>
-     * The {@link EventClientDelegateMBean} which it works with is the
-     * default one registered with the ObjectName
-     * {@link EventClientDelegate#OBJECT_NAME
-     * OBJECT_NAME}
-     * The thread that calls {@link EventReceiver#receive
-     * EventReceiver.receive} from the {@link EventRelay} object is used
-     * to distribute notifications to their listeners.
-     *
-     * @param conn An {@link MBeanServerConnection} object used to communicate
-     * with an {@link EventClientDelegateMBean}.
-     * @param eventRelay A user-specific object used to receive notifications
-     * forwarded by the {@link EventClientDelegateMBean}. If null, the default
-     * {@link FetchingEventRelay} object is used.
-     * @throws IllegalArgumentException If the value of {@code conn} is null,
-     *         or the default {@link EventClientDelegateMBean} is not registered.
-     * @throws IOException If an I/O error occurs.
-     */
-    public static MBeanServerConnection getEventClientConnection(
-            final MBeanServerConnection conn,
-            final EventRelay eventRelay)
-            throws IOException {
-
-        if (newEventConn == null) {
-            throw new IllegalArgumentException(
-                    "Class not found: EventClientConnection");
-        }
-
-        checkInit(conn,null);
-        final Callable<EventClient> factory = new Callable<EventClient>() {
-            final public EventClient call() throws Exception {
-                EventClientDelegateMBean ecd = EventClientDelegate.getProxy(conn);
-                return new EventClient(ecd, eventRelay, null, null,
-                        DEFAULT_REQUESTED_LEASE_TIME);
-            }
-        };
-
-        try {
-            return (MBeanServerConnection)newEventConn.invoke(null,
-                    conn, factory);
-        } catch (Exception e) {
-            throw new IllegalArgumentException(e);
-        }
-    }
-
-    private static Method newEventConn = null;
-    static {
-        try {
-            Class<?> c = Class.forName(
-                    "com.sun.jmx.remote.util.EventClientConnection",
-                    false, Thread.currentThread().getContextClassLoader());
-            newEventConn = c.getMethod("getEventConnectionFor",
-                    MBeanServerConnection.class, Callable.class);
-        } catch (Exception e) {
-            // OK: we're running in a subset of our classes
-        }
-    }
-
-    /**
-     * <p>Get the client id of this {@code EventClient} in the
-     * {@link EventClientDelegateMBean}.
-     *
-     * @return the client id.
-     *
-     * @see EventClientDelegateMBean#addClient(String, Object[], String[])
-     * EventClientDelegateMBean.addClient
-     */
-    public String getClientId() {
-        return clientId;
-    }
-
-    private static final PerThreadGroupPool<ScheduledThreadPoolExecutor>
-            leaseRenewerThreadPool = PerThreadGroupPool.make();
-}
--- a/src/share/classes/javax/management/event/EventClientDelegate.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,824 +0,0 @@
-/*
- * 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.
- *
- * @since JMX 2.0
- */
-
-package javax.management.event;
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.UUID;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.remote.NotificationResult;
-import com.sun.jmx.event.EventBuffer;
-import com.sun.jmx.event.LeaseManager;
-import com.sun.jmx.interceptor.SingleMBeanForwarder;
-import com.sun.jmx.mbeanserver.Util;
-import com.sun.jmx.remote.util.ClassLogger;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedExceptionAction;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-import javax.management.DynamicMBean;
-import javax.management.MBeanException;
-import javax.management.MBeanPermission;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.MBeanServerNotification;
-import javax.management.ObjectInstance;
-import javax.management.StandardMBean;
-import javax.management.remote.MBeanServerForwarder;
-
-/**
- * This is the default implementation of the MBean
- * {@link EventClientDelegateMBean}.
- */
-public class EventClientDelegate implements EventClientDelegateMBean {
-
-    private EventClientDelegate(MBeanServer server) {
-        if (server == null) {
-            throw new NullPointerException("Null MBeanServer.");
-        }
-
-        if (logger.traceOn()) {
-            logger.trace("EventClientDelegate", "new one");
-        }
-        mbeanServer = server;
-        eventSubscriber = EventSubscriber.getEventSubscriber(mbeanServer);
-    }
-
-    /**
-     * Returns an {@code EventClientDelegate} instance for the given
-     * {@code MBeanServer}.  Calling this method more than once with the same
-     * {@code server} argument may return the same object or a different object
-     * each time.  See {@link EventClientDelegateMBean} for an example use of
-     * this method.
-     *
-     * @param server An MBean server instance to work with.
-     * @return An {@code EventClientDelegate} instance.
-     * @throws NullPointerException If {@code server} is null.
-     */
-    public static EventClientDelegate getEventClientDelegate(MBeanServer server) {
-        EventClientDelegate delegate = null;
-        synchronized(delegateMap) {
-            final WeakReference<EventClientDelegate> wrf = delegateMap.get(server);
-            delegate = (wrf == null) ? null : wrf.get();
-
-            if (delegate == null) {
-                delegate = new EventClientDelegate(server);
-                try {
-                    // TODO: this may not work with federated MBean, because
-                    // the delegate will *not* emit notifications for those MBeans.
-                    delegate.mbeanServer.addNotificationListener(
-                            MBeanServerDelegate.DELEGATE_NAME,
-                            delegate.cleanListener, null, null);
-                } catch (InstanceNotFoundException e) {
-                    logger.fine(
-                            "getEventClientDelegate",
-                            "Could not add MBeanServerDelegate listener", e);
-                }
-                delegateMap.put(server,
-                                new WeakReference<EventClientDelegate>(delegate));
-            }
-        }
-
-        return delegate;
-    }
-
-    // Logic for the MBeanServerForwarder that simulates the existence of the
-    // EventClientDelegate MBean. Things are complicated by the fact that
-    // there may not be anything in the chain after this forwarder when it is
-    // created - the connection to a real MBeanServer might only come later.
-    // Recall that there are two ways of creating a JMXConnectorServer -
-    // either you specify its MBeanServer when you create it, or you specify
-    // no MBeanServer and register it in an MBeanServer later. In the latter
-    // case, the forwarder chain points nowhere until this registration
-    // happens. Since EventClientDelegate wants to add a listener to the
-    // MBeanServerDelegate, we can't create an EventClientDelegate until
-    // there is an MBeanServer. So the forwarder initially has
-    // a dummy ECD where every method throws an exception, and
-    // the real ECD is created as soon as doing so does not produce an
-    // exception.
-    // TODO: rewrite so that the switch from the dummy to the real ECD happens
-    // just before we would otherwise have thrown UnsupportedOperationException.
-    // This is more correct, because it's not guaranteed that we will see the
-    // moment where the real MBeanServer is attached, if it happens by virtue
-    // of a setMBeanServer on some other forwarder later in the chain.
-
-    private static class Forwarder extends SingleMBeanForwarder {
-        private MBeanServer loopMBS;
-
-        private static class UnsupportedInvocationHandler
-                implements InvocationHandler {
-            public Object invoke(Object proxy, Method method, Object[] args)
-                    throws Throwable {
-                throw new UnsupportedOperationException(
-                        "EventClientDelegate unavailable: no MBeanServer, or " +
-                        "MBeanServer inaccessible");
-            }
-        }
-
-        private static DynamicMBean makeUnsupportedECD() {
-            EventClientDelegateMBean unsupported = (EventClientDelegateMBean)
-                Proxy.newProxyInstance(
-                    EventClientDelegateMBean.class.getClassLoader(),
-                    new Class<?>[] {EventClientDelegateMBean.class},
-                    new UnsupportedInvocationHandler());
-            return new StandardMBean(
-                unsupported, EventClientDelegateMBean.class, false);
-        }
-
-        private volatile boolean madeECD;
-
-        Forwarder() {
-            super(OBJECT_NAME, makeUnsupportedECD(), true);
-        }
-
-        synchronized void setLoopMBS(MBeanServer loopMBS) {
-            this.loopMBS = loopMBS;
-        }
-
-        @Override
-        public synchronized void setMBeanServer(final MBeanServer mbs) {
-            super.setMBeanServer(mbs);
-
-            if (!madeECD) {
-                try {
-                    EventClientDelegate ecd =
-                        AccessController.doPrivileged(
-                            new PrivilegedAction<EventClientDelegate>() {
-                                public EventClientDelegate run() {
-                                    return getEventClientDelegate(loopMBS);
-                                }
-                            });
-                    DynamicMBean mbean = new StandardMBean(
-                            ecd, EventClientDelegateMBean.class, false);
-                    setSingleMBean(mbean);
-                    madeECD = true;
-                } catch (Exception e) {
-                    // OK: assume no MBeanServer
-                    logger.fine("setMBeanServer", "isRegistered", e);
-                }
-            }
-        }
-    }
-
-    /**
-     * <p>Create a new {@link MBeanServerForwarder} that simulates the existence
-     * of an {@code EventClientDelegateMBean} with the {@linkplain
-     * #OBJECT_NAME default name}.  This forwarder intercepts MBean requests
-     * that are targeted for that MBean and handles them itself.  All other
-     * requests are forwarded to the next element in the forwarder chain.</p>
-     *
-     * @param nextMBS the next {@code MBeanServer} in the chain of forwarders,
-     * which might be another {@code MBeanServerForwarder} or a plain {@code
-     * MBeanServer}.  This is the object to which {@code MBeanServer} requests
-     * that do not concern the {@code EventClientDelegateMBean} are sent.
-     * It will be the value of {@link MBeanServerForwarder#getMBeanServer()
-     * getMBeanServer()} on the returned object, and can be changed with {@link
-     * MBeanServerForwarder#setMBeanServer setMBeanServer}.  It can be null but
-     * must be set to a non-null value before any {@code MBeanServer} requests
-     * arrive.
-     *
-     * @param loopMBS the {@code MBeanServer} to which requests from the
-     * {@code EventClientDelegateMBean} should be sent.  For example,
-     * when you invoke the {@link EventClientDelegateMBean#addListener
-     * addListener} operation on the {@code EventClientDelegateMBean}, it will
-     * result in a call to {@link
-     * MBeanServer#addNotificationListener(ObjectName, NotificationListener,
-     * NotificationFilter, Object) addNotificationListener} on this object.
-     * If this parameter is null, then these requests will be sent to the
-     * newly-created {@code MBeanServerForwarder}.  Usually the parameter will
-     * either be null or will be the result of {@link
-     * javax.management.remote.JMXConnectorServer#getSystemMBeanServerForwarder()
-     * getSystemMBeanServerForwarder()} for the connector server in which
-     * this forwarder will be installed.
-     *
-     * @return a new {@code MBeanServerForwarder} that simulates the existence
-     * of an {@code EventClientDelegateMBean}.
-     *
-     * @see javax.management.remote.JMXConnectorServer#installStandardForwarders
-     */
-    public static MBeanServerForwarder newForwarder(
-            MBeanServer nextMBS, MBeanServer loopMBS) {
-        Forwarder mbsf = new Forwarder();
-        // We must setLoopMBS before setMBeanServer, because when we
-        // setMBeanServer that will call getEventClientDelegate(loopMBS).
-        if (loopMBS == null)
-            loopMBS = mbsf;
-        mbsf.setLoopMBS(loopMBS);
-        if (nextMBS != null)
-            mbsf.setMBeanServer(nextMBS);
-        return mbsf;
-    }
-
-    /**
-     * Returns a proxy of the default {@code EventClientDelegateMBean}.
-     *
-     * @param conn An {@link MBeanServerConnection} to work with.
-     */
-    @SuppressWarnings("cast") // cast for jdk 1.5
-    public static EventClientDelegateMBean getProxy(MBeanServerConnection conn) {
-        return  (EventClientDelegateMBean)MBeanServerInvocationHandler.
-                newProxyInstance(conn,
-                OBJECT_NAME,
-                EventClientDelegateMBean.class,
-                false);
-    }
-
-    public String addClient(String className, Object[] params, String[] sig)
-    throws MBeanException {
-        return addClient(className, null, params, sig, true);
-    }
-
-    public String addClient(String className,
-            ObjectName classLoader,
-            Object[] params,
-            String[] sig) throws MBeanException {
-        return addClient(className, classLoader, params, sig, false);
-    }
-
-    private String addClient(String className,
-            ObjectName classLoader,
-            Object[] params,
-            String[] sig,
-            boolean classLoaderRepository) throws MBeanException {
-        try {
-            return addClientX(
-                    className, classLoader, params, sig, classLoaderRepository);
-        } catch (RuntimeException e) {
-            throw e;
-        } catch (Exception e) {
-            throw new MBeanException(e);
-        }
-    }
-
-    private String addClientX(String className,
-            ObjectName classLoader,
-            Object[] params,
-            String[] sig,
-            boolean classLoaderRepository) throws Exception {
-        if (className == null) {
-            throw new IllegalArgumentException("Null class name.");
-        }
-
-        final Object o;
-
-        // The special treatment of standard EventForwarders is so that no
-        // special permissions are necessary to use them.  Otherwise you
-        // couldn't use EventClient if you didn't have permission to call
-        // MBeanServer.instantiate.  We do require that permission for
-        // non-standard forwarders, because otherwise you could instantiate
-        // any class with possibly adverse consequences.  We also avoid using
-        // MBeanInstantiator because it looks up constructors by loading each
-        // class in the sig array, which means a remote user could cause any
-        // class to be loaded.  That's probably not hugely risky but still.
-        if (className.startsWith("javax.management.event.")) {
-            Class<?> c = Class.forName(
-                    className, false, this.getClass().getClassLoader());
-            Constructor<?> foundCons = null;
-            if (sig == null)
-                sig = new String[0];
-            for (Constructor<?> cons : c.getConstructors()) {
-                Class<?>[] types = cons.getParameterTypes();
-                String[] consSig = new String[types.length];
-                for (int i = 0; i < types.length; i++)
-                    consSig[i] = types[i].getName();
-                if (Arrays.equals(sig, consSig)) {
-                    foundCons = cons;
-                    break;
-                }
-            }
-            if (foundCons == null) {
-                throw new NoSuchMethodException(
-                        "Constructor for " + className + " with argument types " +
-                        Arrays.toString(sig));
-            }
-            o = foundCons.newInstance(params);
-        } else if (classLoaderRepository) {
-            o = mbeanServer.instantiate(className, params, sig);
-        } else {
-            o = mbeanServer.instantiate(className, classLoader, params, sig);
-        }
-
-        if (!(o instanceof EventForwarder)) {
-            throw new IllegalArgumentException(
-                    className+" is not an EventForwarder class.");
-        }
-
-        final EventForwarder forwarder = (EventForwarder)o;
-        final String clientId = UUID.randomUUID().toString();
-        ClientInfo clientInfo = new ClientInfo(clientId, forwarder);
-
-        clientInfoMap.put(clientId, clientInfo);
-
-        forwarder.setClientId(clientId);
-
-        if (logger.traceOn()) {
-            logger.trace("addClient", clientId);
-        }
-
-        return clientId;
-    }
-
-    public Integer[] getListenerIds(String clientId)
-    throws IOException, EventClientNotFoundException {
-        ClientInfo clientInfo = getClientInfo(clientId);
-
-        if (clientInfo == null) {
-            throw new EventClientNotFoundException("The client is not found.");
-        }
-
-        Map<Integer, AddedListener> listenerInfoMap = clientInfo.listenerInfoMap;
-        synchronized (listenerInfoMap) {
-            Set<Integer> ids = listenerInfoMap.keySet();
-            return ids.toArray(new Integer[ids.size()]);
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The execution of this method includes a call to
-     * {@link MBeanServer#addNotificationListener(ObjectName,
-     * NotificationListener, NotificationFilter, Object)}.</p>
-     */
-    public Integer addListener(String clientId,
-            final ObjectName name,
-            NotificationFilter filter)
-            throws EventClientNotFoundException, InstanceNotFoundException {
-
-        if (logger.traceOn()) {
-            logger.trace("addListener", "");
-        }
-
-        return getClientInfo(clientId).addListenerInfo(name, filter);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The execution of this method can include call to
-     * {@link MBeanServer#removeNotificationListener(ObjectName,
-     * NotificationListener, NotificationFilter, Object)}.</p>
-     */
-    public void removeListenerOrSubscriber(String clientId, Integer listenerId)
-    throws InstanceNotFoundException,
-            ListenerNotFoundException,
-            EventClientNotFoundException,
-            IOException {
-        if (logger.traceOn()) {
-            logger.trace("removeListener", ""+listenerId);
-        }
-        getClientInfo(clientId).removeListenerInfo(listenerId);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The execution of this method includes a call to
-     * {@link MBeanServer#addNotificationListener(ObjectName,
-     * NotificationListener, NotificationFilter, Object)} for
-     * every MBean matching {@code name}.  If {@code name} is
-     * an {@code ObjectName} pattern, then the execution of this
-     * method will include a call to {@link MBeanServer#queryNames}.</p>
-     */
-    public Integer addSubscriber(String clientId, ObjectName name,
-            NotificationFilter filter)
-            throws EventClientNotFoundException, IOException {
-        if (logger.traceOn()) {
-            logger.trace("addSubscriber", "");
-        }
-        return getClientInfo(clientId).subscribeListenerInfo(name, filter);
-    }
-
-    public NotificationResult fetchNotifications(String clientId,
-            long startSequenceNumber,
-            int maxNotifs,
-            long timeout)
-            throws EventClientNotFoundException {
-        if (logger.traceOn()) {
-            logger.trace("fetchNotifications", "for "+clientId);
-        }
-        return getClientInfo(clientId).fetchNotifications(startSequenceNumber,
-                maxNotifs,
-                timeout);
-    }
-
-    public void removeClient(String clientId)
-    throws EventClientNotFoundException {
-        if (clientId == null)
-            throw new EventClientNotFoundException("Null clientId");
-        if (logger.traceOn()) {
-            logger.trace("removeClient", clientId);
-        }
-        ClientInfo ci = null;
-        ci = clientInfoMap.remove(clientId);
-
-        if (ci == null) {
-            throw new EventClientNotFoundException("clientId is "+clientId);
-        } else {
-            ci.clean();
-        }
-    }
-
-    public long lease(String clientId, long timeout)
-    throws IOException, EventClientNotFoundException {
-        if (logger.traceOn()) {
-            logger.trace("lease", "for "+clientId);
-        }
-        return getClientInfo(clientId).lease(timeout);
-    }
-
-    // ------------------------------------
-    // private classes
-    // ------------------------------------
-    private class ClientInfo {
-        final String clientId;
-        final NotificationListener clientListener;
-        final Map<Integer, AddedListener> listenerInfoMap =
-                new HashMap<Integer, AddedListener>();
-
-        ClientInfo(String clientId, EventForwarder forwarder) {
-            this.clientId = clientId;
-            this.forwarder = forwarder;
-            clientListener =
-                    new ForwardingClientListener(listenerInfoMap, forwarder);
-        }
-
-        Integer addOrSubscribeListenerInfo(
-                ObjectName name, NotificationFilter filter, boolean subscribe)
-                throws InstanceNotFoundException, IOException {
-
-            final Integer listenerId = nextListenerId();
-            AddedListener listenerInfo = new AddedListener(
-                    listenerId, filter, name, subscribe);
-            if (subscribe) {
-                eventSubscriber.subscribe(name,
-                        clientListener,
-                        filter,
-                        listenerInfo);
-            } else {
-                mbeanServer.addNotificationListener(name,
-                        clientListener,
-                        filter,
-                        listenerInfo);
-            }
-
-            synchronized(listenerInfoMap) {
-                listenerInfoMap.put(listenerId, listenerInfo);
-            }
-
-            return listenerId;
-        }
-
-        Integer addListenerInfo(ObjectName name,
-                NotificationFilter filter) throws InstanceNotFoundException {
-            try {
-                return addOrSubscribeListenerInfo(name, filter, false);
-            } catch (IOException e) { // can't happen
-                logger.warning(
-                        "EventClientDelegate.addListenerInfo",
-                        "unexpected exception", e);
-                throw new RuntimeException(e);
-            }
-        }
-
-        Integer subscribeListenerInfo(ObjectName name,
-                NotificationFilter filter) throws IOException {
-            try {
-                return addOrSubscribeListenerInfo(name, filter, true);
-            } catch (InstanceNotFoundException e) { // can't happen
-                logger.warning(
-                        "EventClientDelegate.subscribeListenerInfo",
-                        "unexpected exception", e);
-                throw new RuntimeException(e);
-            }
-        }
-
-        private final AtomicInteger nextListenerId = new AtomicInteger();
-
-        private Integer nextListenerId() {
-            return nextListenerId.getAndIncrement();
-        }
-
-        NotificationResult fetchNotifications(long startSequenceNumber,
-                int maxNotifs,
-                long timeout) {
-
-            if (!(forwarder instanceof FetchingEventForwarder)) {
-                throw new IllegalArgumentException(
-                        "This client is using Event Postal Service!");
-            }
-
-            return ((FetchingEventForwarder)forwarder).
-                    fetchNotifications(startSequenceNumber,
-                        maxNotifs, timeout);
-        }
-
-        void removeListenerInfo(Integer listenerId)
-        throws InstanceNotFoundException, ListenerNotFoundException, IOException {
-            AddedListener listenerInfo;
-            synchronized(listenerInfoMap) {
-                listenerInfo = listenerInfoMap.remove(listenerId);
-            }
-
-            if (listenerInfo == null) {
-                throw new ListenerNotFoundException("The listener is not found.");
-            }
-
-            if (listenerInfo.subscription) {
-                eventSubscriber.unsubscribe(listenerInfo.name,
-                        clientListener);
-            } else {
-                mbeanServer.removeNotificationListener(listenerInfo.name,
-                        clientListener,
-                        listenerInfo.filter,
-                        listenerInfo);
-            }
-        }
-
-        void clean(ObjectName name) {
-            synchronized(listenerInfoMap) {
-                for (Map.Entry<Integer, AddedListener> entry :
-                        listenerInfoMap.entrySet()) {
-                    AddedListener li = entry.getValue();
-                    if (name.equals(li.name)) {
-                        listenerInfoMap.remove(entry.getKey());
-                    }
-                }
-            }
-        }
-
-        void clean() {
-            synchronized(listenerInfoMap) {
-                for (AddedListener li : listenerInfoMap.values()) {
-                    try {
-                        mbeanServer.removeNotificationListener(li.name,
-                                clientListener);
-                    } catch (Exception e) {
-                        logger.trace("ClientInfo.clean", "removeNL", e);
-                    }
-                }
-                listenerInfoMap.clear();
-            }
-
-            try {
-                forwarder.close();
-            } catch (Exception e) {
-                logger.trace(
-                        "ClientInfo.clean", "forwarder.close", e);
-            }
-
-            if (leaseManager != null) {
-                leaseManager.stop();
-            }
-        }
-
-        long lease(long timeout) {
-            return leaseManager.lease(timeout);
-        }
-
-        @Override
-        public boolean equals(Object o) {
-            if (this == o) {
-                return true;
-            }
-
-            if (o instanceof ClientInfo &&
-                    clientId.equals(((ClientInfo)o).clientId)) {
-                return true;
-            }
-
-            return false;
-        }
-
-        @Override
-        public int hashCode() {
-            return clientId.hashCode();
-        }
-
-        private EventForwarder forwarder = null;
-
-        private final Runnable leaseExpiryCallback = new Runnable() {
-            public void run() {
-                try {
-                    removeClient(clientId);
-                } catch (Exception e) {
-                    logger.trace(
-                            "ClientInfo.leaseExpiryCallback", "removeClient", e);
-                }
-            }
-        };
-
-        private LeaseManager leaseManager = new LeaseManager(leaseExpiryCallback);
-    }
-
-    private class ForwardingClientListener implements NotificationListener {
-        public ForwardingClientListener(Map<Integer, AddedListener> listenerInfoMap,
-                EventForwarder forwarder) {
-            this.listenerInfoMap = listenerInfoMap;
-            this.forwarder = forwarder;
-        }
-
-        public void handleNotification(Notification n, Object o) {
-            if (n == null || (!(o instanceof AddedListener))) {
-                if (logger.traceOn()) {
-                    logger.trace("ForwardingClientListener-handleNotification",
-                            "received a unknown notif");
-                }
-                return;
-            }
-
-            AddedListener li = (AddedListener) o;
-
-            if (checkListenerPermission(li.name,li.acc)) {
-                try {
-                    forwarder.forward(n, li.listenerId);
-                } catch (Exception e) {
-                    if (logger.traceOn()) {
-                        logger.trace(
-                                "ForwardingClientListener-handleNotification",
-                                "forwarding failed.", e);
-                    }
-                }
-            }
-        }
-
-        private final Map<Integer, AddedListener> listenerInfoMap;
-        private final EventForwarder forwarder;
-    }
-
-    private class AddedListener {
-        final int listenerId;
-        final NotificationFilter filter;
-        final ObjectName name;
-        final boolean subscription;
-        final AccessControlContext acc;
-
-        public AddedListener(
-                int listenerId,
-                NotificationFilter filter,
-                ObjectName name,
-                boolean subscription) {
-            this.listenerId = listenerId;
-            this.filter = filter;
-            this.name = name;
-            this.subscription = subscription;
-            acc = AccessController.getContext();
-        }
-    }
-
-    private class CleanListener implements NotificationListener {
-        public void handleNotification(Notification notification,
-                Object handback) {
-            if (notification instanceof MBeanServerNotification) {
-                if (MBeanServerNotification.UNREGISTRATION_NOTIFICATION.equals(
-                        notification.getType())) {
-                    final ObjectName name =
-                            ((MBeanServerNotification)notification).getMBeanName();
-
-                    final Collection <ClientInfo> list =
-                            Collections.unmodifiableCollection(clientInfoMap.values());
-
-                    for (ClientInfo ci : list) {
-                        ci.clean(name);
-                    }
-                }
-
-            }
-        }
-    }
-
-    // -------------------------------------------------
-    // private method
-    // -------------------------------------------------
-    private ClientInfo getClientInfo(String clientId)
-    throws EventClientNotFoundException {
-        ClientInfo clientInfo = null;
-        clientInfo = clientInfoMap.get(clientId);
-
-        if (clientInfo == null) {
-            throw new EventClientNotFoundException(
-                    "Client not found (id " + clientId + ")");
-        }
-
-        return clientInfo;
-    }
-
-    /**
-     * Explicitly check the MBeanPermission for
-     * the current access control context.
-     */
-    private boolean checkListenerPermission(final ObjectName name,
-            final AccessControlContext acc) {
-        if (logger.traceOn()) {
-            logger.trace("checkListenerPermission", "");
-        }
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-            try {
-                final String serverName = getMBeanServerName();
-
-                ObjectInstance oi = (ObjectInstance)
-                    AccessController.doPrivileged(
-                        new PrivilegedExceptionAction<Object>() {
-                    public Object run()
-                    throws InstanceNotFoundException {
-                        return mbeanServer.getObjectInstance(name);
-                    }
-                });
-
-                String classname = oi.getClassName();
-                MBeanPermission perm = new MBeanPermission(
-                        serverName,
-                        classname,
-                        null,
-                        name,
-                        "addNotificationListener");
-                sm.checkPermission(perm, acc);
-            } catch (Exception e) {
-                if (logger.debugOn()) {
-                    logger.debug("checkListenerPermission", "refused.", e);
-                }
-                return false;
-            }
-        }
-        return true;
-    }
-
-    private String getMBeanServerName() {
-        if (mbeanServerName != null) return mbeanServerName;
-        else return (mbeanServerName = getMBeanServerName(mbeanServer));
-    }
-
-    private static String getMBeanServerName(final MBeanServer server) {
-        final PrivilegedAction<String> action = new PrivilegedAction<String>() {
-            public String run() {
-                return Util.getMBeanServerSecurityName(server);
-            }
-        };
-        return AccessController.doPrivileged(action);
-    }
-
-    // ------------------------------------
-    // private variables
-    // ------------------------------------
-    private final MBeanServer mbeanServer;
-    private volatile String mbeanServerName = null;
-    private Map<String, ClientInfo> clientInfoMap =
-            new ConcurrentHashMap<String, ClientInfo>();
-
-    private final CleanListener cleanListener = new CleanListener();
-    private final EventSubscriber eventSubscriber;
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "EventClientDelegate");
-
-    private static final
-            Map<MBeanServer, WeakReference<EventClientDelegate>> delegateMap =
-            new WeakHashMap<MBeanServer, WeakReference<EventClientDelegate>>();
-}
--- a/src/share/classes/javax/management/event/EventClientDelegateMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,317 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import com.sun.jmx.mbeanserver.Util;
-import java.io.IOException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.NotificationFilter;
-import javax.management.ObjectName;
-import javax.management.remote.NotificationResult;
-
-/**
- * <p>This interface specifies necessary methods on the MBean server
- * side for a JMX remote client to manage its notification listeners as
- * if they are local.
- * Users do not usually work directly with this MBean; instead, the {@link
- * EventClient} class is designed to be used directly by the user.</p>
- *
- * <p>A default implementation of this interface can be added to an MBean
- * Server in one of several ways.</p>
- *
- * <ul>
- * <li><p>The most usual is to insert an {@link
- * javax.management.remote.MBeanServerForwarder MBeanServerForwarder} between
- * the {@linkplain javax.management.remote.JMXConnectorServer Connector Server}
- * and the MBean Server, that will intercept accesses to the Event Client
- * Delegate MBean and treat them as the real MBean would. This forwarder is
- * inserted by default with the standard RMI Connector Server, and can also
- * be created explicitly using {@link EventClientDelegate#newForwarder
- * EventClientDelegate.newForwarder}.
- *
- * <li><p>A variant on the above is to replace the MBean Server that is
- * used locally with a forwarder as described above.  Since
- * {@code MBeanServerForwarder} extends {@code MBeanServer}, you can use
- * a forwarder anywhere you would have used the original MBean Server.  The
- * code to do this replacement typically looks something like this:</p>
- *
- * <pre>
- * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();  // or whatever
- * mbs = EventClientDelegate.newForwarder(mbs, null);
- * // now use mbs just as you did before, but it will have an EventClientDelegate
- * </pre>
- *
- * <li><p>The final way is to create an instance of {@link EventClientDelegate}
- * and register it in the MBean Server under the standard {@linkplain
- * #OBJECT_NAME name}:</p>
- *
- * <pre>
- * MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();  // or whatever
- * EventClientDelegate ecd = EventClientDelegate.getEventClientDelegate(mbs);
- * mbs.registerMBean(ecd, EventClientDelegateMBean.OBJECT_NAME);
- * <pre>
- * </ul>
- *
- * @since JMX 2.0
- */
-public interface EventClientDelegateMBean {
-    /**
-     * The string representation of {@link #OBJECT_NAME}.
-     */
-    // This shouldn't really be necessary but an apparent javadoc bug
-    // meant that the {@value} tags didn't work if this was a
-    // field in EventClientDelegate, even a public field.
-    public static final String OBJECT_NAME_STRING =
-            "javax.management.event:type=EventClientDelegate";
-
-    /**
-     * The standard <code>ObjectName</code> used to register the default
-     * <code>EventClientDelegateMBean</code>.  The name is
-     * <code>{@value #OBJECT_NAME_STRING}</code>.
-     */
-    public final static ObjectName OBJECT_NAME =
-            ObjectName.valueOf(OBJECT_NAME_STRING);
-
-    /**
-     * A unique listener identifier specified for an EventClient.
-     * Any notification associated with this id is intended for
-     * the EventClient which receives the notification, rather than
-     * a listener added using that EventClient.
-     */
-    public static final int EVENT_CLIENT_LISTENER_ID = -100;
-
-    /**
-     * Adds a new client to the <code>EventClientDelegateMBean</code> with
-     * a user-specified
-     * {@link EventForwarder} to forward notifications to the client. The
-     * <code>EventForwarder</code> is created by calling
-     * {@link javax.management.MBeanServer#instantiate(String, Object[],
-     * String[])}.
-     *
-     * @param className The class name used to create an
-     * {@code EventForwarder}.
-     * @param params An array containing the parameters of the constructor to
-     * be invoked.
-     * @param sig An array containing the signature of the constructor to be
-     * invoked
-     * @return A client identifier.
-     * @exception IOException Reserved for a remote call to throw on the client
-     * side.
-     * @exception MBeanException An exception thrown when creating the user
-     * specified <code>EventForwarder</code>.
-     */
-    public String addClient(String className, Object[] params, String[] sig)
-    throws IOException, MBeanException;
-
-    /**
-     * Adds a new client to the <code>EventClientDelegateMBean</code> with
-     * a user-specified
-     * {@link EventForwarder} to forward notifications to the client. The
-     * <code>EventForwarder</code> is created by calling
-     * {@link javax.management.MBeanServer#instantiate(String, ObjectName,
-     * Object[], String[])}. A user-specified class loader is used to create
-     * this <code>EventForwarder</code>.
-     *
-     * @param className The class name used to create an
-     * {@code EventForwarder}.
-     * @param classLoader An ObjectName registered as a
-     *        <code>ClassLoader</code> MBean.
-     * @param params An array containing the parameters of the constructor to
-     * be invoked.
-     * @param sig An array containing the signature of the constructor to be
-     * invoked
-     * @return A client identifier.
-     * @exception IOException Reserved for a remote call to throw on the client
-     * side.
-     * @exception MBeanException An exception thrown when creating the user
-     * specified <code>EventForwarder</code>.
-     */
-    public String addClient(String className,
-            ObjectName classLoader,
-            Object[] params,
-            String[] sig) throws IOException, MBeanException;
-
-    /**
-     * Removes an added client. Calling this method will remove all listeners
-     * added with the client.
-     *
-     * @exception EventClientNotFoundException If the {@code clientId} is
-     * not found.
-     * @exception IOException Reserved for a remote call to throw on the client
-     * side.
-     */
-    public void removeClient(String clientID)
-    throws EventClientNotFoundException, IOException;
-
-    /**
-     * Returns the identifiers of listeners added or subscribed to with the
-     * specified client identifier.
-     * <P> If no listener is currently registered with the client, an empty
-     * array is returned.
-     * @param clientID The client identifier with which the listeners are
-     * added or subscribed to.
-     * @return An array of listener identifiers.
-     * @exception EventClientNotFoundException If the {@code clientId} is
-     * not found.
-     * @exception IOException Reserved for a remote call to throw on the client
-     * side.
-     */
-    public Integer[] getListenerIds(String clientID)
-    throws EventClientNotFoundException, IOException;
-
-    /**
-     * Adds a listener to receive notifications from an MBean and returns
-     * a non-negative integer as the identifier of the listener.
-     * <P>This method is called by an {@link EventClient} to implement the
-     * method  {@link EventClient#addNotificationListener(ObjectName,
-     * NotificationListener, NotificationFilter, Object)}.
-     *
-     * @param name The name of the MBean onto which the listener should be added.
-     * @param filter The filter object. If  {@code filter} is null,
-     *        no filtering will be performed before handling notifications.
-     * @param clientId The client identifier with which the listener is added.
-     * @return A listener identifier.
-     * @throws EventClientNotFoundException Thrown if the {@code clientId} is
-     * not found.
-     * @throws InstanceNotFoundException Thrown if the MBean is not found.
-     * @throws IOException Reserved for a remote call to throw on the client
-     * side.
-     */
-    public Integer addListener(String clientId,
-            ObjectName name,
-            NotificationFilter filter)
-            throws InstanceNotFoundException, EventClientNotFoundException,
-            IOException;
-
-
-    /**
-     * <p>Subscribes a listener to receive notifications from an MBean or a
-     * set of MBeans represented by an {@code ObjectName} pattern.  (It is
-     * not an error if no MBeans match the pattern at the time this method is
-     * called.)</p>
-     *
-     * <p>Returns a non-negative integer as the identifier of the listener.</p>
-     *
-     * <p>This method is called by an {@link EventClient} to execute its
-     * method {@link EventClient#subscribe(ObjectName, NotificationListener,
-     * NotificationFilter, Object)}.</p>
-     *
-     * @param clientId The remote client's identifier.
-     * @param name The name of an MBean or an {@code ObjectName} pattern
-     * representing a set of MBeans to which the listener should listen.
-     * @param filter The filter object. If {@code filter} is null, no
-     * filtering will be performed before notifications are handled.
-     *
-     * @return A listener identifier.
-     *
-     * @throws IllegalArgumentException If the {@code name} or
-     * {@code listener} is null.
-     * @throws EventClientNotFoundException If the client ID is not found.
-     * @throws IOException Reserved for a remote client to throw if
-     * an I/O error occurs.
-     *
-     * @see EventConsumer#subscribe(ObjectName, NotificationListener,
-     * NotificationFilter,Object)
-     * @see #removeListenerOrSubscriber(String, Integer)
-     */
-    public Integer addSubscriber(String clientId, ObjectName name,
-            NotificationFilter filter)
-            throws EventClientNotFoundException, IOException;
-
-    /**
-     * Removes a listener, to stop receiving notifications.
-     * <P> This method is called by an {@link EventClient} to execute its
-     * methods {@link EventClient#removeNotificationListener(ObjectName,
-     * NotificationListener, NotificationFilter, Object)},
-     * {@link EventClient#removeNotificationListener(ObjectName,
-     * NotificationListener)}, and {@link EventClient#unsubscribe}.
-     *
-     * @param clientId The client identifier with which the listener was added.
-     * @param listenerId The listener identifier to be removed. This must be
-     * an identifier returned by a previous {@link #addListener addListener}
-     * or {@link #addSubscriber addSubscriber} call.
-     *
-     * @throws InstanceNotFoundException if the MBean on which the listener
-     * was added no longer exists.
-     * @throws ListenerNotFoundException if there is no listener with the
-     * given {@code listenerId}.
-     * @throws EventClientNotFoundException if the {@code clientId} is
-     * not found.
-     * @throws IOException Reserved for a remote call to throw on the client
-     * side.
-     */
-    public void removeListenerOrSubscriber(String clientId, Integer listenerId)
-    throws InstanceNotFoundException, ListenerNotFoundException,
-            EventClientNotFoundException, IOException;
-
-    /**
-     * Called by a client to fetch notifications that are to be sent to its
-     * listeners.
-     *
-     * @param clientId The client's identifier.
-     * @param startSequenceNumber The first sequence number to
-     * consider.
-     * @param timeout The maximum waiting time.
-     * @param maxNotifs The maximum number of notifications to return.
-     *
-     * @throws EventClientNotFoundException Thrown if the {@code clientId} is
-     * not found.
-     * @throws IllegalArgumentException if the client was {@linkplain
-     * #addClient(String, Object[], String[]) added} with an {@link
-     * EventForwarder} that is not a {@link FetchingEventForwarder}.
-     * @throws IOException Reserved for a remote call to throw on the client
-     * side.
-     */
-    public NotificationResult fetchNotifications(String clientId,
-            long startSequenceNumber,
-            int maxNotifs,
-            long timeout)
-            throws EventClientNotFoundException, IOException;
-
-    /**
-     * An {@code EventClient} calls this method to keep its {@code clientId}
-     * alive in this MBean. The client will be removed if the lease times out.
-     *
-     * @param clientId The client's identifier.
-     * @param timeout The time in milliseconds by which the lease is to be
-     * extended.  The value zero has no special meaning, so it will cause the
-     * lease to time out immediately.
-     *
-     * @return The new lifetime of the lease in milliseconds.  This may be
-     * different from the requested time.
-     *
-     * @throws EventClientNotFoundException if the {@code clientId} is
-     * not found.
-     * @throws IOException reserved for a remote call to throw on the client
-     * side.
-     * @throws IllegalArgumentException if {@code clientId} is null or
-     * {@code timeout} is negative.
-     */
-    public long lease(String clientId, long timeout)
-    throws IOException, EventClientNotFoundException;
-}
--- a/src/share/classes/javax/management/event/EventClientNotFoundException.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import javax.management.JMException;
-
-/**
- * Thrown if an event client identifier is unknown.
- */
-public class EventClientNotFoundException extends JMException {
-
-    /* Serial version */
-    private static final long serialVersionUID = -3910667345840643089L;
-
-    /**
-     *Constructs a {@code ClientNotFoundException} without a detail message.
-     */
-    public EventClientNotFoundException() {
-        super();
-    }
-
-    /**
-     * Constructs a {@code ClientNotFoundException} with the specified detail message.
-     * @param message The message.
-     */
-    public EventClientNotFoundException(String message) {
-        super(message);
-    }
-
-    /**
-     * Constructs a {@code ClientNotFoundException} with the specified detail message
-     * and cause.
-     *
-     * @param message The message.
-     * @param cause The cause (which is saved for later retrieval by the
-     * {@code Throwable.getCause()} method). A null value is permitted, and indicates
-     * that the cause is non-existent or unknown.
-     */
-    public EventClientNotFoundException(String message, Throwable cause) {
-        super(message);
-
-        initCause(cause);
-    }
-
-    /**
-     * Constructs a new exception with the specified cause.
-     * @param cause The cause (which is saved for later retrieval by the
-     * {@code Throwable.getCause()} method). A null value is permitted, and indicates
-     * that the cause is non-existent or unknown.
-     */
-    public EventClientNotFoundException(Throwable cause) {
-        super();
-
-        initCause(cause);
-    }
-}
--- a/src/share/classes/javax/management/event/EventConsumer.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import java.io.IOException;
-import javax.management.ListenerNotFoundException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-/**
- * This interface specifies methods to subscribe a listener to receive events
- * from an MBean or a set of MBeans. The MBeans can already be registered in
- * an MBean server, or they can be pending registration, or they can be MBeans
- * that will never be registered, or they can be MBeans that will be registered
- * then unregistered.
- * @since JMX 2.0
- */
-public interface EventConsumer {
-    /**
-     * <p>Subscribes a listener to receive events from an MBean or a set
-     * of MBeans represented by an {@code ObjectName} pattern.</p>
-     *
-     * <P> An event emitted by an MBean is forwarded to every listener that was
-     * subscribed with the name of that MBean, or with a pattern that matches
-     * that name.</p>
-     *
-     * @param name The name of an MBean or an {@code ObjectName} pattern
-     * representing a set of MBeans to which the listener should listen.
-     * @param listener The listener object that will handle the
-     * notifications emitted by the MBeans.
-     * @param filter The filter object. If {@code filter} is null, no
-     * filtering will be performed before notification handling.
-     * @param handback The context to be sent to the listener when a
-     * notification is emitted.
-     *
-     * @throws IllegalArgumentException If the {@code name} or
-     * {@code listener} is null.
-     * @throws IOException for a remote client, thrown if
-     * an I/O error occurs.
-     * @see #unsubscribe(ObjectName, NotificationListener)
-     */
-    public void subscribe(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback)
-            throws IOException;
-
-    /**
-     * <p>Unsubscribes a listener which is listening to an MBean or a set of
-     * MBeans represented by an {@code ObjectName} pattern.</p>
-     *
-     * <p>The listener to be removed must have been added by the {@link
-     * #subscribe subscribe} method with the given {@code name}. If the {@code
-     * name} is a pattern, then the {@code subscribe} must have used the same
-     * pattern. If the same listener has been subscribed more than once to the
-     * {@code name}, perhaps with different filters or handbacks, then all such
-     * listeners are removed.</p>
-     *
-     * @param name The name of the MBean or an {@code ObjectName} pattern
-     * representing a set of MBeans to which the listener was subscribed.
-     * @param listener A listener that was previously subscribed to the
-     * MBean(s).
-     *
-     * @throws ListenerNotFoundException The given {@code listener} was not
-     * subscribed to the given {@code name}.
-     * @throws IOException for a remote client, thrown if
-     * an I/O error occurs.
-     *
-     * @see #subscribe
-     */
-    public void unsubscribe(ObjectName name,
-            NotificationListener listener)
-            throws ListenerNotFoundException, IOException;
-}
--- a/src/share/classes/javax/management/event/EventForwarder.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import java.io.IOException;
-import javax.management.Notification;
-
-/**
- * This interface can be used to specify a custom forwarding mechanism for
- * {@code EventClientDelegateMBean} to forward events to the client.
- *
- * @see <a href="package-summary.html#transports">Custom notification
- * transports</a>
- */
-public interface EventForwarder {
-    /**
-     * Forwards a notification.
-     * @param n The notification to be forwarded to a remote listener.
-     * @param listenerId The identifier of the listener to receive the notification.
-     * @throws IOException If it is closed or an I/O error occurs.
-     */
-    public void forward(Notification n, Integer listenerId)
-        throws IOException;
-
-    /**
-     * Informs the {@code EventForwarder} to shut down.
-     * <p> After this method is called, any call to the method
-     * {@link #forward forward(Notification, Integer)} may get an {@code IOException}.
-     * @throws IOException If an I/O error occurs.
-     */
-    public void close() throws IOException;
-
-    /**
-     * Sets an event client identifier created by {@link EventClientDelegateMBean}.
-     * <P> This method will be called just after this {@code EventForwarder}
-     * is constructed and before calling the {@code forward} method to forward any
-     * notifications.
-     */
-    public void setClientId(String clientId) throws IOException;
-}
--- a/src/share/classes/javax/management/event/EventReceiver.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import javax.management.remote.NotificationResult;
-
-/**
- * An object implementing this interface is passed by an {@link EventClient}
- * to its {@link EventRelay}, to allow the {@code EventRelay} to communicate
- * received notifications to the {@code EventClient}.
- *
- * @see <a href="package-summary.html#transports">Custom notification
- * transports</a>
- */
-public interface EventReceiver {
-
-    /**
-     * This method is implemented by {@code EventClient} as a callback to
-     * receive notifications from {@code EventRelay}.
-     * <P>The notifications are included in an object specified by the class
-     * {@link NotificationResult}. In
-     * addition to a set of notifications, the class object also contains two values:
-     * {@code earliestSequenceNumber} and {@code nextSequenceNumber}.
-     * These two values determine whether any notifications have been lost.
-     * The {@code nextSequenceNumber} value of the last time is compared
-     * to the received value {@code earliestSequenceNumber}. If the
-     * received {@code earliesSequenceNumber} is greater, than the difference
-     * signifies the number of lost notifications. A sender should
-     * ensure the sequence of notifications sent, meaning that the value
-     * {@code earliestSequenceNumber} of the next return should be always equal to
-     * or greater than the value {@code nextSequenceNumber} of the last return.
-     *
-     * @param nr the received notifications and sequence numbers.
-     */
-    public void receive(NotificationResult nr);
-
-    /**
-     * Allows the {@link EventRelay} to report when it receives an unexpected
-     * exception, which may be fatal and which may make it stop receiving
-     * notifications.
-     *
-     * @param t The unexpected exception received while {@link EventRelay} was running.
-     */
-    public void failed(Throwable t);
-
-    /**
-     * Allows the {@link EventRelay} to report when it receives an unexpected
-     * exception that is not fatal. For example, a notification received is not
-     * serializable or its class is not found.
-     *
-     * @param e The unexpected exception received while notifications are being received.
-     */
-    public void nonFatal(Exception e);
-}
--- a/src/share/classes/javax/management/event/EventRelay.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import java.io.IOException;
-import java.util.concurrent.Executors;  // for javadoc
-
-/**
- * This interface is used to specify a way to receive
- * notifications from a remote MBean server and then to forward the notifications
- * to an {@link EventClient}.
- *
- * @see <a href="package-summary.html#transports">Custom notification
- * transports</a>
- */
-public interface EventRelay {
-    /**
-     * Returns an identifier that is used by this {@code EventRelay} to identify
-     * the client when communicating with the {@link EventClientDelegateMBean}.
-     * <P> This identifier is obtained by calling
-     * {@link EventClientDelegateMBean#addClient(String, Object[], String[])
-     * EventClientDelegateMBean.addClient}.
-     * <P> It is the {@code EventRelay} that calls {@code EventClientDelegateMBean} to obtain
-     * the client identifier because it is the {@code EventRelay} that decides
-     * how to get notifications from the {@code EventClientDelegateMBean},
-     * by creating the appropriate {@link EventForwarder}.
-     *
-     * @return A client identifier.
-     * @throws IOException If an I/O error occurs when communicating with
-     * the {@code EventClientDelegateMBean}.
-     */
-    public String getClientId() throws IOException;
-
-    /**
-     * This method is called by {@link EventClient} to register a callback
-     * to receive notifications from an {@link EventClientDelegateMBean} object.
-     * A {@code null} value is allowed, which means that the {@code EventClient} suspends
-     * reception of notifications, so that the {@code EventRelay} can decide to stop receiving
-     * notifications from its {@code EventForwarder}.
-     *
-     * @param eventReceiver An {@link EventClient} callback to receive
-     * events.
-     */
-    public void setEventReceiver(EventReceiver eventReceiver);
-
-    /**
-     * Stops receiving and forwarding notifications and performs any necessary
-     * cleanup.  After calling this method, the {@link EventClient} will never
-     * call any other methods of this object.
-     *
-     * @throws IOException If an I/O exception appears.
-     *
-     * @see EventClient#close
-     */
-    public void stop() throws IOException;
-}
--- a/src/share/classes/javax/management/event/EventSubscriber.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,376 +0,0 @@
-/*
- * 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 javax.management.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.WeakHashMap;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerNotification;
-import javax.management.Notification;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryEval;
-import javax.management.QueryExp;
-
-/**
- * <p>An object that can be used to subscribe for notifications from all MBeans
- * in an MBeanServer that match a pattern.  For example, to listen for
- * notifications from all MBeans in the MBeanServer {@code mbs} that match
- * {@code com.example:type=Controller,name=*} you could write:</p>
- *
- * <pre>
- * EventSubscriber subscriber = EventSubscriber.getEventSubscriber(mbs);
- * ObjectName pattern = new ObjectName("com.example:type=Controller,name=*");
- * NotificationListener myListener = ...;
- * NotificationFilter myFilter = null;  // or whatever
- * Object handback = null;              // or whatever
- * subscriber.subscribe(pattern, myListener, myFilter, myHandback);
- * </pre>
- */
-public class EventSubscriber implements EventConsumer {
-    /**
-     * Returns an {@code EventSubscriber} object to subscribe for notifications
-     * from the given {@code MBeanServer}.  Calling this method more
-     * than once with the same parameter may or may not return the same object.
-     *
-     * @param mbs the {@code MBeanServer} containing MBeans to be subscribed to.
-     * @return An {@code EventSubscriber} object.
-     *
-     * @throws NullPointerException if mbs is null.
-     */
-    public static EventSubscriber getEventSubscriber(MBeanServer mbs) {
-        if (mbs == null)
-            throw new NullPointerException("Null MBeanServer");
-
-        EventSubscriber eventSubscriber = null;
-        synchronized (subscriberMap) {
-            final WeakReference<EventSubscriber> wrf = subscriberMap.get(mbs);
-            eventSubscriber = (wrf == null) ? null : wrf.get();
-
-            if (eventSubscriber == null) {
-                eventSubscriber = new EventSubscriber(mbs);
-
-                subscriberMap.put(mbs,
-                        new WeakReference<EventSubscriber>(eventSubscriber));
-            }
-        }
-
-        return eventSubscriber;
-    }
-
-    private EventSubscriber(final MBeanServer mbs) {
-        logger.trace("EventSubscriber", "create a new one");
-        this.mbeanServer = mbs;
-
-        Exception x = null;
-        try {
-            AccessController.doPrivileged(
-                    new PrivilegedExceptionAction<Void>() {
-                public Void run() throws Exception {
-                    mbs.addNotificationListener(
-                            MBeanServerDelegate.DELEGATE_NAME,
-                            myMBeanServerListener, null, null);
-                    return null;
-                }
-            });
-        } catch (PrivilegedActionException ex) {
-            x = ex.getException();
-        }
-
-        // handle possible exceptions.
-        //
-        // Fail unless x is null or x is instance of InstanceNotFoundException
-        // The logic here is that if the MBeanServerDelegate is not present,
-        // we will assume that the connection will not emit any
-        // MBeanServerNotifications.
-        //
-        if (x != null && !(x instanceof InstanceNotFoundException)) {
-            if (x instanceof RuntimeException)
-                throw (RuntimeException) x;
-            throw new RuntimeException(
-                    "Can't add listener to MBean server delegate: " + x, x);
-        }
-    }
-
-    public void subscribe(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback)
-            throws IOException {
-
-        if (logger.traceOn())
-            logger.trace("subscribe", "" + name);
-
-        if (name == null)
-            throw new IllegalArgumentException("Null MBean name");
-
-        if (listener == null)
-            throw new IllegalArgumentException("Null listener");
-
-        final MyListenerInfo li = new MyListenerInfo(listener, filter, handback);
-        List<MyListenerInfo> list;
-
-        Map<ObjectName, List<MyListenerInfo>> map;
-        Set<ObjectName> names;
-        if (name.isPattern()) {
-            map = patternSubscriptionMap;
-            names = mbeanServer.queryNames(name, notificationBroadcasterExp);
-        } else {
-            map = exactSubscriptionMap;
-            names = Collections.singleton(name);
-        }
-
-        synchronized (map) {
-            list = map.get(name);
-            if (list == null) {
-                list = new ArrayList<MyListenerInfo>();
-                map.put(name, list);
-            }
-            list.add(li);
-        }
-
-        for (ObjectName mbeanName : names) {
-            try {
-                mbeanServer.addNotificationListener(mbeanName,
-                                                    listener,
-                                                    filter,
-                                                    handback);
-            } catch (Exception e) {
-                logger.fine("subscribe", "addNotificationListener", e);
-            }
-        }
-    }
-
-    public void unsubscribe(ObjectName name,
-            NotificationListener listener)
-            throws ListenerNotFoundException, IOException {
-        if (logger.traceOn())
-            logger.trace("unsubscribe", "" + name);
-
-        if (name == null)
-            throw new IllegalArgumentException("Null MBean name");
-
-        if (listener == null)
-            throw new ListenerNotFoundException();
-
-        Map<ObjectName, List<MyListenerInfo>> map;
-        Set<ObjectName> names;
-
-        if (name.isPattern()) {
-            map = patternSubscriptionMap;
-            names = mbeanServer.queryNames(name, notificationBroadcasterExp);
-        } else {
-            map = exactSubscriptionMap;
-            names = Collections.singleton(name);
-        }
-
-        List<MyListenerInfo> toRemove = new ArrayList<MyListenerInfo>();
-        synchronized (map) {
-            List<MyListenerInfo> list = map.get(name);
-            if (list == null) {
-                throw new ListenerNotFoundException();
-            }
-
-            for (MyListenerInfo info : list) {
-                if (info.listener == listener) {
-                    toRemove.add(info);
-                }
-            }
-
-            if (toRemove.isEmpty()) {
-                throw new ListenerNotFoundException();
-            }
-
-            for (MyListenerInfo info : toRemove) {
-                list.remove(info);
-            }
-
-            if (list.isEmpty())
-                map.remove(name);
-        }
-
-        for (ObjectName mbeanName : names) {
-            for (MyListenerInfo i : toRemove) {
-                try {
-                    mbeanServer.removeNotificationListener(mbeanName,
-                        i.listener, i.filter, i.handback);
-                } catch (Exception e) {
-                    logger.fine("unsubscribe", "removeNotificationListener", e);
-                }
-            }
-        }
-    }
-
-    // ---------------------------------
-    // private stuff
-    // ---------------------------------
-    // used to receive MBeanServerNotification
-    private NotificationListener myMBeanServerListener =
-            new NotificationListener() {
-        public void handleNotification(Notification n, Object hb) {
-            if (!(n instanceof MBeanServerNotification) ||
-                    !MBeanServerNotification.
-                    REGISTRATION_NOTIFICATION.equals(n.getType())) {
-                return;
-            }
-
-            final ObjectName name =
-                    ((MBeanServerNotification)n).getMBeanName();
-            try {
-                if (!mbeanServer.isInstanceOf(name,
-                        NotificationBroadcaster.class.getName())) {
-                    return;
-                }
-            } catch (Exception e) {
-                // The only documented exception is InstanceNotFoundException,
-                // which could conceivably happen if the MBean is unregistered
-                // immediately after being registered.
-                logger.fine("myMBeanServerListener.handleNotification",
-                        "isInstanceOf", e);
-                return;
-            }
-
-            final List<MyListenerInfo> listeners = new ArrayList<MyListenerInfo>();
-
-            // If there are subscribers for the exact name that has just arrived
-            // then add their listeners to the list.
-            synchronized (exactSubscriptionMap) {
-                List<MyListenerInfo> exactListeners = exactSubscriptionMap.get(name);
-                if (exactListeners != null)
-                    listeners.addAll(exactListeners);
-            }
-
-            // For every subscription pattern that matches the new name,
-            // add all the listeners for that pattern to "listeners".
-            synchronized (patternSubscriptionMap) {
-                for (ObjectName on : patternSubscriptionMap.keySet()) {
-                    if (on.apply(name)) {
-                        listeners.addAll(patternSubscriptionMap.get(on));
-                    }
-                }
-            }
-
-            // Add all the listeners just found to the new MBean.
-            for (MyListenerInfo li : listeners) {
-                try {
-                    mbeanServer.addNotificationListener(
-                            name,
-                            li.listener,
-                            li.filter,
-                            li.handback);
-                } catch (Exception e) {
-                    logger.fine("myMBeanServerListener.handleNotification",
-                            "addNotificationListener", e);
-                }
-            }
-        }
-    };
-
-    private static class MyListenerInfo {
-        public final NotificationListener listener;
-        public final NotificationFilter filter;
-        public final Object handback;
-
-        public MyListenerInfo(NotificationListener listener,
-                NotificationFilter filter,
-                Object handback) {
-
-            if (listener == null)
-                throw new IllegalArgumentException("Null listener");
-
-            this.listener = listener;
-            this.filter = filter;
-            this.handback = handback;
-        }
-    }
-
-    // ---------------------------------
-    // private methods
-    // ---------------------------------
-    // ---------------------------------
-    // private variables
-    // ---------------------------------
-    private final MBeanServer mbeanServer;
-
-    private final Map<ObjectName, List<MyListenerInfo>> exactSubscriptionMap =
-            new HashMap<ObjectName, List<MyListenerInfo>>();
-    private final Map<ObjectName, List<MyListenerInfo>> patternSubscriptionMap =
-            new HashMap<ObjectName, List<MyListenerInfo>>();
-
-
-
-    // trace issues
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "EventSubscriber");
-
-    // Compatibility code, so we can run on Tiger:
-    private static final QueryExp notificationBroadcasterExp;
-    static {
-        QueryExp broadcasterExp;
-        try {
-            final Method m = Query.class.getMethod("isInstanceOf", String.class);
-            broadcasterExp = (QueryExp)m.invoke(Query.class,
-                    new Object[] {NotificationBroadcaster.class.getName()});
-        } catch (Exception e) {
-            broadcasterExp = new BroadcasterQueryExp();
-        }
-        notificationBroadcasterExp = broadcasterExp;
-    }
-    private static class BroadcasterQueryExp extends QueryEval implements QueryExp {
-        private static final long serialVersionUID = 1234L;
-        public boolean apply(ObjectName name) {
-            try {
-                return getMBeanServer().isInstanceOf(
-                        name, NotificationBroadcaster.class.getName());
-            } catch (Exception e) {
-                return false;
-            }
-        }
-    }
-
-    private static final
-            Map<MBeanServerConnection, WeakReference<EventSubscriber>> subscriberMap =
-            new WeakHashMap<MBeanServerConnection, WeakReference<EventSubscriber>>();
-}
--- a/src/share/classes/javax/management/event/FetchingEventForwarder.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import com.sun.jmx.event.EventBuffer;
-import com.sun.jmx.remote.util.ClassLogger;
-import java.io.IOException;
-import java.util.List;
-import javax.management.Notification;
-import javax.management.remote.NotificationResult;
-import javax.management.remote.TargetedNotification;
-
-/**
- * This class is used by {@link FetchingEventRelay}. When
- * {@link FetchingEventRelay} calls {@link
- * EventClientDelegateMBean#addClient(String, Object[], String[])} to get a new
- * client identifier, it uses
- * this class name as the first argument to ask {@code EventClientDelegateMBean}
- * to create an object of this class.
- * Then {@code EventClientDelegateMBean} forwards client notifications
- * to this object.
- * When {@link FetchingEventRelay} calls
- * {@link EventClientDelegateMBean#fetchNotifications(String, long, int, long)}
- * to fetch notifications, the {@code EventClientDelegateMBean} will forward
- * the call to this object.
- */
-public class FetchingEventForwarder implements EventForwarder {
-
-    /**
-     * Construct a new {@code FetchingEventForwarder} with the given
-     * buffer size.
-     * @param bufferSize the size of the buffer that will store notifications
-     * until they have been fetched and acknowledged by the client.
-     */
-    public FetchingEventForwarder(int bufferSize) {
-        if (logger.traceOn()) {
-            logger.trace("Constructor", "buffer size is "+bufferSize);
-        }
-
-        buffer = new EventBuffer(bufferSize);
-        this.bufferSize = bufferSize;
-    }
-
-    /**
-     * Called by an {@link EventClientDelegateMBean} to forward a user call
-     * {@link EventClientDelegateMBean#fetchNotifications(String, long, int, long)}.
-     * A call of this method is considered to acknowledge reception of all
-     * notifications whose sequence numbers are less the
-     * {@code startSequenceNumber}, so all these notifications can be deleted
-     * from this object.
-     *
-     * @param startSequenceNumber The first sequence number to
-     * consider.
-     * @param timeout The maximum waiting time in milliseconds.
-     * If no notifications have arrived after this period of time, the call
-     * will return with an empty list of notifications.
-     * @param maxNotifs The maximum number of notifications to return.
-     */
-    public NotificationResult fetchNotifications(long startSequenceNumber,
-            int maxNotifs, long timeout) {
-        if (logger.traceOn()) {
-            logger.trace("fetchNotifications",
-                    startSequenceNumber+" "+
-                    maxNotifs+" "+
-                    timeout);
-        }
-
-        return buffer.fetchNotifications(startSequenceNumber,
-                    timeout,
-                    maxNotifs);
-    }
-
-    /**
-     * {@inheritDoc}
-     * In this implementation, the notification is stored in the local buffer
-     * waiting for {@link #fetchNotifications fetchNotifications} to pick
-     * it up.
-     */
-    public void forward(Notification n, Integer listenerId) throws IOException {
-        if (logger.traceOn()) {
-            logger.trace("forward", n+" "+listenerId);
-        }
-
-        buffer.add(new TargetedNotification(n, listenerId));
-    }
-
-    public void close() throws IOException {
-        if (logger.traceOn()) {
-            logger.trace("close", "");
-        }
-
-        buffer.close();
-    }
-
-    public void setClientId(String clientId) throws IOException {
-        if (logger.traceOn()) {
-            logger.trace("setClientId", clientId);
-        }
-        this.clientId = clientId;
-    }
-
-    /**
-     * Sets a user specific list to save notifications in server side
-     * before forwarding to an FetchingEventRelay in client side.
-     * <P> This method should be called before any notification is
-     * forwarded to this forwader.
-     *
-     * @param list a user specific list to save notifications
-     */
-    protected void setList(List<TargetedNotification> list) {
-        if (logger.traceOn()) {
-            logger.trace("setList", "");
-        }
-
-        if (clientId == null) {
-            buffer = new EventBuffer(bufferSize, list);
-        } else {
-            throw new IllegalStateException();
-        }
-    }
-
-    private EventBuffer buffer;
-    private int bufferSize;
-    private String clientId;
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "FetchingEventForwarder");
-}
--- a/src/share/classes/javax/management/event/FetchingEventRelay.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,391 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import com.sun.jmx.event.DaemonThreadFactory;
-import com.sun.jmx.event.RepeatedSingletonJob;
-import com.sun.jmx.remote.util.ClassLogger;
-import java.io.IOException;
-import java.io.NotSerializableException;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
-import javax.management.MBeanException;
-import javax.management.remote.NotificationResult;
-
-/**
- * <p>This class is an implementation of the {@link EventRelay} interface. It calls
- * {@link EventClientDelegateMBean#fetchNotifications
- * fetchNotifications(String, long, int, long)} to get
- * notifications and then forwards them to an {@link EventReceiver} object.</p>
- *
- * <p>A {@code fetchExecutor} parameter can be specified when creating a
- * {@code FetchingEventRelay}.  That is then the {@code Executor} that will
- * be used to perform the {@code fetchNotifications} operation.  Only one
- * job at a time will be submitted to this {@code Executor}.  The behavior
- * is unspecified if {@link Executor#execute} throws an exception, including
- * {@link java.util.concurrent.RejectedExecutionException
- * RejectedExecutionException}.
- *
- * @since JMX 2.0
- */
-public class FetchingEventRelay implements EventRelay {
-    /**
-     * The default buffer size: {@value #DEFAULT_BUFFER_SIZE}.
-     */
-    public final static int DEFAULT_BUFFER_SIZE = 1000;
-
-    /**
-     * The default waiting timeout: {@value #DEFAULT_WAITING_TIMEOUT}
-     * in millseconds when fetching notifications from
-     * an {@code EventClientDelegateMBean}.
-     */
-    public final static long DEFAULT_WAITING_TIMEOUT = 60000;
-
-    /**
-     * The default maximum notifications to fetch every time:
-     * {@value #DEFAULT_MAX_NOTIFICATIONS}.
-     */
-    public final static int DEFAULT_MAX_NOTIFICATIONS = DEFAULT_BUFFER_SIZE;
-
-    /**
-     * Constructs a default {@code FetchingEventRelay} object by using the default
-     * configuration: {@code DEFAULT_BUFFER_SIZE}, {@code DEFAULT_WAITING_TIMEOUT}
-     * {@code DEFAULT_MAX_NOTIFICATIONS}. A single thread is created
-     * to do fetching.
-     *
-     * @param delegate The {@code EventClientDelegateMBean} to work with.
-     * @throws IOException If failed to work with the {@code delegate}.
-     * @throws MBeanException if unable to add a client to the remote
-     * {@code EventClientDelegateMBean} (see {@link
-     * EventClientDelegateMBean#addClient(String, Object[], String[])
-     * EventClientDelegateMBean.addClient}).
-     * @throws IllegalArgumentException If {@code delegate} is {@code null}.
-     */
-    public FetchingEventRelay(EventClientDelegateMBean delegate)
-    throws IOException, MBeanException {
-        this(delegate, null);
-    }
-
-    /**
-     * Constructs a {@code FetchingEventRelay} object by using the default
-     * configuration: {@code DEFAULT_BUFFER_SIZE}, {@code DEFAULT_WAITING_TIMEOUT}
-     * {@code DEFAULT_MAX_NOTIFICATIONS}, with a user-specific executor to do
-     * the fetching.
-     *
-     * @param delegate The {@code EventClientDelegateMBean} to work with.
-     * @param fetchExecutor Used to do the fetching. A new thread is created if
-     * {@code null}.
-     * @throws IOException If failed to work with the {@code delegate}.
-     * @throws MBeanException if unable to add a client to the remote
-     * {@code EventClientDelegateMBean} (see {@link
-     * EventClientDelegateMBean#addClient(String, Object[], String[])
-     * EventClientDelegateMBean.addClient}).
-     * @throws IllegalArgumentException If {@code delegate} is {@code null}.
-     */
-    public FetchingEventRelay(EventClientDelegateMBean delegate,
-            Executor fetchExecutor) throws IOException, MBeanException {
-        this(delegate,
-                DEFAULT_BUFFER_SIZE,
-                DEFAULT_WAITING_TIMEOUT,
-                DEFAULT_MAX_NOTIFICATIONS,
-                fetchExecutor);
-    }
-
-    /**
-     * Constructs a {@code FetchingEventRelay} object with user-specific
-     * configuration and executor to fetch notifications via the
-     * {@link EventClientDelegateMBean}.
-     *
-     * @param delegate The {@code EventClientDelegateMBean} to work with.
-     * @param bufferSize The buffer size for saving notifications in
-     * {@link EventClientDelegateMBean} before they are fetched.
-     * @param timeout The waiting time in millseconds when fetching
-     * notifications from an {@code EventClientDelegateMBean}.
-     * @param maxNotifs The maximum notifications to fetch every time.
-     * @param fetchExecutor Used to do the fetching. A new thread is created if
-     * {@code null}.
-     * @throws IOException if failed to communicate with the {@code delegate}.
-     * @throws MBeanException if unable to add a client to the remote
-     * {@code EventClientDelegateMBean} (see {@link
-     * EventClientDelegateMBean#addClient(String, Object[], String[])
-     * EventClientDelegateMBean.addClient}).
-     * @throws IllegalArgumentException If {@code delegate} is {@code null}.
-     */
-    public FetchingEventRelay(EventClientDelegateMBean delegate,
-            int bufferSize,
-            long timeout,
-            int maxNotifs,
-            Executor fetchExecutor) throws IOException, MBeanException {
-        this(delegate,
-                bufferSize,
-                timeout,
-                maxNotifs,
-                fetchExecutor,
-                FetchingEventForwarder.class.getName(),
-                new Object[] {bufferSize},
-                new String[] {int.class.getName()});
-    }
-
-    /**
-     * Constructs a {@code FetchingEventRelay} object with user-specific
-     * configuration and executor to fetch notifications via the
-     * {@link EventClientDelegateMBean}.
-     *
-     * @param delegate The {@code EventClientDelegateMBean} to work with.
-     * @param bufferSize The buffer size for saving notifications in
-     * {@link EventClientDelegateMBean} before they are fetched.
-     * @param timeout The waiting time in millseconds when fetching
-     * notifications from an {@code EventClientDelegateMBean}.
-     * @param maxNotifs The maximum notifications to fetch every time.
-     * @param fetchExecutor Used to do the fetching.
-     * @param forwarderName the class name of a user specific EventForwarder
-     * to create in server to forward notifications to this object. The class
-     * should be a subclass of the class {@link FetchingEventForwarder}.
-     * @param params the parameters passed to create {@code forwarderName}
-     * @param sig the signature of the {@code params}
-     * @throws IOException if failed to communicate with the {@code delegate}.
-     * @throws MBeanException if unable to add a client to the remote
-     * {@code EventClientDelegateMBean} (see {@link
-     * EventClientDelegateMBean#addClient(String, Object[], String[])
-     * EventClientDelegateMBean.addClient}).
-     * @throws IllegalArgumentException if {@code bufferSize} or
-     * {@code maxNotifs} is less than {@code 1}
-     * @throws NullPointerException if {@code delegate} is {@code null}.
-     */
-    public FetchingEventRelay(EventClientDelegateMBean delegate,
-            int bufferSize,
-            long timeout,
-            int maxNotifs,
-            Executor fetchExecutor,
-            String forwarderName,
-            Object[] params,
-            String[] sig) throws IOException, MBeanException {
-
-        if (logger.traceOn()) {
-            logger.trace("FetchingEventRelay", "delegateMBean "+
-                    bufferSize+" "+
-                    timeout+" "+
-                    maxNotifs+" "+
-                    fetchExecutor+" "+
-                    forwarderName+" ");
-        }
-
-        if (delegate == null) {
-            throw new NullPointerException("Null EventClientDelegateMBean!");
-        }
-
-
-        if (bufferSize<=1) {
-            throw new IllegalArgumentException(
-                    "The bufferSize cannot be less than 1, no meaning.");
-        }
-
-        if (maxNotifs<=1) {
-            throw new IllegalArgumentException(
-                    "The maxNotifs cannot be less than 1, no meaning.");
-        }
-
-        clientId = delegate.addClient(
-                forwarderName,
-                params,
-                sig);
-
-        this.delegate = delegate;
-        this.timeout = timeout;
-        this.maxNotifs = maxNotifs;
-
-        if (fetchExecutor == null) {
-            ScheduledThreadPoolExecutor executor =
-                    new ScheduledThreadPoolExecutor(1, daemonThreadFactory);
-            executor.setKeepAliveTime(1, TimeUnit.SECONDS);
-            executor.allowCoreThreadTimeOut(true);
-            fetchExecutor = executor;
-            this.defaultExecutor = executor;
-        } else
-            this.defaultExecutor = null;
-        this.fetchExecutor = fetchExecutor;
-
-        startSequenceNumber = 0;
-        fetchingJob = new MyJob();
-    }
-
-    public synchronized void setEventReceiver(EventReceiver eventReceiver) {
-        if (logger.traceOn()) {
-            logger.trace("setEventReceiver", ""+eventReceiver);
-        }
-
-        EventReceiver old = this.eventReceiver;
-        this.eventReceiver = eventReceiver;
-        if (old == null && eventReceiver != null)
-            fetchingJob.resume();
-    }
-
-    public String getClientId() {
-        return clientId;
-    }
-
-    public synchronized void stop() {
-        if (logger.traceOn()) {
-            logger.trace("stop", "");
-        }
-        if (stopped) {
-            return;
-        }
-
-        stopped = true;
-        clientId = null;
-        if (defaultExecutor != null)
-            defaultExecutor.shutdown();
-    }
-
-    private class MyJob extends RepeatedSingletonJob {
-        public MyJob() {
-            super(fetchExecutor);
-        }
-
-        public boolean isSuspended() {
-            boolean b;
-            synchronized(FetchingEventRelay.this) {
-                b = stopped ||
-                        (eventReceiver == null) ||
-                        (clientId == null);
-            }
-
-            if (logger.traceOn()) {
-                logger.trace("-MyJob-isSuspended", ""+b);
-            }
-            return b;
-        }
-
-        public void task() {
-            logger.trace("MyJob-task", "");
-            long fetchTimeout = timeout;
-            NotificationResult nr = null;
-            Throwable failedExcep = null;
-            try {
-                nr = delegate.fetchNotifications(
-                        clientId,
-                        startSequenceNumber,
-                        maxNotifs,
-                        fetchTimeout);
-            } catch (Exception e) {
-                if (isSerialOrClassNotFound(e)) {
-                    try {
-                        nr = fetchOne();
-                    } catch (Exception ee) {
-                        failedExcep = e;
-                    }
-                } else {
-                    failedExcep = e;
-                }
-            }
-
-            if (failedExcep != null &&
-                    !isSuspended()) {
-                logger.fine("MyJob-task",
-                        "Failed to fetch notification, stopping...", failedExcep);
-                try {
-                    eventReceiver.failed(failedExcep);
-                } catch (Exception e) {
-                    logger.trace(
-                            "MyJob-task", "exception from eventReceiver.failed", e);
-                }
-
-                stop();
-            } else if (nr != null) {
-                try {
-                    eventReceiver.receive(nr);
-                } catch (RuntimeException e) {
-                    logger.trace(
-                            "MyJob-task",
-                            "exception delivering notifs to EventClient", e);
-                } finally {
-                    startSequenceNumber = nr.getNextSequenceNumber();
-                }
-            }
-        }
-    }
-
-    private NotificationResult fetchOne() throws Exception {
-        logger.trace("fetchOne", "");
-
-        while (true) {
-            try {
-                // 1 notif to skip possible missing class
-                return delegate.fetchNotifications(
-                        clientId,
-                        startSequenceNumber,
-                        1,
-                        timeout);
-            } catch (Exception e) {
-                if (isSerialOrClassNotFound(e)) { // skip and continue
-                    if (logger.traceOn()) {
-                        logger.trace("fetchOne", "Ignore", e);
-                    }
-                    eventReceiver.nonFatal(e);
-                    startSequenceNumber++;
-                } else {
-                    throw e;
-                }
-            }
-        }
-    }
-
-    static boolean isSerialOrClassNotFound(Exception e) {
-        Throwable cause = e.getCause();
-
-        while (cause != null &&
-                !(cause instanceof ClassNotFoundException) &&
-                !(cause instanceof NotSerializableException)) {
-            cause = cause.getCause();
-        }
-
-        return (cause instanceof ClassNotFoundException ||
-                cause instanceof NotSerializableException);
-    }
-
-    private long startSequenceNumber = 0;
-    private EventReceiver eventReceiver = null;
-    private final EventClientDelegateMBean delegate;
-    private String clientId;
-    private boolean stopped = false;
-
-    private final Executor fetchExecutor;
-    private final ExecutorService defaultExecutor;
-    private final MyJob fetchingJob;
-
-    private final long timeout;
-    private final int maxNotifs;
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event",
-            "FetchingEventRelay");
-    private static final ThreadFactory daemonThreadFactory =
-                    new DaemonThreadFactory("JMX FetchingEventRelay executor %d");
-}
--- a/src/share/classes/javax/management/event/ListenerInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,169 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-/**
- * This class specifies all the information required to register a user listener into
- * a remote MBean server. This class is not serializable because a user listener
- * is not serialized in order to be sent to the remote server.
- *
- * @since JMX 2.0
- */
-public class ListenerInfo {
-
-    /**
-     * Constructs a {@code ListenerInfo} object.
-     *
-     * @param name The name of the MBean to which the listener should
-     * be added.
-     * @param listener The listener object which will handle the
-     * notifications emitted by the MBean.
-     * @param filter The filter object. If the filter is null, no
-     * filtering will be performed before notifications are handled.
-     * @param handback The context to be sent to the listener when a
-     * notification is emitted.
-     * @param isSubscription If true, the listener is subscribed via
-     * an {@code EventManager}. Otherwise it is added to a registered MBean.
-     */
-    public ListenerInfo(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback,
-            boolean isSubscription) {
-        this.name = name;
-        this.listener = listener;
-        this.filter = filter;
-        this.handback = handback;
-        this.isSubscription = isSubscription;
-    }
-
-    /**
-     * Returns an MBean or an MBean pattern that the listener listens to.
-     *
-     * @return An MBean or an MBean pattern.
-     */
-    public ObjectName getObjectName() {
-        return name;
-    }
-
-    /**
-     * Returns the listener.
-     *
-     * @return The listener.
-     */
-    public NotificationListener getListener() {
-        return listener;
-    }
-
-    /**
-     * Returns the listener filter.
-     *
-     * @return The filter.
-     */
-    public NotificationFilter getFilter() {
-        return filter;
-    }
-
-    /**
-     * Returns the listener handback.
-     *
-     * @return The handback.
-     */
-    public Object getHandback() {
-        return handback;
-    }
-
-    /**
-     * Returns true if this is a subscription listener.
-     *
-     * @return True if this is a subscription listener.
-     *
-     * @see EventClient#addListeners
-     */
-    public boolean isSubscription() {
-        return isSubscription;
-    }
-
-    /**
-     * <p>Indicates whether some other object is "equal to" this one.
-     * The return value is true if and only if {@code o} is an instance of
-     * {@code ListenerInfo} and has equal values for all of its properties.</p>
-     */
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-
-        if (!(o instanceof ListenerInfo)) {
-            return false;
-        }
-
-        ListenerInfo li = (ListenerInfo)o;
-
-        boolean ret = name.equals(li.name) &&
-                (listener == li.listener) &&
-                (isSubscription == li.isSubscription);
-
-        if (filter != null) {
-            ret &= filter.equals(li.filter);
-        } else {
-            ret &= (li.filter == null);
-        }
-
-        if (handback != null) {
-            ret &= handback.equals(li.handback);
-        } else {
-            ret &= (li.handback == null);
-        }
-
-        return ret;
-    }
-
-    @Override
-    public int hashCode() {
-        return name.hashCode() + listener.hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return name.toString() + "_" +
-                listener + "_" +
-                filter + "_" +
-                handback + "_" +
-                isSubscription;
-    }
-
-    private final ObjectName name;
-    private final NotificationListener listener;
-    private final NotificationFilter filter;
-    private final Object handback;
-    private final boolean isSubscription;
-}
--- a/src/share/classes/javax/management/event/NotificationManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import java.io.IOException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-/**
- * This interface specifies methods to add and remove notification listeners
- * on named MBeans.
- */
-public interface NotificationManager {
-    /**
-     * <p>Adds a listener to a registered MBean.
-     * Notifications emitted by the MBean will be forwarded
-     * to the listener.
-     *
-     * @param name The name of the MBean on which the listener should
-     * be added.
-     * @param listener The listener object which will handle the
-     * notifications emitted by the registered MBean.
-     * @param filter The filter object. If filter is null, no
-     * filtering will be performed before handling notifications.
-     * @param handback The context to be sent to the listener when a
-     * notification is emitted.
-     *
-     * @exception InstanceNotFoundException The MBean name provided
-     * does not match any of the registered MBeans.
-     * @exception IOException A communication problem occurred when
-     * talking to the MBean server.
-     *
-     * @see #removeNotificationListener(ObjectName, NotificationListener)
-     * @see #removeNotificationListener(ObjectName, NotificationListener,
-     * NotificationFilter, Object)
-     */
-    public void addNotificationListener(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback)
-            throws InstanceNotFoundException,
-            IOException;
-
-    /**
-     * <p>Removes a listener from a registered MBean.</p>
-     *
-     * <P> If the listener is registered more than once, perhaps with
-     * different filters or callbacks, this method will remove all
-     * those registrations.
-     *
-     * @param name The name of the MBean on which the listener should
-     * be removed.
-     * @param listener The listener to be removed.
-     *
-     * @exception InstanceNotFoundException The MBean name provided
-     * does not match any of the registered MBeans.
-     * @exception ListenerNotFoundException The listener is not
-     * registered in the MBean.
-     * @exception IOException A communication problem occurred when
-     * talking to the MBean server.
-     *
-     * @see #addNotificationListener(ObjectName, NotificationListener,
-     * NotificationFilter, Object)
-     */
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener)
-            throws InstanceNotFoundException,
-            ListenerNotFoundException,
-            IOException;
-
-    /**
-     * <p>Removes a listener from a registered MBean.</p>
-     *
-     * <p>The MBean must have a listener that exactly matches the
-     * given <code>listener</code>, <code>filter</code>, and
-     * <code>handback</code> parameters.  If there is more than one
-     * such listener, only one is removed.</p>
-     *
-     * <p>The <code>filter</code> and <code>handback</code> parameters
-     * may be null if and only if they are null in a listener to be
-     * removed.</p>
-     *
-     * @param name The name of the MBean on which the listener should
-     * be removed.
-     * @param listener The listener to be removed.
-     * @param filter The filter that was specified when the listener
-     * was added.
-     * @param handback The handback that was specified when the
-     * listener was added.
-     *
-     * @exception InstanceNotFoundException The MBean name provided
-     * does not match any of the registered MBeans.
-     * @exception ListenerNotFoundException The listener is not
-     * registered in the MBean, or it is not registered with the given
-     * filter and handback.
-     * @exception IOException A communication problem occurred when
-     * talking to the MBean server.
-     *
-     * @see #addNotificationListener(ObjectName, NotificationListener,
-     * NotificationFilter, Object)
-     *
-     */
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback)
-            throws InstanceNotFoundException,
-            ListenerNotFoundException,
-            IOException;
-}
--- a/src/share/classes/javax/management/event/RMIPushEventForwarder.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,198 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import com.sun.jmx.event.DaemonThreadFactory;
-import com.sun.jmx.event.RepeatedSingletonJob;
-import com.sun.jmx.remote.util.ClassLogger;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import javax.management.Notification;
-import javax.management.remote.NotificationResult;
-import javax.management.remote.TargetedNotification;
-
-
-/**
- * This class is used by {@link RMIPushEventRelay}. When
- * {@link RMIPushEventRelay} calls {@link
- * EventClientDelegateMBean#addClient(String, Object[], String[])} to get a new
- * client identifier, it uses this class name as the
- * first argument to ask {@code EventClientDelegateMBean} to create an object of
- * this class.
- * Then {@code EventClientDelegateMBean} forwards client notifications
- * to this object. This object then continues forwarding the notifications
- * to the {@code RMIPushEventRelay}.
- */
-public class RMIPushEventForwarder implements EventForwarder {
-    private static final int DEFAULT_BUFFER_SIZE = 6000;
-
-    /**
-     * Creates a new instance of {@code RMIPushEventForwarder}.
-     *
-     * @param receiver An RMI stub exported to receive notifications
-     * from this object for its {@link RMIPushEventRelay}.
-     *
-     * @param bufferSize The maximum number of notifications to store
-     * while waiting for the last remote send to complete.
-     */
-    public RMIPushEventForwarder(RMIPushServer receiver, int bufferSize) {
-        if (logger.traceOn()) {
-            logger.trace("RMIEventForwarder", "new one");
-        }
-
-        if (bufferSize < 0) {
-            throw new IllegalArgumentException(
-                    "Negative buffer size: " + bufferSize);
-        } else if (bufferSize == 0)
-            bufferSize = DEFAULT_BUFFER_SIZE;
-
-        if (receiver == null) {
-            throw new NullPointerException();
-        }
-
-        this.receiver = receiver;
-        this.buffer = new ArrayBlockingQueue<TargetedNotification>(bufferSize);
-    }
-
-    public void forward(Notification n, Integer listenerId) {
-        if (logger.traceOn()) {
-            logger.trace("forward", "to the listener: "+listenerId);
-        }
-        synchronized(sendingJob) {
-            TargetedNotification tn = new TargetedNotification(n, listenerId);
-            while (!buffer.offer(tn)) {
-                buffer.remove();
-                passed++;
-            }
-            sendingJob.resume();
-        }
-    }
-
-    public void close() {
-        if (logger.traceOn()) {
-            logger.trace("close", "called");
-        }
-
-        synchronized(sendingJob) {
-            ended = true;
-            buffer.clear();
-        }
-    }
-
-    public void setClientId(String clientId) {
-        if (logger.traceOn()) {
-            logger.trace("setClientId", clientId);
-        }
-    }
-
-    private class SendingJob extends RepeatedSingletonJob {
-        public SendingJob() {
-            super(executor);
-        }
-
-        public boolean isSuspended() {
-            return ended || buffer.isEmpty();
-        }
-
-        public void task() {
-            final long earliest = passed;
-
-            List<TargetedNotification> tns =
-                    new ArrayList<TargetedNotification>(buffer.size());
-            synchronized(sendingJob) {
-                buffer.drainTo(tns);
-                passed += tns.size();
-            }
-
-            if (logger.traceOn()) {
-                logger.trace("SendingJob-task", "sending: "+tns.size());
-            }
-
-            if (!tns.isEmpty()) {
-                try {
-                    TargetedNotification[] tnArray =
-                            new TargetedNotification[tns.size()];
-                    tns.toArray(tnArray);
-                    receiver.receive(new NotificationResult(earliest, passed, tnArray));
-                } catch (RemoteException e) {
-                    if (logger.debugOn()) {
-                        logger.debug("SendingJob-task",
-                                "Got exception to forward notifs.", e);
-                    }
-
-                    long currentLost = passed - earliest;
-                    if (FetchingEventRelay.isSerialOrClassNotFound(e)) {
-                        // send one by one
-                        long tmpPassed = earliest;
-                        for (TargetedNotification tn : tns) {
-                            try {
-                                receiver.receive(new NotificationResult(earliest,
-                                        ++tmpPassed, new TargetedNotification[]{tn}));
-                            } catch (RemoteException ioee) {
-                                logger.trace(
-                                        "SendingJob-task", "send to remote", ioee);
-                                // sends nonFatal notifs?
-                            }
-                        }
-
-                        currentLost = passed - tmpPassed;
-                    }
-
-                    if (currentLost > 0) { // inform of the lost.
-                        try {
-                            receiver.receive(new NotificationResult(
-                                    passed, passed,
-                                    new TargetedNotification[]{}));
-                        } catch (RemoteException ee) {
-                            logger.trace(
-                                    "SendingJob-task", "receiver.receive", ee);
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    private long passed = 0;
-
-    private static final ExecutorService executor =
-            Executors.newCachedThreadPool(
-            new DaemonThreadFactory("JMX RMIEventForwarder Executor"));
-    private final SendingJob sendingJob = new SendingJob();
-
-    private final BlockingQueue<TargetedNotification> buffer;
-
-    private final RMIPushServer receiver;
-    private boolean ended = false;
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "RMIEventForwarder");
-}
--- a/src/share/classes/javax/management/event/RMIPushEventRelay.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,161 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.io.IOException;
-import java.rmi.NoSuchObjectException;
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-import java.rmi.server.RMIClientSocketFactory;
-import java.rmi.server.RMIServerSocketFactory;
-import javax.management.MBeanException;
-import javax.management.remote.NotificationResult;
-
-/**
- * This class is an implementation of the {@link EventRelay} interface, using
- * push mode. It exports an RMI object that {@link RMIPushEventForwarder} uses
- * to forward notifications.
- *
- * @since JMX 2.0
- */
-public class RMIPushEventRelay implements EventRelay {
-    /**
-     * Constructs a default {@code RMIPushEventRelay} object
-     * and exports its {@linkplain RMIPushServer notification
-     * receiver} on any free port. This constructor is equivalent
-     * to {@link #RMIPushEventRelay(EventClientDelegateMBean,
-     * int, RMIClientSocketFactory, RMIServerSocketFactory, int)
-     * RMIPushEventRelay(delegate, 0, null, null, <em>&lt;default buffer
-     * size&gt;</em>)}.
-     *
-     * @param delegate The {@link EventClientDelegateMBean} proxy to work with.
-     * @throws IOException if failed to communicate with
-     * {@link EventClientDelegateMBean}.
-     * @throws MBeanException if the {@link EventClientDelegateMBean} failed
-     * to create an {@code EventForwarder} for this object.
-     */
-    public RMIPushEventRelay(EventClientDelegateMBean delegate)
-    throws IOException, MBeanException {
-        this(delegate, 0, null,  null, 0);
-    }
-
-    /**
-     * Constructs a {@code RMIPushEventRelay} object and exports its
-     * {@linkplain RMIPushServer notification receiver} on a specified port.
-     *
-     * @param delegate The {@link EventClientDelegateMBean} proxy to work with.
-     * @param port The port used to export an RMI object to receive notifications
-     * from a server. If the port is zero, an anonymous port is used.
-     * @param csf The client socket factory used to export the RMI object.
-     * Can be null.
-     * @param ssf The server socket factory used to export the RMI object.
-     * Can be null.
-     * @param bufferSize The number of notifications held on the server
-     * while waiting for the previous transmission to complete.  A value of
-     * zero means the default buffer size.
-     *
-     * @throws IOException if failed to communicate with
-     * {@link EventClientDelegateMBean}.
-     * @throws MBeanException if the {@link EventClientDelegateMBean} failed
-     * to create an {@code EventForwarder} for this object.
-     *
-     * @see RMIPushEventForwarder#RMIPushEventForwarder(RMIPushServer, int)
-     */
-    public RMIPushEventRelay(EventClientDelegateMBean delegate,
-            int port,
-            RMIClientSocketFactory csf,
-            RMIServerSocketFactory ssf,
-            int bufferSize)
-            throws IOException, MBeanException {
-
-        UnicastRemoteObject.exportObject(exportedReceiver, port, csf, ssf);
-
-        clientId = delegate.addClient(
-                RMIPushEventForwarder.class.getName(),
-                new Object[] {exportedReceiver, bufferSize},
-                new String[] {RMIPushServer.class.getName(),
-                              int.class.getName()});
-    }
-
-    public String getClientId() {
-        return clientId;
-    }
-
-    public void setEventReceiver(EventReceiver receiver) {
-        if (logger.traceOn()) {
-            logger.trace("setEventReceiver", ""+receiver);
-        }
-        synchronized(lock) {
-            this.receiver = receiver;
-        }
-    }
-
-    public void stop() {
-        if (logger.traceOn()) {
-            logger.trace("stop", "");
-        }
-        synchronized(lock) {
-            if (stopped) {
-                return;
-            } else {
-                stopped = true;
-            }
-
-            if (clientId == null) {
-                return;
-            }
-
-            try {
-                UnicastRemoteObject.unexportObject(exportedReceiver, true);
-            } catch (NoSuchObjectException nsoe) {
-                logger.fine("RMIPushEventRelay.stop", "unexport", nsoe);
-                // OK: we wanted it unexported, and apparently it already is
-            }
-        }
-    }
-
-    private volatile String clientId;
-    private volatile EventReceiver receiver;
-
-    private RMIPushServer exportedReceiver = new RMIPushServer() {
-        public void receive(NotificationResult nr) throws RemoteException {
-            if (logger.traceOn()) {
-                logger.trace("EventPusherImpl-receive","");
-            }
-            receiver.receive(nr);
-            // Any exception will be sent back to the client.
-        }
-    };
-
-    private boolean stopped = false;
-
-    private final int[] lock = new int[0];
-
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event",
-            "PushEventRelay");
-}
--- a/src/share/classes/javax/management/event/RMIPushServer.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.event;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import javax.management.remote.NotificationResult;
-
-/**
- * The {@link RMIPushEventRelay} exports an RMI object of this class and
- * sends a client stub for that object to the associated
- * {@link RMIPushEventForwarder} in a remote MBean server.  The
- * {@code RMIPushEventForwarder} then sends notifications to the
- * RMI object.
- */
-public interface RMIPushServer extends Remote {
-    /**
-     * <p>Dispatch the notifications in {@code nr} to the {@link RMIPushEventRelay}
-     * associated with this object.</p>
-     * @param nr the notification result to dispatch.
-     * @throws java.rmi.RemoteException if the remote invocation of this method
-     * failed.
-     */
-    public void receive(NotificationResult nr) throws RemoteException;
-}
--- a/src/share/classes/javax/management/event/package-info.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,312 +0,0 @@
-/**
- * <p>Defines the <em>Event Service</em>, which provides extended support
- * for JMX notifications.</p>
- *
- * <p>The Event Service provides greater control over
- * notification handling than the default technique using {@link
- * javax.management.MBeanServer#addNotificationListener(ObjectName,
- * NotificationListener, NotificationFilter, Object)
- * MBeanServer.addNotificationListener} or {@link
- * javax.management.MBeanServerConnection#addNotificationListener(ObjectName,
- * NotificationListener, NotificationFilter, Object)
- * MBeanServerConnection.addNotificationListener}.</p>
- *
- * <p>Here are some reasons you may want to use the Event Service:</p>
- *
- * <ul>
- * <li>To receive notifications from a set of MBeans defined by an
- * ObjectName pattern, such as {@code com.example.config:type=Cache,*}.
- *
- * <li>When the notification-handling behavior of the connector you are
- * using does not match your requirements.  For example, with the standard
- * RMI connector you can lose notifications if there are very many of them
- * in the MBean Server you are connected to, even if you are only listening
- * for a small proportion of them.
- *
- * <li>To change the threading behavior of notification dispatch.
- *
- * <li>To define a different transport for notifications, for example to
- * arrange for them to be delivered through the Java Message Service (<a
- * href="http://java.sun.com/jms">JMS</a>).  The Event Service comes with
- * one alternative transport as standard, a "push-mode" RMI transport.
- *
- * <li>To handle notifications on behalf of MBeans (often virtual) in a
- * namespace.
- * </ul>
- *
- * <p>The Event Service is new in version 2.0 of the JMX API, which is the
- * version introduced in version 7 of the Java SE platform.  It is not usually
- * possible to use the Event Service when connecting remotely to an
- * MBean Server that is running an earlier version.</p>
- *
- *
- * <h3 id="handlingremote">Handling remote notifications with the Event
- * Service</h3>
- *
- * <p>Prior to version 2.0 of the JMX API, every connector
- * had to include logic to handle notifications. The standard {@linkplain
- * javax.management.remote.rmi RMI} and JMXMP connectors defined by <a
- * href="http://jcp.org/en/jsr/detail?id=160">JSR 160</a> handle notifications
- * in a way that is not always appropriate for applications. Specifically,
- * the connector server adds one listener to every MBean that might emit
- * notifications, and adds all received notifications to a fixed-size
- * buffer. This means that if there are very many notifications, a
- * remote client may miss some, even if it is only registered for a
- * very small subset of notifications. Furthermore, since every {@link
- * javax.management.NotificationBroadcaster NotificationBroadcaster} MBean
- * gets a listener from the connector server, MBeans cannot usefully optimize
- * by only sending notifications when there is a listener. Finally, since
- * the connector server uses just one listener per MBean, MBeans cannot
- * impose custom behavior per listener, such as security checks or localized
- * notifications.</p>
- *
- * <p>The Event Service does not have these restrictions.  The RMI connector
- * that is included in this version of the JMX API uses the Event Service by
- * default, although it can be configured to have the previous behavior if
- * required.</p>
- *
- * <p>The Event Service can be used with <em>any</em> connector via the
- * method {@link javax.management.event.EventClient#getEventClientConnection
- * EventClient.getEventClientConnection}, like this:</p>
- *
- * <pre>
- * JMXConnector conn = ...;
- * MBeanServerConnection mbsc = conn.getMBeanServerConnection();
- * MBeanServerConnection eventMbsc = EventClient.getEventClientConnection(mbsc);
- * </pre>
- *
- * <p>If you add listeners using {@code eventMbsc.addNotificationListener}
- * instead of {@code mbsc.addNotificationListener}, then they will be handled
- * by the Event Service rather than by the connector's notification system.</p>
- *
- * <p>For the Event Service to work, either the {@link
- * javax.management.event.EventClientDelegateMBean EventClientDelegateMBean}
- * must be registered in the MBean Server, or the connector server must
- * be configured to simulate the existence of this MBean, for example
- * using {@link javax.management.event.EventClientDelegate#newForwarder
- * EventClientDelegate.newForwarder}. The standard RMI connector is so
- * configured by default. The {@code EventClientDelegateMBean} documentation
- * has further details.</p>
- *
- *
- * <h3 id="subscribepattern">Receiving notifications from a set of MBeans</h3>
- *
- * <p>The Event Server allows you to receive notifications from every MBean
- * that matches an {@link javax.management.ObjectName ObjectName} pattern.
- * For local clients (in the same JVM as the MBean Server), the {@link
- * javax.management.event.EventSubscriber EventSubscriber} class can be used for
- * this. For remote clients, or if the same code is to be used locally and
- * remotely, use an
- * {@link javax.management.event.EventClient EventClient}.</p>
- *
- * <p>EventSubscriber and EventClient correctly handle the case where a new
- * MBean is registered under a name that matches the pattern. Notifications
- * from the new MBean will also be received.</p>
- *
- * <p>Here is how to receive notifications from all MBeans in a local
- * {@code MBeanServer} that match {@code com.example.config:type=Cache,*}:</p>
- *
- * <pre>
- * MBeanServer mbs = ...;
- * NotificationListener listener = ...;
- * ObjectName pattern = new ObjectName("com.example.config:type=Cache,*");
- * EventSubscriber esub = EventSubscriber.getEventSubscriber(mbs);
- * esub.{@link javax.management.event.EventSubscriber#subscribe
- * subscribe}(pattern, listener, null, null);
- * </pre>
- *
- * <p>Here is how to do the same thing remotely:</p>
- *
- * <pre>
- * MBeanServerConnection mbsc = jmxConnector.getMBeanServerConnection();
- * EventClient events = new EventClient(mbsc);
- * NotificationListener listener = ...;
- * ObjectName pattern = new ObjectName("com.example.config:type=Cache,*");
- * events.{@link javax.management.event.EventClient#subscribe
- * subscribe}(pattern, listener, null, null);
- * </pre>
- *
- *
- * <h3 id="threading">Controlling threading behavior for notification
- * dispatch</h3>
- *
- * <p>The EventClient class can be used to control threading of listener
- * dispatch.  For example, to arrange for all listeners to be invoked
- * in the same thread, you can create an {@code EventClient} like this:</p>
- *
- * <pre>
- * MBeanServerConnection mbsc = ...;
- * Executor singleThreadExecutor = {@link
- * java.util.concurrent.Executors#newSingleThreadExecutor()
- * Executors.newSingleThreadExecutor}();
- * EventClient events = new EventClient(
- *         mbsc, null, singleThreadExecutor, EventClient.DEFAULT_LEASE_TIMEOUT);
- * events.addNotificationListener(...);
- * events.subscribe(...);
- * </pre>
- *
- *
- * <h3 id="leasing">Leasing</h3>
- *
- * <p>The {@code EventClient} uses a <em>lease</em> mechanism to ensure
- * that resources are eventually released on the server even if the client
- * does not explicitly clean up.  (This can happen through network
- * partitioning, for example.)</p>
- *
- * <p>When an {@code EventClient} registers with the {@code
- * EventClientDelegateMBean} using one of the {@code addClient} methods,
- * an initial lease is created with a default expiry time. The {@code
- * EventClient} requests an explicit lease shortly after that, with a
- * configurable expiry time. Then the {@code EventClient} periodically
- * <em>renews</em> the lease before it expires, typically about half way
- * through the lifetime of the lease. If at any point the lease reaches
- * the expiry time of the last renewal then it expires, and {@code
- * EventClient} is unregistered as if it had called the {@link
- * javax.management.event.EventClientDelegateMBean#removeClient removeClient}
- * method.</p>
- *
- *
- * <h3 id="transports">Custom notification transports</h3>
- *
- * <p>When you create an {@code EventClient}, you can define the transport
- * that it uses to deliver notifications. The transport might use the
- * Java Message Service (<a href="http://java.sun.com/jms">JMS</a>) or
- * any other communication system. Specifying a transport is useful for
- * example when you want different network behavior from the default, or
- * different reliability guarantees. The default transport calls {@link
- * javax.management.event.EventClientDelegateMBean#fetchNotifications
- * EventClientDelegateMBean.fetchNotifications} repeatedly, which usually means
- * that there must be a network connection permanently open between the client
- * and the server. If the same client is connected to many servers this can
- * cause scalability problems.  If notifications are relatively rare, then
- * JMS or the {@linkplain javax.management.event.RMIPushEventRelay push-mode
- * RMI transport} may be more suitable.</p>
- *
- * <p>A transport is implemented by an {@link javax.management.event.EventRelay
- * EventRelay} on the client side and a corresponding {@link
- * javax.management.event.EventForwarder EventForwarder}
- * on the server side. An example is the {@link
- * javax.management.event.RMIPushEventRelay RMIPushEventRelay} and its
- * {@link javax.management.event.RMIPushEventForwarder RMIPushEventForwarder}.</p>
- *
- * <p>To use a given transport with an {@code EventClient}, you first create
- * an instance of its {@code EventRelay}. Typically the {@code EventRelay}'s
- * constructor will have a parameter of type {@code MBeanServerConnection}
- * or {@code EventClientDelegateMBean}, so that it can communicate with the
- * {@code EventClientDelegateMBean} in the server. For example, the {@link
- * javax.management.event.RMIPushEventForwarder RMIPushEventForwarder}'s constructors
- * all take an {@code EventClientDelegateMBean} parameter, which is expected to
- * be a {@linkplain javax.management.JMX#newMBeanProxy(MBeanServerConnection,
- * ObjectName, Class) proxy} for the {@code EventClientDelegateMBean} in the
- * server.</p>
- *
- * <p>When it is created, the {@code EventRelay} will call
- * {@link javax.management.event.EventClientDelegateMBean#addClient(String,
- * Object[], String[]) EventClientDelegateMBean.addClient}.  It passes the
- * name of the {@code EventForwarder} class and its constructor parameters.
- * The {@code EventClientDelegateMBean} will instantiate this class using
- * {@link javax.management.MBeanServer#instantiate(String, Object[], String[])
- * MBeanServer.instantiate}, and it will return a unique <em>client id</em>.</p>
- *
- * <p>Then you pass the newly-created {@code EventRelay} to one of the {@code
- * EventClient} constructors, and you have an {@code EventClient} that uses the
- * chosen transport.</p>
- *
- * <p>For example, when you create an {@code RMIPushEventRelay}, it
- * uses {@code MBeanServerDelegateMBean.addClient} to create an {@code
- * RMIEventForwarder} in the server. Notifications will then be delivered
- * through an RMI communication from the {@code RMIEventForwarder} to the
- * {@code RMIPushEventRelay}.</p>
- *
- *
- * <h4 id="writingcustomtransport">Writing a custom transport</h4>
- *
- * <p>To write a custom transport, you need to understand the sequence
- * of events when an {@code EventRelay} and its corresponding {@code
- * EventForwarder} are created, and when a notification is sent from the {@code
- * EventForwarder} to the {@code EventRelay}.</p>
- *
- * <p>When an {@code EventRelay} is created:</p>
- *
- * <ul>
- * <li><p>The {@code EventRelay} must call {@code
- * EventClientDelegateMBean.addClient} with the name of the {@code
- * EventForwarder} and the constructor parameters.</p>
- *
- * <li><p>{@code EventClientDelegateMBean.addClient} will do the following
- * steps:</p>
- *
- * <ul>
- * <li>create the {@code EventForwarder} using {@code MBeanServer.instantiate};
- * <li>allocate a unique client id;
- * <li>call the new {@code EventForwarder}'s {@link
- * javax.management.event.EventForwarder#setClientId setClientId} method with
- * the new client id;
- * <li>return the client id to the caller.
- * </ul>
- *
- * </ul>
- *
- * <p>When an {@code EventClient} is created with an {@code EventRelay}
- * parameter, it calls {@link javax.management.event.EventRelay#setEventReceiver
- * EventRelay.setEventReceiver} with an {@code EventReceiver} that the
- * {@code EventRelay} will use to deliver notifications.</p>
- *
- * <p>When a listener is added using the {@code EventClient}, the
- * {@code EventRelay} and {@code EventForwarder} are not involved.</p>
- *
- * <p>When an MBean emits a notification and a listener has been added
- * to that MBean using the {@code EventClient}:</p>
- *
- * <ul>
- * <li><p>The {@code EventForwarder}'s
- * {@link javax.management.event.EventForwarder#forward forward} method
- * is called with the notification and a <em>listener id</em>.</p>
- *
- * <li><p>The {@code EventForwarder} sends the notification and listener id
- * to the {@code EventRelay} using the custom transport.</p>
- *
- * <li><p>The {@code EventRelay} delivers the notification by calling
- * {@link javax.management.event.EventReceiver#receive EventReceiver.receive}.</p>
- * </ul>
- *
- * <p>When the {@code EventClient} is closed ({@link
- * javax.management.event.EventClient#close EventClient.close}):</p>
- *
- * <ul>
- * <li><p>The {@code EventClient} calls {@link
- * javax.management.event.EventRelay#stop EventRelay.stop}.</p>
- *
- * <li><p>The {@code EventClient} calls {@link
- * javax.management.event.EventClientDelegateMBean#removeClient
- * EventClientDelegateMBean.removeClient}.</p>
- *
- * <li><p>The {@code EventClientDelegateMBean} removes any listeners it
- * had added on behalf of this {@code EventClient}.</p>
- *
- * <li><p>The {@code EventClientDelegateMBean} calls
- * {@link javax.management.event.EventForwarder#close EventForwarder.close}.</p>
- * </ul>
- *
- *
- * <h4 id="threading">Threading and buffering</h3>
- *
- * <p>The {@link javax.management.event.EventForwarder#forward
- * EventForwarder.forward} method may be called in the thread that the
- * source MBean is using to send its notification.  MBeans can expect
- * that notification sending does not block.  Therefore a {@code forward}
- * method will typically add the notification to a queue, with a separate
- * thread that takes notifications off the queue and sends them.</p>
- *
- * <p>An {@code EventRelay} does not usually need to buffer notifications
- * before giving them to
- * {@link javax.management.event.EventReceiver#receive EventReceiver.receive}.
- * Although by default each such notification will be sent to potentially-slow
- * listeners, if this is a problem then an {@code Executor} can be given to
- * the {@code EventClient} constructor to cause the listeners to be called
- * in a different thread.</p>
- *
- * @since 1.7
- */
-
-package javax.management.event;
--- a/src/share/classes/javax/management/modelmbean/DescriptorSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/modelmbean/DescriptorSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -229,10 +229,9 @@
             init(inDescr.descriptorMap);
     }
 
+
     /**
-     * <p>Descriptor constructor taking an XML String or a
-     * <i>fieldName=fieldValue</i> format String. The String parameter is
-     * parsed as XML if it begins with a '<' character.</p>
+     * <p>Descriptor constructor taking an XML String.</p>
      *
      * <p>The format of the XML string is not defined, but an
      * implementation must ensure that the string returned by
@@ -245,20 +244,17 @@
      * programmer will have to reset or convert these fields
      * correctly.</p>
      *
-     * @param inStr An XML-format or a fieldName=fieldValue formatted string
-     * used to populate this Descriptor.  The XML format is not defined, but any
+     * @param inStr An XML-formatted string used to populate this
+     * Descriptor.  The format is not defined, but any
      * implementation must ensure that the string returned by
      * method {@link #toXMLString toXMLString} on an existing
      * descriptor can be used to instantiate an equivalent
      * descriptor when instantiated using this constructor.
      *
-     * @exception RuntimeOperationsException If the String inStr passed in
-     * parameter is null or, when it is not an XML string, if the field name or
-     * field value is illegal. If inStr is not an XML string then it must
-     * contain an "=". "fieldValue", "fieldName", and "fieldValue" are illegal.
-     * FieldName cannot be empty. "fieldName=" will cause the value to be empty.
+     * @exception RuntimeOperationsException If the String inStr
+     * passed in parameter is null
      * @exception XMLParseException XML parsing problem while parsing
-     * the XML-format input String
+     * the input String
      * @exception MBeanException Wraps a distributed communication Exception.
      */
     /* At some stage we should rewrite this code to be cleverer.  Using
@@ -287,27 +283,14 @@
             throw new RuntimeOperationsException(iae, msg);
         }
 
-        // parse parameter string into structures
-
-        init(null);
-
-        if(!inStr.startsWith("<")) {
-            parseNamesValues(inStr);
-            if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-                MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(name=value)", "Exit");
-            }
-            return;
-        }
-
         final String lowerInStr = inStr.toLowerCase();
         if (!lowerInStr.startsWith("<descriptor>")
             || !lowerInStr.endsWith("</descriptor>")) {
             throw new XMLParseException("No <descriptor>, </descriptor> pair");
         }
 
-
+        // parse xmlstring into structures
+        init(null);
         // create dummy descriptor: should have same size
         // as number of fields in xmlstring
         // loop through structures and put them in descriptor
@@ -471,16 +454,6 @@
 
         init(null);
 
-        parseNamesValues(fields);
-
-        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
-            MODELMBEAN_LOGGER.logp(Level.FINEST,
-                    DescriptorSupport.class.getName(),
-                    "Descriptor(String... fields)", "Exit");
-        }
-    }
-
-    private void parseNamesValues(String... fields) {
         for (int i=0; i < fields.length; i++) {
             if ((fields[i] == null) || (fields[i].equals(""))) {
                 continue;
@@ -522,6 +495,11 @@
 
             setField(fieldName,fieldValue);
         }
+        if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
+            MODELMBEAN_LOGGER.logp(Level.FINEST,
+                    DescriptorSupport.class.getName(),
+                    "Descriptor(String... fields)", "Exit");
+        }
     }
 
     private void init(Map<String, ?> initMap) {
--- a/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -231,16 +231,14 @@
          * @param descriptor An instance of Descriptor containing the
          * appropriate metadata for this instance of the Attribute. If
          * it is null, then a default descriptor will be created.  If
-         * the descriptor does not contain all the following fields,
-         * the missing ones are added with their default values:
-         * displayName, name, descriptorType.
+         * the descriptor does not contain the field "displayName" this field is added
+         * in the descriptor with its default value.
          * @exception IntrospectionException There is a consistency
          * problem in the definition of this attribute.
          * @exception RuntimeOperationsException Wraps an
-         * IllegalArgumentException. The descriptor is invalid, or
-         * descriptor field "name" is present but not equal to name
-         * parameter, or descriptor field "descriptorType" is present
-         * but not equal to "attribute".
+         * IllegalArgumentException. The descriptor is invalid, or descriptor
+         * field "name" is not equal to name parameter, or descriptor field
+         * "descriptorType" is not equal to "attribute".
          *
          */
 
@@ -295,7 +293,7 @@
         }
 
         /**
-         * Constructs a ModelMBeanAttributeInfo object with a default descriptor.
+         * Constructs a ModelMBeanAttributeInfo object.
          *
          * @param name The name of the attribute
          * @param type The type or class name of the attribute
@@ -306,14 +304,12 @@
          * @param descriptor An instance of Descriptor containing the
          * appropriate metadata for this instance of the Attribute. If
          * it is null then a default descriptor will be created.  If
-         * the descriptor does not contain all the following fields,
-         * the missing ones are added with their default values:
-         * displayName, name, descriptorType.
+         * the descriptor does not contain the field "displayName" this field
+         * is added in the descriptor with its default value.
          * @exception RuntimeOperationsException Wraps an
-         * IllegalArgumentException. The descriptor is invalid, or
-         * descriptor field "name" is present but not equal to name
-         * parameter, or descriptor field "descriptorType" is present
-         * but not equal to "attribute".
+         * IllegalArgumentException. The descriptor is invalid, or descriptor
+         * field "name" is not equal to name parameter, or descriptor field
+         * "descriptorType" is not equal to "attribute".
          *
          */
         public ModelMBeanAttributeInfo(String name,
@@ -392,9 +388,6 @@
         * assigned.  If the new Descriptor is invalid, then a
         * RuntimeOperationsException wrapping an
         * IllegalArgumentException is thrown.
-        * If the descriptor does not contain all the following fields, the
-        * missing ones are added with
-        * their default values: displayName, name, descriptorType.
         * @param inDescriptor replaces the Descriptor associated with the
         * ModelMBeanAttributeInfo
         *
@@ -415,6 +408,7 @@
         * fails for any reason, this exception will be thrown.
         */
 
+        @Override
         public Object clone()
         {
             if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
@@ -429,6 +423,7 @@
         * Returns a human-readable version of the
         * ModelMBeanAttributeInfo instance.
         */
+        @Override
         public String toString()
         {
             return
@@ -456,7 +451,8 @@
         private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
 
             Descriptor clone;
-            if (in == null) {
+            boolean defaulted = (in == null);
+            if (defaulted) {
                 clone = new DescriptorSupport();
                 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
             } else {
@@ -464,11 +460,11 @@
             }
 
             //Setting defaults.
-            if (clone.getFieldValue("name")==null) {
+            if (defaulted && clone.getFieldValue("name")==null) {
                 clone.setField("name", this.getName());
                 MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
             }
-            if (clone.getFieldValue("descriptorType")==null) {
+            if (defaulted && clone.getFieldValue("descriptorType")==null) {
                 clone.setField("descriptorType", "attribute");
                 MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"attribute\"");
             }
@@ -483,13 +479,13 @@
                     "The isValid() method of the Descriptor object itself returned false,"+
                     "one or more required fields are invalid. Descriptor:" + clone.toString());
             }
-            if (! ((String)clone.getFieldValue("name")).equalsIgnoreCase(this.getName())) {
+            if (!getName().equalsIgnoreCase((String)clone.getFieldValue("name"))) {
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                     "The Descriptor \"name\" field does not match the object described. " +
                      " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
             }
 
-            if (! ((String)clone.getFieldValue("descriptorType")).equalsIgnoreCase("attribute")) {
+            if (!"attribute".equalsIgnoreCase((String)clone.getFieldValue("descriptorType"))) {
                      throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                     "The Descriptor \"descriptorType\" field does not match the object described. " +
                      " Expected: \"attribute\" ," + " was: " + clone.getFieldValue("descriptorType"));
--- a/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -78,9 +78,7 @@
  * are meaningless for constructors, but are not considered invalid.</p>
  *
  * <p>The default descriptor will have the {@code name}, {@code
- * descriptorType}, {@code displayName} and {@code role} fields.  The
- * default value of the {@code name} and {@code displayName} fields is
- * the name of the constructor.
+ * descriptorType}, {@code displayName} and {@code role} fields.
  *
  * <p>The <b>serialVersionUID</b> of this class is <code>3862947819818064362L</code>.
  *
@@ -193,14 +191,14 @@
         * appropriate metadata for this instance of the
         * ModelMBeanConstructorInfo.  If it is null, then a default
         * descriptor will be created. If the descriptor does not
-        * contain all the following fields, the missing ones are added with
-        * their default values: displayName, name, role, descriptorType.
+        * contain the field "displayName" this field is added in the
+        * descriptor with its default value.
         *
         * @exception RuntimeOperationsException Wraps an
         * IllegalArgumentException. The descriptor is invalid, or
-        * descriptor field "name" is present but not equal to name
-        * parameter, or descriptor field "descriptorType" is present
-        * but not equal to "operation" or descriptor field "role" is
+        * descriptor field "name" is not equal to name
+        * parameter, or descriptor field "descriptorType" is
+        * not equal to "operation" or descriptor field "role" is
         * present but not equal to "constructor".
         */
 
@@ -250,15 +248,14 @@
         * @param signature MBeanParameterInfo objects describing the parameters(arguments) of the constructor.
         * @param descriptor An instance of Descriptor containing the appropriate metadata
         *                   for this instance of the MBeanConstructorInfo. If it is null then a default descriptor will be created.
-        * If the descriptor does not
-        * contain all the following fields, the missing ones are added with
-        * their default values: displayName, name, role, descriptorType.
+        * If the descriptor does not contain the field "displayName" this field
+        * is added in the descriptor with its default value.
         *
         * @exception RuntimeOperationsException Wraps an
         * IllegalArgumentException. The descriptor is invalid, or
-        * descriptor field "name" is present but not equal to name
-        * parameter, or descriptor field "descriptorType" is present
-        * but not equal to "operation" or descriptor field "role" is
+        * descriptor field "name" is not equal to name
+        * parameter, or descriptor field "descriptorType" is
+        * not equal to "operation" or descriptor field "role" is
         * present but not equal to "constructor".
         */
 
@@ -300,6 +297,7 @@
         * Creates and returns a new ModelMBeanConstructorInfo which is a duplicate of this ModelMBeanConstructorInfo.
         *
         */
+        @Override
         public Object clone ()
         {
             if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
@@ -320,6 +318,7 @@
          */
 
 
+        @Override
         public Descriptor getDescriptor()
         {
             if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
@@ -368,6 +367,7 @@
         /**
         * Returns a string containing the entire contents of the ModelMBeanConstructorInfo in human readable form.
         */
+        @Override
         public String toString()
         {
             if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
@@ -404,8 +404,9 @@
          * @exception RuntimeOperationsException if Descriptor is invalid
          */
         private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
-           Descriptor clone;
-            if (in == null) {
+            Descriptor clone;
+            boolean defaulted = (in == null);
+            if (defaulted) {
                 clone = new DescriptorSupport();
                 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
             } else {
@@ -413,11 +414,11 @@
             }
 
             //Setting defaults.
-            if (clone.getFieldValue("name")==null) {
+            if (defaulted && clone.getFieldValue("name")==null) {
                 clone.setField("name", this.getName());
                 MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
             }
-            if (clone.getFieldValue("descriptorType")==null) {
+            if (defaulted && clone.getFieldValue("descriptorType")==null) {
                 clone.setField("descriptorType", "operation");
                 MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\"");
             }
@@ -436,12 +437,12 @@
                     "The isValid() method of the Descriptor object itself returned false,"+
                     "one or more required fields are invalid. Descriptor:" + clone.toString());
             }
-            if (! ((String)clone.getFieldValue("name")).equalsIgnoreCase(this.getName())) {
+            if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                     "The Descriptor \"name\" field does not match the object described. " +
                      " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
             }
-            if (! ((String)clone.getFieldValue("descriptorType")).equalsIgnoreCase("operation")) {
+            if (!"operation".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
                      throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                     "The Descriptor \"descriptorType\" field does not match the object described. " +
                      " Expected: \"operation\" ," + " was: " + clone.getFieldValue("descriptorType"));
--- a/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -945,7 +945,8 @@
      */
     private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
         Descriptor clone;
-        if (in == null) {
+        boolean defaulted = (in == null);
+        if (defaulted) {
             clone = new DescriptorSupport();
             MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
         } else {
@@ -953,11 +954,11 @@
         }
 
         //Setting defaults.
-        if (clone.getFieldValue("name")==null) {
+        if (defaulted && clone.getFieldValue("name")==null) {
             clone.setField("name", this.getClassName());
             MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getClassName());
         }
-        if (clone.getFieldValue("descriptorType")==null) {
+        if (defaulted && clone.getFieldValue("descriptorType")==null) {
             clone.setField("descriptorType", MMB);
             MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"" + MMB + "\"");
         }
--- a/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -186,14 +186,14 @@
      * @param descriptor An instance of Descriptor containing the
      *        appropriate metadata for this instance of the
      *        MBeanNotificationInfo. If it is null a default descriptor
-     *        will be created. If the descriptor does not contain all the
-     *        fields "name", "descriptorType", "displayName" and "severity",
+     *        will be created. If the descriptor does not contain the
+     *        fields "displayName" or "severity",
      *        the missing ones are added with their default values.
      *
      * @exception RuntimeOperationsException Wraps an
      *    {@link IllegalArgumentException}. The descriptor is invalid, or
-     *    descriptor field "name" is present but not equal to parameter name, or
-     *    descriptor field "descriptorType" is present but not equal to "notification".
+     *    descriptor field "name" is not equal to parameter name, or
+     *    descriptor field "descriptorType" is not equal to "notification".
      *
      **/
     public ModelMBeanNotificationInfo(String[] notifTypes,
@@ -341,7 +341,8 @@
      */
     private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
         Descriptor clone;
-        if (in == null) {
+        boolean defaulted = (in == null);
+        if (defaulted) {
             clone = new DescriptorSupport();
             MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
         } else {
@@ -349,11 +350,11 @@
         }
 
         //Setting defaults.
-        if (clone.getFieldValue("name")==null) {
+        if (defaulted && clone.getFieldValue("name")==null) {
             clone.setField("name", this.getName());
             MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
         }
-        if (clone.getFieldValue("descriptorType")==null) {
+        if (defaulted && clone.getFieldValue("descriptorType")==null) {
             clone.setField("descriptorType", "notification");
             MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"notification\"");
         }
@@ -372,12 +373,12 @@
                 "The isValid() method of the Descriptor object itself returned false,"+
                 "one or more required fields are invalid. Descriptor:" + clone.toString());
         }
-        if (! ((String)clone.getFieldValue("name")).equalsIgnoreCase(this.getName())) {
+        if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
                 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                 "The Descriptor \"name\" field does not match the object described. " +
                  " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
         }
-        if (! ((String)clone.getFieldValue("descriptorType")).equalsIgnoreCase("notification")) {
+        if (!"notification".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
                  throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                 "The Descriptor \"descriptorType\" field does not match the object described. " +
                  " Expected: \"notification\" ," + " was: " + clone.getFieldValue("descriptorType"));
--- a/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -208,16 +208,16 @@
          * appropriate metadata for this instance of the
          * ModelMBeanOperationInfo.  If it is null a default
          * descriptor will be created. If the descriptor does not
-         * contain all the fields "name", "descriptorType",
-         * "displayName", and "role", the missing ones are added with
+         * contain the fields
+         * "displayName" or "role", the missing ones are added with
          * their default values.
          *
          * @exception RuntimeOperationsException Wraps an
          * IllegalArgumentException. The descriptor is invalid; or
-         * descriptor field "name" is present but not equal to
+         * descriptor field "name" is not equal to
          * operation name; or descriptor field "DescriptorType" is
-         * present but not equal to "operation"; or descriptor
-         * optional field "role" is not equal to "operation",
+         * not equal to "operation"; or descriptor
+         * optional field "role" is present but not equal to "operation",
          * "getter", or "setter".
          *
          */
@@ -281,16 +281,16 @@
         * @param descriptor An instance of Descriptor containing the
         * appropriate metadata for this instance of the
         * MBeanOperationInfo. If it is null then a default descriptor
-        * will be created.  If the descriptor does not contain all the
-        * fields "name", "descriptorType", "displayName", and "role",
+        * will be created.  If the descriptor does not contain
+        * fields "displayName" or "role",
         * the missing ones are added with their default values.
         *
         * @exception RuntimeOperationsException Wraps an
         * IllegalArgumentException. The descriptor is invalid; or
-        * descriptor field "name" is present but not equal to
+        * descriptor field "name" is not equal to
         * operation name; or descriptor field "DescriptorType" is
-        * present but not equal to "operation"; or descriptor optional
-        * field "role" is not equal to "operation", "getter", or
+        * not equal to "operation"; or descriptor optional
+        * field "role" is present but not equal to "operation", "getter", or
         * "setter".
         */
 
@@ -446,7 +446,8 @@
         private Descriptor validDescriptor(final Descriptor in)
         throws RuntimeOperationsException {
             Descriptor clone;
-            if (in == null) {
+            boolean defaulted = (in == null);
+            if (defaulted) {
                 clone = new DescriptorSupport();
                 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
             } else {
@@ -454,11 +455,11 @@
             }
 
             //Setting defaults.
-            if (clone.getFieldValue("name")==null) {
+            if (defaulted && clone.getFieldValue("name")==null) {
                 clone.setField("name", this.getName());
                 MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
             }
-            if (clone.getFieldValue("descriptorType")==null) {
+            if (defaulted && clone.getFieldValue("descriptorType")==null) {
                 clone.setField("descriptorType", "operation");
                 MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\"");
             }
@@ -477,15 +478,15 @@
                     "The isValid() method of the Descriptor object itself returned false,"+
                     "one or more required fields are invalid. Descriptor:" + clone.toString());
             }
-            if (! ((String)clone.getFieldValue("name")).equalsIgnoreCase(this.getName())) {
+            if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                     "The Descriptor \"name\" field does not match the object described. " +
                      " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
             }
-            if (! ((String)clone.getFieldValue("descriptorType")).equalsIgnoreCase("operation")) {
+            if (!"operation".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
                      throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
                     "The Descriptor \"descriptorType\" field does not match the object described. " +
-                     " Expected: \"attribute\" ," + " was: " + clone.getFieldValue("descriptorType"));
+                     " Expected: \"operation\" ," + " was: " + clone.getFieldValue("descriptorType"));
             }
             final String role = (String)clone.getFieldValue("role");
             if (!(role.equalsIgnoreCase("operation") ||
--- a/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Wed Nov 25 11:08:25 2009 -0800
@@ -23,7 +23,7 @@
  * have any questions.
  */
 /*
- * @(#)author    IBM Corp.
+ * @author    IBM Corp.
  *
  * Copyright IBM Corp. 1999-2000.  All rights reserved.
  */
@@ -55,7 +55,6 @@
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
 import javax.management.Descriptor;
-import javax.management.DynamicWrapperMBean;
 import javax.management.InstanceNotFoundException;
 import javax.management.InvalidAttributeValueException;
 import javax.management.ListenerNotFoundException;
@@ -116,7 +115,7 @@
  */
 
 public class RequiredModelMBean
-    implements ModelMBean, MBeanRegistration, NotificationEmitter, DynamicWrapperMBean {
+    implements ModelMBean, MBeanRegistration, NotificationEmitter {
 
     /*************************************/
     /* attributes                        */
@@ -134,8 +133,6 @@
      * and operations will be executed */
     private Object managedResource = null;
 
-    /* true if getWrappedObject returns the wrapped resource */
-    private boolean visible;
 
     /* records the registering in MBeanServer */
     private boolean registered = false;
@@ -322,13 +319,9 @@
      *
      * @param mr Object that is the managed resource
      * @param mr_type The type of reference for the managed resource.
-     *     <br>Can be: "ObjectReference", "VisibleObjectReference",
-     *         "Handle", "IOR", "EJBHandle", or "RMIReference".
-     *     <br>In this implementation only "ObjectReference" and
-     *         "VisibleObjectReference" are supported.  The two
-     *         types are equivalent except for the behavior of the
-     *         {@link #getWrappedObject()} and {@link #getWrappedClassLoader()}
-     *         methods.
+     *     <br>Can be: "ObjectReference", "Handle", "IOR", "EJBHandle",
+     *         or "RMIReference".
+     *     <br>In this implementation only "ObjectReference" is supported.
      *
      * @exception MBeanException The initializer of the object has
      *            thrown an exception.
@@ -348,11 +341,10 @@
                 "setManagedResource(Object,String)","Entry");
         }
 
-        visible = "visibleObjectReference".equalsIgnoreCase(mr_type);
-
         // check that the mr_type is supported by this JMXAgent
         // only "objectReference" is supported
-        if (!"objectReference".equalsIgnoreCase(mr_type) && !visible) {
+        if ((mr_type == null) ||
+            (! mr_type.equalsIgnoreCase("objectReference"))) {
             if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
                 MODELMBEAN_LOGGER.logp(Level.FINER,
                         RequiredModelMBean.class.getName(),
@@ -378,51 +370,6 @@
     }
 
     /**
-     * <p>Get the managed resource for this Model MBean. For compatibility
-     * reasons, the managed resource is only returned if the resource type
-     * specified to {@link #setManagedResource setManagedResource} was {@code
-     * "visibleObjectReference"}. Otherwise, {@code this} is returned.</p>
-     *
-     * @return The value that was specified to {@link #setManagedResource
-     * setManagedResource}, if the resource type is {@code
-     * "visibleObjectReference"}. Otherwise, {@code this}.
-     */
-    public Object getWrappedObject() {
-        if (visible)
-            return managedResource;
-        else
-            return this;
-    }
-
-    /**
-     * <p>Get the ClassLoader of the managed resource for this Model MBean. For
-     * compatibility reasons, the ClassLoader of the managed resource is only
-     * returned if the resource type specified to {@link #setManagedResource
-     * setManagedResource} was {@code "visibleObjectReference"}. Otherwise,
-     * {@code this.getClass().getClassLoader()} is returned.</p>
-     *
-     * @return The ClassLoader of the value that was specified to
-     * {@link #setManagedResource setManagedResource}, if the resource
-     * type is {@code "visibleObjectReference"}. Otherwise, {@code
-     * this.getClass().getClassLoader()}.
-     */
-    public ClassLoader getWrappedClassLoader() {
-        return getWrappedObject().getClass().getClassLoader();
-    }
-
-    private static boolean isTrue(Descriptor d, String field) {
-        if (d == null)
-            return false;
-        Object x = d.getFieldValue(field);
-        if (x instanceof Boolean)
-            return (Boolean) x;
-        if (!(x instanceof String))
-            return false;
-        String s = (String) x;
-        return ("true".equalsIgnoreCase(s) || "T".equalsIgnoreCase(s));
-    }
-
-    /**
      * <p>Instantiates this MBean instance with the data found for
      * the MBean in the persistent store.  The data loaded could include
      * attribute and operation values.</p>
--- a/src/share/classes/javax/management/monitor/MonitorNotification.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/monitor/MonitorNotification.java	Wed Nov 25 11:08:25 2009 -0800
@@ -201,7 +201,7 @@
      * @param derGauge The derived gauge.
      * @param trigger The threshold/string (depending on the monitor type) that triggered the notification.
      */
-    public MonitorNotification(String type, Object source, long sequenceNumber, long timeStamp, String msg,
+    MonitorNotification(String type, Object source, long sequenceNumber, long timeStamp, String msg,
                                ObjectName obsObj, String obsAtt, Object derGauge, Object trigger) {
 
         super(type, source, sequenceNumber, timeStamp, msg);
--- a/src/share/classes/javax/management/namespace/JMXDomain.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,378 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import java.io.IOException;
-import javax.management.ListenerNotFoundException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import static javax.management.namespace.JMXNamespaces.NAMESPACE_SEPARATOR;
-
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-import javax.management.ObjectName;
-
-/**
- * A special {@link JMXNamespace} that can handle part of
- * the MBeanServer local name space.
- * <p>
- * A {@code JMXDomain} makes a domain <i>X</i> of a
- * {@linkplain #getSourceServer() source MBean server} appear in the same domain
- * <i>X</i> of a containing {@code MBeanServer} in which the
- * {@code JMXDomain} MBean {@linkplain #getMBeanServer() is registered}.
- * </p>
- * <p>
- * The JMX infrastructure of the containing {@code MBeanServer} takes care of
- * routing all calls to MBeans whose names have domain <i>X</i> to the
- * {@linkplain #getSourceServer() source MBean server} exported by the
- * {@code JMXDomain} MBean in charge of domain <i>X</i>.
- * </p>
- * <p>
- * The {@linkplain #getSourceServer() source MBean server} of a {@code JMXDomain}
- * can, but need not be a regular {@code MBeanServer} created through
- * the {@link javax.management.MBeanServerFactory}. It could also be,
- * for instance, an instance of a subclass of {@link MBeanServerSupport},
- * or a custom object implementing the {@link MBeanServer} interface.
- * </p>
- *
- * <h4>Differences between {@code JMXNamespace} and {@code JMXDomain}</h4>
- *
- * <p>
- * A {@code JMXDomain} is a special kind of {@code JMXNamespace}.
- * A {@code JMXNamespace} such as {@code foo//} is triggered by an
- * {@code ObjectName} that begins with the string {@code foo//}, for example
- * {@code foo//bar:type=Baz}.  A {@code JMXDomain} such as {@code foo} is
- * triggered by an {@code ObjectName} with that exact domain, for example
- * {@code foo:type=Baz}.  A client can immediately see that an MBean is
- * handled by a {@code JMXNamespace} because of the {@code //} in the name.
- * A client cannot see whether a name such as {@code foo:type=Baz} is an
- * ordinary MBean or is handled by a {@code JMXDomain}.
- * </p>
- *
- * <p>
- * A {@linkplain MBeanServer#queryNames query} on the containing {@code
- * MBeanserver} will return all MBeans from the {@code JMXDomain} that match
- * the query.  In particular, {@code queryNames(null, null)} will return all
- * MBeans including those from {@code JMXDomain} domains.  On the other hand,
- * a query will not include MBeans from a {@code JMXNamespace} unless the
- * {@code ObjectName} pattern in the query starts with the name of that
- * namespace.
- * </p>
- *
- * <h4 id="security">Permission checks</h4>
- *
- * <p>
- * When a JMXDomain MBean is registered in a containing
- * MBean server created through the default {@link
- * javax.management.MBeanServerBuilder}, and if a {@link
- * SecurityManager SecurityManager} is
- * {@linkplain System#getSecurityManager() present}, the containing MBeanServer will
- * check an {@link javax.management.MBeanPermission} before invoking
- * any method on the {@linkplain #getSourceServer() source MBeanServer} of the
- * JMXDomain.
- * </p>
- *
- * <p>First, if there is no security manager ({@link
- * System#getSecurityManager()} is null), that containing
- * {@code MBeanServer} is free not to make any checks.
- * </p>
- *
- * <p>
- * Assuming that there is a security manager, or that the
- * implementation chooses to make checks anyway, the containing
- * {@code MBeanServer} will perform
- * {@link javax.management.MBeanPermission MBeanPermission} checks
- * for access to the MBeans in domain <i>X</i> handled by a {@code JMXDomain}
- * in the same way that it would do for MBeans registered in its own local
- * repository, and as <a href="../MBeanServer.html#security">described in
- * the MBeanServer interface</a>, with the following exceptions:
- * </p>
- *
- * <p>
- * For those permissions that require a {@code className}, the
- * <code>className</code> is the
- * string returned by {@link #getSourceServer() getSourceServer()}.
- * {@link MBeanServer#getObjectInstance(ObjectName)
- * getObjectInstance(mbeanName)}.
- * {@link javax.management.ObjectInstance#getClassName() getClassName()},
- * except for {@code createMBean} and {@code registerMBean} operations,
- * for which the permission checks are performed as follows:
- * </p>
- * <ul>
- * <li><p>For {@code createMBean} operations, the {@code className} of the
- * permission you need is the {@code className} passed as first parameter
- * to {@code createMBean}.</p>
- *
- * <li><p>For {@code registerMBean} operations, the {@code className} of the
- * permission you need is the name of the class of the mbean object, as
- * returned by {@code mbean.getClass().getClassName()}, where
- * {@code mbean} is the mbean reference passed as first parameter
- * to {@code registerMBean}.</p>
- *
- * <li><p>In addition, for {@code createMBean} and {@code registerMBean}, the
- * permission you need is checked with the {@linkplain ObjectName object name} of
- * the mbean that is passed as second parameter to the {@code createMBean} or
- * {@code registerMBean} operation.
- * </p>
- *
- * <li><p>Contrarily to what is done for regular MBeans registered in the
- *     MBeanServer local repository, the containing MBeanServer will not
- *     check the {@link javax.management.MBeanTrustPermission#MBeanTrustPermission(String)
- *     MBeanTrustPermission("register")} against the protection domain
- *     of the MBean's class. This check can be performed by the
- *     {@linkplain #getSourceServer source MBean server} implementation,
- *     if necessary.
- * </p>
- * </ul>
- *
- * <p>If a security check fails, the method throws {@link
- * SecurityException}.</p>
- *
- * <p>For methods that can throw {@link InstanceNotFoundException},
- * this exception is thrown for a non-existent MBean, regardless of
- * permissions.  This is because a non-existent MBean has no
- * <code>className</code>.</p>
- *
- * All these checks are performed by the containing {@code MBeanServer},
- * before accessing the JMXDomain {@linkplain #getSourceServer source MBean server}.
- * The implementation of the JMXDomain {@linkplain #getSourceServer source MBean
- * server} is free to make any additional checks. In fact, if the JMXDomain
- * {@linkplain #getSourceServer source MBean server} is an {@code MBeanServer}
- * obtained through the {@link javax.management.MBeanServerFactory}, it will
- * again make permission checks as described in the
- * <a href="../MBeanServer.html#security">MBeanServer</a> interface.
- *
- * <p>See the <a href="../MBeanServer.html#security">MBeanServer</a> interface
- * for more details on permission checks.</p>
- *
- * @since 1.7
- */
-public class JMXDomain extends JMXNamespace {
-
-
-    /**
-     * This constant contains the value of the {@code type}
-     * key used in defining a standard JMXDomain MBean object name.
-     * By definition, a standard JMXDomain MBean object name must be of
-     * the form:
-     * <pre>
-     * {@code "<domain>:"}+{@value javax.management.namespace.JMXDomain#TYPE_ASSIGNMENT}
-     * </pre>
-     */
-    public static final String TYPE = "JMXDomain";
-
-    /**
-     * This constant contains the value of the standard
-     * {@linkplain javax.management.ObjectName#getKeyPropertyListString() key
-     * property list string} for JMXDomain MBean object names.
-     * By definition, a standard JMXDomain MBean object name must be of
-     * the form:
-     * <pre>
-     * {@code <domain>}+":"+{@value javax.management.namespace.JMXDomain#TYPE_ASSIGNMENT}
-     * </pre>
-     */
-    public static final String TYPE_ASSIGNMENT = "type="+TYPE;
-
-
-
-    /**
-     * Creates a new instance of JMXDomain. The MBeans contained in this
-     * domain are handled by the {@code virtualServer} object given to
-     * this constructor. Frequently, this will be an instance of
-     * {@link MBeanServerSupport}.
-     * @param virtualServer The virtual server that acts as a container for
-     *        the MBeans handled by this JMXDomain object. Frequently, this will
-     *        be an instance of {@link MBeanServerSupport}
-     * @see JMXNamespace#JMXNamespace(MBeanServer)
-     */
-    public JMXDomain(MBeanServer virtualServer) {
-        super(virtualServer);
-    }
-
-    /**
-     * Return the name of domain handled by this JMXDomain.
-     * @return the domain handled by this JMXDomain.
-     * @throws IOException - if the domain cannot be determined,
-     *         for instance, if the MBean is not registered yet.
-     */
-    @Override
-    public final String getDefaultDomain() {
-        final ObjectName name = getObjectName();
-        if (name == null)
-            throw new IllegalStateException("DefaultDomain is not yet known");
-        final String dom = name.getDomain();
-        return dom;
-    }
-
-    /**
-     * Returns a singleton array, containing the only domain handled by
-     * this JMXDomain object. This is
-     * {@code new String[] {getDefaultDomain()}}.
-     * @return the only domain handled by this JMXDomain.
-     * @throws IOException if the domain cannot be determined,
-     *         for instance, if the MBean is not registered yet.
-     * @see #getDefaultDomain()
-     */
-    @Override
-    public final String[] getDomains() {
-        return new String[] {getDefaultDomain()};
-    }
-
-    /**
-     * This method returns the number of MBeans in the domain handled
-     * by this JMXDomain object. The default implementation is:
-     * <pre>
-     *    getSourceServer().queryNames(
-     *        new ObjectName(getObjectName().getDomain()+":*"), null).size();
-     * </pre>
-     * If this JMXDomain is not yet registered, this method returns 0.
-     * Subclasses can override the above behavior and provide a better
-     * implementation.
-     * <p>
-     * The getMBeanCount() method is called when computing the number
-     * of MBeans in the {@linkplain #getMBeanServer() containing MBeanServer}.
-     * @return the number of MBeans in this domain, or 0.
-     */
-    @Override
-    public Integer getMBeanCount()  {
-        final ObjectName name = getObjectName();
-        if (name == null) return 0;
-        try {
-            return getSourceServer().
-               queryNames(ObjectName.WILDCARD.withDomain(name.getDomain()),
-               null).size();
-        } catch (RuntimeException x) {
-            throw x;
-        } catch (Exception x) {
-            throw new RuntimeException("Unexpected exception: "+x,x);
-        }
-    }
-
-
-
-    /**
-     * Return a canonical handler name for the provided local
-     * <var>domain</var> name, or null if the provided domain name is
-     * {@code null}.
-     * If not null, the handler name returned will be
-     * {@code domain+":type="+}{@link #TYPE TYPE}, for example
-     * {@code foo:type=JMXDomain}.
-     * @param domain A domain name
-     * @return a canonical ObjectName for a domain handler.
-     * @throws IllegalArgumentException if the provided
-     *         <var>domain</var> is not valid - e.g it contains "//".
-     */
-    public static ObjectName getDomainObjectName(String domain) {
-        if (domain == null) return null;
-        if (domain.contains(NAMESPACE_SEPARATOR))
-            throw new IllegalArgumentException("domain contains " +
-                    NAMESPACE_SEPARATOR+": "+domain);
-        return ObjectName.valueOf(domain, "type", TYPE);
-    }
-
-
-    /**
-     * Validate the ObjectName supplied to preRegister.
-     * This method is introduced to allow standard subclasses to use
-     * an alternate naming scheme. For instance - if we want to
-     * reuse JMXNamespace in order to implement sessions...
-     * It is however only available for subclasses in this package.
-     **/
-    @Override
-    ObjectName validateHandlerName(ObjectName suppliedName) {
-        if (suppliedName == null)
-            throw new IllegalArgumentException("Must supply a valid name");
-        final String dirName = JMXNamespaces.
-                normalizeNamespaceName(suppliedName.getDomain());
-        final ObjectName handlerName = getDomainObjectName(dirName);
-        if (!suppliedName.equals(handlerName))
-            throw new IllegalArgumentException("invalid name space name: "+
-                        suppliedName);
-
-        return suppliedName;
-    }
-
-    /**
-     * This method is called by the JMX framework to register a
-     * NotificationListener that will forward {@linkplain
-     * javax.management.MBeanServerNotification mbean server notifications}
-     * through the delegate of the {@linkplain #getMBeanServer()
-     * containing MBeanServer}.
-     * The default implementation of this method is to call
-     * <pre>
-     *    getSourceServer().addNotificationListener(
-     *           MBeanServerDelegate.DELEGATE_NAME, listener, filter, null);
-     * </pre>
-     * Subclasses can redefine this behavior if needed. In particular,
-     * subclasses can send their own instances of {@link
-     * javax.management.MBeanServerNotification} by calling
-     * {@code listener.handleNotification()}.
-     *
-     * @param listener The MBeanServerNotification listener for this domain.
-     * @param filter   A notification filter.
-     */
-    public void addMBeanServerNotificationListener(
-            NotificationListener listener, NotificationFilter filter) {
-        try {
-            getSourceServer().addNotificationListener(
-                MBeanServerDelegate.DELEGATE_NAME, listener, filter, null);
-        } catch(InstanceNotFoundException x) {
-            throw new UnsupportedOperationException(
-                    "Unexpected exception: " +
-                    "Emission of MBeanServerNotification disabled.", x);
-        }
-    }
-
-    /**
-     * This method is called by the JMX framework to remove the
-     * NotificationListener that was added with {@link
-     * #addMBeanServerNotificationListener addMBeanServerNotificationListener}.
-     * The default implementation of this method is to call
-     * <pre>
-     *    getSourceServer().removeNotificationListener(
-     *           MBeanServerDelegate.DELEGATE_NAME, listener);
-     * </pre>
-     * Subclasses can redefine this behavior if needed.
-     *
-     * @param listener The MBeanServerNotification listener for this domain.
-     * @throws ListenerNotFoundException if the listener is not found.
-     */
-    public void removeMBeanServerNotificationListener(
-            NotificationListener listener)
-            throws ListenerNotFoundException {
-        try {
-            getSourceServer().removeNotificationListener(
-                MBeanServerDelegate.DELEGATE_NAME, listener);
-        } catch(InstanceNotFoundException x) {
-            throw new UnsupportedOperationException(
-                    "Unexpected exception: " +
-                    "Emission of MBeanServerNotification disabled.", x);
-        }
-    }
-
-}
--- a/src/share/classes/javax/management/namespace/JMXNamespace.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,666 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-
-import java.io.IOException;
-
-import java.util.UUID;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-/**
- * MBean Servers can be federated into a single hierarchical name space:
- * A JMXNamespace is an MBean that handles a sub name space in that
- * hierarchical name space.
- * <p>
- * A name space is created simply by registering a {@code JMXNamespace}
- * MBean in the MBean Server. The name of the created name space is defined
- * by the {@linkplain JMXNamespaces#getNamespaceObjectName name of the JMXNamespace}
- * that handles it. A name space is equivalent to
- * an MBean Server within an MBean Server. When creating a {@code JMXNamespace},
- * the MBean Server within is passed to the constructor.
- * </p>
- * <p>
- * The {@code JMXNamespace} class is the base class for implementing
- * all name space handlers. All name space handlers must be instances of
- * {@code JMXNamespace} or a subclass of it.
- * </p>
- * <p>
- * A concrete example of a {@code JMXNamespace} MBean subclass
- * is the {@link JMXRemoteNamespace JMXRemoteNamespace} MBean which
- * is able to mirror all MBeans contained in a remote MBean server known by its
- * {@link javax.management.remote.JMXServiceURL}.
- * </p>
- * <p>
- * You can create a local namespace by supplying a newly created MBean Server
- * to an instance of {@code JMXNamespace}. For instance:
- * <pre>
- * final String namespace = "foo";
- * final ObjectName namespaceName = {@link JMXNamespaces#getNamespaceObjectName
- *       JMXNamespaces.getNamespaceObjectName(namespace)};
- * server.registerMBean(new JMXNamespace(MBeanServerFactory.newMBeanServer()),
- *                      namespaceName);
- * </pre>
- * </p>
- * <p>
- * <u>Note:</u> A JMXNamespace MBean cannot be registered
- * simultaneously in two different
- * MBean servers, or indeed in the same MBean Server with two
- * different names. It is however possible to give the same MBeanServer
- * instance to two different JMXNamespace MBeans, and thus create a graph
- * rather than a tree.
- * </p>
- *
- * <p>To view the content of a namespace, you will usually use an
- *    instance of {@link JMXNamespaceView}. For instance, given the
- *    namespace {@code "foo"} created above, you would do:
- * </p>
- * <pre>
- * final JMXNamespaceView view = new JMXNamespaceView(server);
- * System.out.println("List of namespaces: "+Arrays.toString({@link JMXNamespaceView#list() view.list()}));
- *
- * final JMXNamespaceView foo  = {@link JMXNamespaceView#down view.down("foo")};
- * System.out.println({@link JMXNamespaceView#where() foo.where()}+" contains: " +
- *        {@link JMXNamespaceView#getMBeanServerConnection foo.getMBeanServerConnection()}.queryNames(null,null));
- * </pre>
- *
- * <h2 id="PermissionChecks">JMX Namespace Permission Checks</h2>
- *
- * <p>A special {@link JMXNamespacePermission} is defined to check access
- * to MBean within namespaces.</p>
- * <p>When a JMXNamespace MBean is registered in an
- * MBean server created through the default {@link
- * javax.management.MBeanServerBuilder}, and if a {@link
- * SecurityManager SecurityManager} is
- * {@linkplain System#getSecurityManager() present}, the MBeanServer will
- * check a {@link JMXNamespacePermission} before invoking
- * any method on the {@linkplain #getSourceServer source MBeanServer} of the
- * JMXNamespace.
- * {@linkplain JMXNamespacePermission JMX Namespace Permissions} are similar to
- * {@linkplain javax.management.MBeanPermission MBean Permissions}, except
- * that you usually cannot specify an MBean class name. You can however
- * specify object name patterns - which will allow you for example to only grant
- * permissions for MBeans having a specific {@code type=<MBeanType>} key
- * in their object name.
- * <p>
- * Another difference is that {@link JMXNamespacePermission
- * JMXNamespacePermission} also specifies from which namespace and which
- * MBean server the permission is granted.
- * </p>
- * <p>In the rest of this document, the following terms are used:</p>
- * <ul>
- *    <li id="MBeanServerName"><p>{@code server name} is the
- *    <a href="../MBeanServerFactory.html#MBeanServerName">name of the
- *    MBeanServer</a> in which the permission is granted.
- *    The name of an {@code MBeanServer} can be obtained by calling {@link
- *    javax.management.MBeanServerFactory#getMBeanServerName
- *    MBeanServerFactory.getMBeanServerName(mbeanServer)}
- *    </p>
- *    <li id="NamespaceName"><p>{@code namespace} is the name of the namespace
- *    in the <a href="#MBeanServerName">named MBean server</a> for which the
- *    permission is granted. It doesn't contain any
- *    {@link JMXNamespaces#NAMESPACE_SEPARATOR namespace separator}.
- *    </p>
- *    <li id="MBeanName"><p>{@code mbean} is the name
- *    of the MBean in that {@code namespace}. This is the name of the MBean
- *    in the namespace's {@link JMXNamespace#getSourceServer() source mbean server}.
- *    It might contain no, one, or several {@link
- *    JMXNamespaces#NAMESPACE_SEPARATOR namespace separators}.
- *    </p>
- * </ul>
- *
- * <p>For instance let's assume that some piece of code calls:</p>
- * <pre>
- *     final MBeanServer mbeanServer = ...;
- *     final ObjectName  name   = new ObjectName("a//b//c//D:k=v");
- *     mbeanServer.getAttribute(name,"Foo");
- * </pre>
- * <p>
- *   Assuming that there is a security manager, or that the
- *   implementation chooses to make checks anyway, the checks that will
- *   be made in that case are:
- * </p>
- * <ol>
- * <li id="check1">
- * <code>JMXNamespacePermission(mbeanServerName, "Foo", "<b>a//</b>b//c//D:k=v",
- * "getAttribute")</code>
- * (where {@code mbeanServerName=MBeanServerFactory.getMBeanServerName(mbeanServer)},
- * <code>namespace="<b>a</b>"</code>, and {@code mbean="b//c//D:k=v"})
- * </li>
- * <li id="check2">and in addition if namespace {@code "a"} is local,
- * <code>JMXNamespacePermission(aSourceServerName,"Foo","<b>b//</b>c//D:k=v",
- *       "getAttribute")}</code>
- * (where
- * {@code aSourceServerName=MBeanServerFactory.getMBeanServerName(sourceServer(a))},
- * <code>namespace="<b>b</b>"</code>, and {@code mbean="c//D:k=v"}),
- * </li>
- * <li id="check3">and in addition if namespace {@code "b"} is also local,
- * <code>JMXNamespacePermission(bSourceServerName,"Foo","<b>c//</b>D:k=v",
- *       "getAttribute")}</code>
- * (where
- * {@code bSourceServerName=MBeanServerFactory.getMBeanServerName(sourceServer(b))},
- * <code>namespace="<b>c</b>"</code>, and {@code mbean="D:k=v"}),
- * </li>
- * <li id="check4">and in addition if the source mbean server of namespace
- * {@code "c"} is a also a local MBeanServer in this JVM,
- * {@code MBeanPermission(cSourceServerName,<className(D:k=v)>,"Foo","D:k=v","getAttrinute")},
- * (where
- * {@code cSourceServerName=MBeanServerFactory.getMBeanServerName(sourceServer(c))}).
- * </li>
- * </ol>
- * <p>For any of these MBean servers, if no name was supplied when
- * creating that MBeanServer the {@link JMXNamespacePermission} is
- * created with an {@code mbeanServerName} equal to
- * {@value javax.management.MBeanServerFactory#DEFAULT_MBEANSERVER_NAME}.
- * </p>
- * <p>If the namespace {@code a} is in fact a remote {@code MBeanServer},
- *    for instance because namespace {@code a} is implemented by a {@link
- *    JMXRemoteNamespace} pointing to a distant MBeanServer located in
- *    another JMX agent, then checks <a href="#check2">2</a>,
- *    <a href="#check3">3</a>, and <a href="#check4">4</a> will not
- *    be performed in the local JVM. They might or might not be performed in
- *    the remote agent, depending on how access control and permission
- *    checking are configured in the remote agent, and how authentication
- *    is configured in the connector used by the {@link
- *    JMXRemoteNamespace}.
- * </p>
- * <p>In all cases, {@linkplain JMXNamespacePermission JMX Namespace Permissions}
- * are checked as follows:</p>
- * <p>First, if there is no security manager ({@link
- * System#getSecurityManager()} is null), then an implementation of
- * of MBeanServer that supports JMX namespaces is free not to make any
- * checks.</p>
- *
- * <p>Assuming that there is a security manager, or that the
- * implementation chooses to make checks anyway, the checks are made
- * as detailed below.</p>
- *
- * <p>If a security check fails, the method throws {@link
- * SecurityException}.</p>
- *
- * <ul>
- *
- * <li><p>For the {@link MBeanServer#invoke invoke} method, the caller's
- * permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, &lt;operation name&gt;, &lt;namespace&gt;//&lt;mbean&gt;, "invoke")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#getAttribute getAttribute} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, &lt;attribute&gt;, &lt;namespace&gt;//&lt;mbean&gt;, "getAttribute")}.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#getAttributes getAttributes} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, &lt;null&gt;, &lt;namespace&gt;//&lt;mbean&gt;, "getAttribute")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * Additionally, for each attribute <em>att</em> in the {@link
- * javax.management.AttributeList}, if the caller's permissions do not
- * imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, <em>att</em>,
- * &lt;namespace&gt;//&lt;mbean&gt;, "getAttribute")}, the
- * MBean server will behave as if that attribute had not been in the
- * supplied list.</p>
- *
- * <li><p>For the {@link MBeanServer#setAttribute setAttribute} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, &lt;attrName&gt;, &lt;namespace&gt;//&lt;mbean&gt;, "setAttribute")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace, and
- * <code>attrName</code> is {@link javax.management.Attribute#getName()
- * attribute.getName()}.</p>
- *
- * <li><p>For the {@link MBeanServer#setAttributes setAttributes} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;, "setAttribute")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * Additionally, for each attribute <em>att</em> in the {@link
- * javax.management.AttributeList}, if the caller's permissions do not
- * imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, <em>att</em>, &lt;namespace&gt;//&lt;mbean&gt;, "setAttribute")},
- * the MBean server will behave as if that attribute had not been in the
- * supplied list.</p>
- *
- * <li><p>For the <code>addNotificationListener</code> methods,
- * the caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "addNotificationListener")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * </p>
- *
- * <li><p>For the <code>removeNotificationListener</code> methods,
- * the caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "removeNotificationListener")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#getMBeanInfo getMBeanInfo} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "getMBeanInfo")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#getObjectInstance getObjectInstance} method,
- * the caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "getObjectInstance")},
- * where <a href="#MBeanServerName">mbean server name/a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#isInstanceOf isInstanceOf} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "isInstanceOf")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#queryMBeans queryMBeans} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, null,
- * "queryMBeans")}.
- * Additionally, for each MBean {@code mbean} that matches {@code pattern},
- * if the caller's permissions do not imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "queryMBeans")}, the
- * MBean server will behave as if that MBean did not exist.</p>
- *
- * <p>Certain query elements perform operations on the MBean server.
- * However these operations are usually performed by the MBeanServer at the
- * bottom of the namespace path, and therefore, do not involve any
- * {@link JMXNamespacePermission} permission check. They might involve
- * {@link javax.management.MBeanPermission} checks depending on how security
- * in the JVM in which the bottom MBeanServer resides is implemented.
- * See {@link javax.management.MBeanServer} for more details.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#queryNames queryNames} method, the checks
- * are the same as for <code>queryMBeans</code> except that
- * <code>"queryNames"</code> is used instead of
- * <code>"queryMBeans"</code> in the <code>JMXNamespacePermission</code>
- * objects.  Note that a <code>"queryMBeans"</code> permission implies
- * the corresponding <code>"queryNames"</code> permission.</p>
- *
- * <li><p>For the {@link MBeanServer#getClassLoader getClassLoader} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;loaderName&gt;,
- * "getClassLoader")},
- * where <a href="#MBeanServerName">mbean server name/a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">loaderName</a> is the name of the ClassLoader MBean
- * which is accessed, in that namespace.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#getClassLoaderFor getClassLoaderFor} method,
- * the caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "getClassLoaderFor")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which the action
- * is performed, in that namespace.
- * </p>
- *
- * <li><p>For the {@link MBeanServer#registerMBean registerMBean} method, the
- * caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, &lt;class name&gt;, &lt;namespace&gt;//&lt;mbean&gt;,
- * "registerMBean")}.  Here
- * <code>class name</code> is the string returned by {@code
- * obj.getClass().getName()} where {@code obj} is the mbean reference,
- * <a href="#MBeanServerName"mbean server name/a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean which is being
- * registered, relative to that namespace.
- *
- * <li><p>For the <code>createMBean</code> methods, the caller's
- * permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, &lt;class name&gt;, &lt;namespace&gt;//&lt;mbean&gt;,
- * "instantiate")} and
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, &lt;class name&gt;, &lt;namespace&gt;//&lt;mbean&gt;,
- * "registerMBean")}, where
- * <code>class name</code> is the string passed as first argument to the {@code
- * createMBean} method,
- * <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean which is being
- * created, relative to that namespace.
- *
- * <li><p>For the {@link MBeanServer#unregisterMBean unregisterMBean} method,
- * the caller's permissions must imply {@link
- * JMXNamespacePermission#JMXNamespacePermission(String,String,ObjectName,String)
- * JMXNamespacePermission(&lt;mbean server name&gt;, null, &lt;namespace&gt;//&lt;mbean&gt;,
- * "unregisterMBean")},
- * where <a href="#MBeanServerName">mbean server name</a> is the name of the
- * {@code MBeanServer} in which the {@code JMXNamespace} MBean in charge of
- * <a href="#NamespaceName">namespace</a> is registered, and
- * <a href="#MBeanName">mbean</a> is the name of the MBean on which is
- * being unregistered, relative to that namespace.
- * </p>
- * </ul>
- * </p>
- * <p>It must be noted that if all namespaces are local, and all
- *    local namespaces are implemented by regular MBean servers, that is, there
- *    are no {@linkplain MBeanServerSupport Virtual Namespaces}, then
- *    simple {@linkplain javax.management.MBeanPermission MBean Permission}
- *    checks might be enough to secure an application.
- *    In that case, it is possible to specify the following {@link
- *    JMXNamespacePermission} permission in the policy file, which implies all
- *    other JMX namespace permissions:
- * </p>
- * <pre>
- *     permission javax.management.namespace.JMXNamespacePermission "*::*[]", "*";
- * </pre>
- *
- * @since 1.7
- */
-public class JMXNamespace
-        implements JMXNamespaceMBean, MBeanRegistration {
-
-    /**
-     * The standard value of the {@code type}
-     * property key that must be used to construct valid {@link
-     * JMXNamespaceMBean} ObjectNames.<br>
-     * This is {@value #TYPE}.
-     **/
-    public static final String TYPE = "JMXNamespace";
-
-    /**
-     * The {@link ObjectName#getKeyPropertyListString keyPropertyListString}
-     * that must be used to construct valid {@link JMXNamespaceMBean}
-     * ObjectNames.<br>
-     * This is
-     * <code>{@value #TYPE_ASSIGNMENT}</code>.
-     **/
-    public static final String TYPE_ASSIGNMENT = "type="+TYPE;
-
-    private volatile MBeanServer mbeanServer; // the mbean server in which
-                                              // this MBean is registered.
-    private volatile ObjectName objectName;   // the ObjectName of this MBean.
-    private final MBeanServer sourceServer;   // the MBeanServer within = the
-                                              // name space (or the MBean server
-                                              // that contains it).
-    private final String uuid;
-
-    /**
-     * Creates a new JMXNamespace implemented by means of an MBean Server.
-     * A namespace is equivalent to an MBeanServer within an MBean Server.
-     * The {@code sourceServer} provided to this constructor is the MBean Server
-     * within.
-     * @param sourceServer the MBean server that implemented by this namespace.
-     * @see #getSourceServer
-    */
-    public JMXNamespace(MBeanServer sourceServer) {
-        this.sourceServer = sourceServer;
-        this.uuid = UUID.randomUUID().toString();
-    }
-
-    /**
-     * This method is part of the {@link MBeanRegistration} interface.
-     * The {@link JMXNamespace} class uses the {@link MBeanRegistration}
-     * interface in order to get a reference to the MBean server in which it is
-     * registered. It also checks the validity of its own ObjectName.
-     * <p>
-     * This method is called by the MBean server.
-     * Application classes should never call this method directly.
-     * <p>
-     * If this method is overridden, the overriding method should call
-     * {@code super.preRegister(server,name)}.
-     * @see MBeanRegistration#preRegister MBeanRegistration
-     * @see JMXNamespaces#getNamespaceObjectName getNamespaceObjectName
-     * @param name The object name of the MBean. <var>name</var> must be a
-     *  syntactically valid JMXNamespace name, as returned by
-     *  {@link JMXNamespaces#getNamespaceObjectName(java.lang.String)
-     *   getNamespaceObjectName(namespace)}.
-     * @return The name under which the MBean is to be registered.
-     * @throws IllegalArgumentException if the name supplied is not valid.
-     * @throws Exception can be thrown by subclasses.
-     */
-    public ObjectName preRegister(MBeanServer server, ObjectName name)
-        throws Exception {
-        // need to synchronize to protect against multiple registration.
-        synchronized(this) {
-            if (objectName != null && ! objectName.equals(name))
-                throw new IllegalStateException(
-                    "Already registered under another name: " + objectName);
-            objectName = validateHandlerName(name);
-            mbeanServer = server;
-        }
-        return name;
-    }
-
-    /**
-     * Validate the ObjectName supplied to preRegister.
-     * This method is introduced to allow standard subclasses to use
-     * an alternate naming scheme. For instance - if we want to
-     * reuse JMXNamespace in order to implement sessions...
-     * It is however only available for subclasses in this package.
-     **/
-    ObjectName validateHandlerName(ObjectName suppliedName) {
-        if (suppliedName == null)
-            throw new IllegalArgumentException("Must supply a valid name");
-        final String dirName = JMXNamespaces.
-                normalizeNamespaceName(suppliedName.getDomain());
-        final ObjectName handlerName =
-                JMXNamespaces.getNamespaceObjectName(dirName);
-        if (!suppliedName.equals(handlerName))
-            throw new IllegalArgumentException("invalid name space name: "+
-                        suppliedName);
-        return suppliedName;
-    }
-
-    /**
-     * This method is part of the {@link MBeanRegistration} interface.
-     * The {@link JMXNamespace} class uses the {@link MBeanRegistration}
-     * interface in order to get a reference to the MBean server in which it is
-     * registered.
-     * <p>
-     * This method is called by the MBean server. Application classes should
-     * not call this method directly. Subclasses are free to override this
-     * method with their own specific behavior - but the overriding method
-     * shoud still call {@code super.postRegister(registrationDone)}.
-     * @see MBeanRegistration#postRegister MBeanRegistration
-     */
-    public void postRegister(Boolean registrationDone) {
-        // nothing to do
-    }
-
-    /**
-     * This method is part of the {@link MBeanRegistration} interface.
-     * The {@link JMXNamespace} class uses the {@link MBeanRegistration}
-     * interface in order to get a reference to the MBean server in which it is
-     * registered.
-     * <p>
-     * This method is called by the MBean server. Application classes should
-     * not call this method directly. Subclasses are free to override this
-     * method with their own specific behavior - but the overriding method
-     * shoud still call {@code super.preDeregister()}.
-     * @see MBeanRegistration#preDeregister MBeanRegistration
-     */
-    public void preDeregister() throws Exception {
-        // nothing to do
-    }
-
-    /**
-     * This method is part of the {@link MBeanRegistration} interface.
-     * It allows the {@code JMXNamespace} MBean to perform any operations
-     * needed after having been unregistered in the MBean server.
-     * <p>
-     * This method is called by the MBean server. Application classes should
-     * not call this method directly. If a subclass overrides this
-     * method, the overriding method shoud  call {@code super.postDeregister()}.
-     * @see MBeanRegistration#postDeregister MBeanRegistration
-     */
-    public void postDeregister() {
-        // need to synchronize to protect against multiple registration.
-        synchronized(this) {
-            mbeanServer = null;
-            objectName  = null;
-        }
-    }
-
-
-    /**
-     * Returns the MBeanServer in which this MBean is registered,
-     * or null. Chiefly of interest for subclasses.
-     * @return the MBeanServer supplied to {@link #preRegister}.
-     **/
-    public final MBeanServer getMBeanServer() {
-        return mbeanServer;
-    }
-
-    /**
-     * Returns the MBeanServer that contains or emulates the source
-     * namespace. When a JMXNamespace MBean is registered in an
-     * MBean server created through the default {@link
-     * javax.management.MBeanServerBuilder}, the MBeanServer will
-     * check {@link JMXNamespacePermission} before invoking
-     * any method on the source MBeanServer of the JMXNamespace.
-     * See <a href="#PermissionChecks">JMX Namespace Permission Checks</a>
-     * above.
-     * @return an MBeanServer view of the source namespace
-     **/
-    public MBeanServer getSourceServer() {
-        return sourceServer;
-    }
-
-    /**
-     * Returns the ObjectName with which this MBean was registered,
-     * or null. Chiefly of interest for subclasses.
-     * @return the ObjectName supplied to {@link #preRegister}.
-     **/
-    public final ObjectName getObjectName() {
-        return objectName;
-    }
-
-    /**
-     * HandlerName used in traces.
-     **/
-    String getHandlerName() {
-        final ObjectName name = getObjectName();
-        if (name != null) return name.toString();
-        return this.toString();
-    }
-
-   /**
-    * In this class, this method returns {@link #getSourceServer
-    * getSourceServer()}.{@link javax.management.MBeanServer#getMBeanCount
-    * getMBeanCount()}.
-    * <br>This default behaviour may be redefined in subclasses.
-    * @throws java.io.IOException can be thrown by subclasses.
-    */
-    public Integer getMBeanCount() throws IOException {
-        return getSourceServer().getMBeanCount();
-    }
-
-   /**
-    * In this class, this method returns {@link #getSourceServer
-    * getSourceServer()}.{@link javax.management.MBeanServer#getDomains
-    * getDomains()}.
-    * <br>This default behaviour may be redefined in subclasses.
-    * @throws java.io.IOException can be thrown by subclasses.
-    */
-   public String[] getDomains() throws IOException {
-       return getSourceServer().getDomains();
-    }
-
-   /**
-    * In this class, this method returns {@link #getSourceServer
-    * getSourceServer()}.{@link javax.management.MBeanServer#getDefaultDomain
-    * getDefaultDomain()}.
-    * <br>This default behaviour may be redefined in subclasses.
-    * @throws java.io.IOException can be thrown by subclasses.
-    */
-    public String getDefaultDomain() throws IOException {
-        return getSourceServer().getDefaultDomain();
-    }
-
-    public final String getUUID() {
-        return uuid;
-    }
-
-}
--- a/src/share/classes/javax/management/namespace/JMXNamespaceMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import java.io.IOException;
-import java.util.UUID;
-
-/**
- * A {@link JMXNamespace} is an MBean that handles a name space in the
- * MBeanServer hierarchical name space.
- * @see JMXNamespace
- * @since 1.7
- */
-public interface JMXNamespaceMBean {
-
-    // Note: since getDomains(), getDefaultDomain(), and getMBeanCount()
-    // don't take any ObjectName parameters, the only efficient way
-    // to get these data is to call the corresponding method on the
-    // JMXNamespaceMBean that handles the name space.
-    //
-    // We need these methods to implement 'cd' (JMXNamespaces.narrowToNamespace)
-    // correctly.
-    //
-
-    /**
-     * Returns the list of domains currently implemented in the name space
-     * handled by this {@link JMXNamespace}.
-     * @throws IOException if the domain list cannot be obtained due to
-     *         I/O problems (communication failures etc...).
-     * @return the list of domains currently implemented in the name space
-     * handled by this {@link JMXNamespace}.
-     * @see javax.management.MBeanServerConnection#getDomains
-     *      MBeanServerConnection.getDomains
-     **/
-    public String[] getDomains() throws IOException;
-
-    /**
-     * Returns the default domain for the name space handled by
-     * this {@link JMXNamespace}.
-     * @throws IOException if the default domain cannot be obtained due to
-     *         I/O problems (communication failures etc...).
-     * @return the default domain for the name space handled by
-     * this {@link JMXNamespace}.
-     * @see javax.management.MBeanServerConnection#getDefaultDomain
-     *      MBeanServerConnection.getDefaultDomain
-     **/
-    public String   getDefaultDomain() throws IOException;
-
-    /**
-     * Returns the number of MBeans registered in the  name space handled by
-     *         this  {@link JMXNamespace}.
-     *
-     * @return the number of MBeans registered in the  name space handled by
-     *         this  {@link JMXNamespace}.
-     *
-     * @throws IOException if the MBean count cannot be obtained due to
-     *         I/O problems (communication failures etc...).
-     * @see javax.management.MBeanServerConnection#getMBeanCount
-     *      MBeanServerConnection.getMBeanCount
-     */
-    public Integer  getMBeanCount() throws IOException;
-
-    /**
-     * Returns a {@link java.util.UUID UUID string} which uniquely identifies
-     * this {@linkplain JMXNamespace} MBean.
-     * This information can be used to detect loops in the JMX name space graph.
-     * @return A unique ID identifying this MBean.
-     * @throws IOException if the MBean UUID cannot be obtained due to
-     *         I/O problems (communication failures etc...).
-     */
-    public String getUUID() throws IOException;
-
-}
--- a/src/share/classes/javax/management/namespace/JMXNamespacePermission.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1446 +0,0 @@
-/*
- * Copyright 2002-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 javax.management.namespace;
-
-import javax.management.*;
-import com.sun.jmx.mbeanserver.Util;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.security.Permission;
-
-/**
- * <p>A permission controlling access to MBeans located in namespaces.
- * If a security manager has been set using {@link
- * System#setSecurityManager}, most operations on an MBean mounted in a
- * namespace require that the caller's permissions imply a
- * JMXNamespacePermission appropriate for the operation.
- * This is described in detail in the
- * documentation for the
- * <a href="JMXNamespace.html#PermissionChecks">JMXNamespace</a>
- * class.</p>
- *
- * <p>As with other {@link Permission} objects,
- * a JMXNamespacePermission can represent either a permission that
- * you <em>have</em> or a permission that you <em>need</em>.
- * When a sensitive operation is being checked for permission,
- * a JMXNamespacePermission is constructed
- * representing the permission you need.  The operation is only
- * allowed if the permissions you have {@linkplain #implies imply} the
- * permission you need.</p>
- *
- * <p>A JMXNamespacePermission contains four items of information:</p>
- *
- * <ul>
- *
- * <li id="Action"><p>The <em>action</em>.</p>
- * <p>For a permission you need,
- * this is one of the actions in the list <a
- * href="#action-list">below</a>.  For a permission you have, this is
- * a comma-separated list of those actions, or <code>*</code>,
- * representing all actions.</p>
- *
- * <p>The action is returned by {@link #getActions()}.</p>
- *
- * <li id="MBeanServerName"><p>The <em>MBean Server name</em>.</p>
- *
- * <p>For a permission you need, this is the {@linkplain
- * javax.management.MBeanServerFactory#getMBeanServerName
- * name of the MBeanServer}
- * from which the <a href="#MBeanName">MBean</a> is accessed.</p>
- *
- * <p>For a permission you have, this is either the  {@linkplain
- * javax.management.MBeanServerFactory#getMBeanServerName
- * name of the MBeanServer} from which the <a href="#MBeanName">MBean</a>
- * for which you have this permission is accessed,
- * or a pattern against which that MBean Server name will be matched.<br>
- * An {@code mbeanServername} pattern can also be empty, or the single
- * character {@code "*"}, both of which match any {@code MBeanServer} name.
- * The string {@code "-"} doesn't match any MBeanServer name.
- * </p>
- *
- * <p>Example:</p>
- * <pre>
- *   // grant permission to invoke the operation "stop" on any MBean
- *   // whose name matches "a//*&#42;//*:type=JMXConnectorServer" when
- *   // accessed from any MBeanServer whose name matches myapp.*"
- *   permission javax.management.namespace.JMXNamespacePermission "myapp.*::stop[a//*&#42;//*:type=JMXConnectorServer]", "invoke";
- * </pre>
- *
- * <li id="Member"><p>The <em>member</em>.</p>
- *
- * <p>For a permission you need, this is the name of the attribute or
- * operation you are accessing.  For operations that do not reference
- * an attribute or operation, the member is null.</p>
- *
- * <p>For a permission you have, this is either the name of an attribute
- * or operation you can access, or it is empty or the single character
- * "<code>*</code>", both of which grant access to any member.</p>
- *
- * <p>There is a special case for actions {@code registerMBean} and
- *    {@code instantiate}, where for a permission you need, {@code member}
- *    indicates the name of the class for which you are trying
- *    to create, instantiate, or register an MBean instance. For a
- *    permission you have, it is a pattern that will be matched against
- *    the full class name of the MBean being created, instantiated, or
- *    registered.
- * </p>
- *
- *
- * <li id="MBeanName"><p>The <em>object name</em>.</p>
- *
- * <p>For a permission you need, this is the {@link ObjectName} of the
- * MBean you are accessing. It is of the form {@code <namespace>//<mbean name>}
- * where {@code <namespace>} is the name of the name space for which the
- * permission is checked, and {@code <mbean name>} is the name of the MBean
- * within that namespace.
- * <br>
- * For operations that do not reference a
- * single MBean, the <em>object name</em> is null.  It is never an object
- * name pattern.
- * </p>
- *
- * <p>For a permission you have, this is the {@link ObjectName} of the
- * MBean or MBeans you can access. It is of the form
- * {@code <namespace>//<mbean name>}
- * where {@code <namespace>} is the name of the name space for which the
- * permission is checked, and
- * {@code <mbean name>} is the name of the MBean
- * within that namespace. Both {@code <namespace>} and {@code <mbean name>}
- * can be patterns. The <em>object name</em>
- * may also be empty, which grants access to all MBeans whatever their
- * name and namespace.
- * When included in a namespace path the special path element
- * <code>**</code> matches any number of sub namespaces
- * recursively, but only if used as a complete namespace path element,
- * as in <code>*&#42;//b//c//D:k=v</code> or <code>a//*&#42;//c//D:k=v</code>
- * - see ObjectName <a href="../ObjectName.html#metawildcard">documentation</a>
- * for more details.
- * </p>
- *
- *
- * </ul>
- *
- * <p>If you have a JMXNamespacePermission, it allows operations only
- * if all four of the items match.</p>
- *
- * <p>The <a href="#MBeanServerName">MBeanServer name</a>,
- * <a href="#Member">member</a>, and <a href="#MBeanName">object name</a>
- * can be written together
- * as a single string, which is the <em>name</em> of this permission.
- * The name of the permission is the string returned by {@link
- * java.security.Permission#getName() getName()}.
- * The format of the string is:</p>
- *
- * <blockquote>
- * {@code <mbean server name>::<member>[<namespace>//<mbean name>]}
- * </blockquote>
- *
- * <p>
- * The {@code <mbean server name>} is optional. If omitted, {@code "*"} is
- * assumed, and these three permission names
- * are thus equivalent:
- * </p>
- * <blockquote>
- * {@code *::<member>[<namespace>//<mbean name>]}<br>
- * {@code ::<member>[<namespace>//<mbean name>]}<br>
- * {@code <member>[<namespace>//<mbean name>]}<br>
- * </blockquote>
- * <p>
- *    The {@code <namespace>//<mbean name>} string can be in the form
- *    of a traditional ObjectName
- *    pattern - meaning that <code>?</code> will match any single
- *    character, and <code>*</code> will match any sequence of characters,
- *    except {@value
- *    javax.management.namespace.JMXNamespaces#NAMESPACE_SEPARATOR}
- *    In addition, when included in a namespace path the special
- *    path element <code>**</code> matches any number of sub namespaces
- *    recursively.
- *    A {@code <namespace>//<mbean name>} string of the form
- *    <code>*&#42;//*:*</code> thus means that the permission is
- *    granted for all MBeans in all namespaces, recursively (see
- *    <a href="#metawildcard">below</a> for more details.
- * </p>
- * <p>Namespace permission checking may be tricky to configure, depending
- *    on whether the namespaces crossed to reach the MBean are local or
- *    remote.<br>
- *    For instance, let <code>a//b//D:k=v</code> be an MBean exposing an
- *    attribute <code>Foo</code>.
- *    If namespace <code>a</code> is a plain JMXNamespace pointing to
- *    a local MBeanServer in the same JVM, then the permissions you need
- *    to get the attribute <code>Foo</code> will be:
- * </p>
- * <pre>
- *    // granting permission to access attribute 'Foo' of MBean a//b//D:k=v
- *    // from MBeanServer named 'srv1'
- *    // This permission will be checked by the MBeanServer that contains 'a'.
- *    srv1::Foo[a//b//D:k=v]
- *
- *    // Since a is local, you also need the following additional permission,
- *    // which will be checked by the MBeanServer 'srv2' that contains 'b':
- *    //
- *    // granting permission to access attribute 'Foo' of MBean b//D:k=v from
- *    // 'srv2'
- *    srv2::Foo[b//D:k=v]
- * </pre>
- * <p>On the other hand, if namespace <code>a</code> is a JMXRemoteNamespace
- *    pointing to an MBeanServer in a remote JVM, then the only permission you
- *    need to get the attribute <code>Foo</code> will be:
- * </p>
- * <pre>
- *    // granting permission to access attribute 'Foo' of MBean a//b//D:k=v
- *    // from 'srv1'
- *    srv1::Foo[a//b//D:k=v]
- * </pre>
- * <p>The namespace <code>b</code> resides in the remote JVM, and
- *    therefore the permissions concerning access to MBeans from
- *    namespace 'b' will only be checked in the remote JVM, if that JVM is
- *    configured to do so.
- * </p>
- *
- * <p>The {@code <mbean name>} is written using the usual syntax for {@link
- * ObjectName}.  It may contain any legal characters, including
- * <code>]</code>.  It is terminated by a <code>]</code> character
- * that is the last character in the string.
- * </p>
- * <p>Below are some examples of permission names:</p>
- * <pre>
- *    // allows access to Foo in 'a//b//*:*' from any MBeanServer in the JVM.
- *    Foo[a//b//*:*]
- *
- *    // allows access to Foo in all subnamespaces of 'a//b', but only for
- *    // MBeanServers whose name matches 'myapp.*'
- *    myapp.*::Foo[a//b//*&#42;//*:*]
- *
- *    // allows access to Foo from all namespaces in the MBeanServer named
- *    // 'myapp.srv1' - but not recursively.
- *    myapp.srv1::Foo[&#42;//*:*]
- * </pre>
- * <p>For instance, the first two permissions listed above
- *    will let through {@code getAttribute("a//b//D:k=v","Foo");} in
- *    all MBeanServers, but will block access to
- *    {@code getAttribute("a//b//c//D:k=v","Foo");} in MBeanServers whose
- *    name do not start with {@code "myapp."}.
- * </p>
- * <p><a name="metawildcard">Depending on how your namespace hierarchy
- *    is defined some of these wildcard permission names can be useful</a>:</p>
- * <pre>
- *    // allows access to Foo in all namespaces, recursively.
- *    //
- *    *::Foo[*&#42;//*:*]
- *
- *    // This permission name is the equivalent to the permission names above:
- *    // Foo[*&#42;//*:*] and Foo[] are equivalent.
- *    //
- *    Foo[]
- *
- *    // This permission name is the equivalent to the two permission names
- *    // above:
- *    // Foo[*&#42;//*:*], Foo[], Foo are equivalent.
- *    //
- *    Foo
- *
- *    // allows access to Foo from all namespaces - but not recursively.
- *    // This wildcard permission complements the previous one: it allows
- *    // access to 'Foo' from an MBean directly registered in any local namespace.
- *    //
- *    Foo[&#42;//*:*]
- *
- * </pre>
- * <p><b>Note on wildcards:</b> In an object name pattern, a path element
- *    of exactly <code>**</code> corresponds to a meta
- *    wildcard that will match any number of sub namespaces.
- *    See ObjectName <a href="../ObjectName.html#metawildcard">documentation</a>
- *    for more details.</p>
- *
- * <p>If {@code <mbean server name>::} is omitted, then one of
- * <code>member</code> or <code>object name</code> may be omitted.
- * If the <code>object name</code> is omitted,
- * the <code>[]</code> may be too (but does not have to be).  It is
- * not legal to omit all items, that is to have a <em>name</em>
- * which is the empty string.</p>
- * <p>If {@code <mbean server name>} is present, it <b>must be followed</b> by
- *    the {@code "::"} separator - otherwise it will be interpreted as
- *    a {@code member name}.
- * </p>
- *
- * <p>
- * One or more of the <a href="#MBeanServerName">MBean Server name</a>,
- * <a href="#Member">member</a>
- * or <a href="#MBeanName">object name</a> may be the character "<code>-</code>",
- * which is equivalent to a null value.  A null value is implied by
- * any value (including another null value) but does not imply any
- * other value.
- * </p>
- *
- * <p><a name="action-list">The possible actions are these:</a></p>
- *
- * <ul>
- * <li>addNotificationListener</li>
- * <li>getAttribute</li>
- * <li>getClassLoader</li>
- * <li>getClassLoaderFor</li>
- * <li>getClassLoaderRepository</li>
- * <li>getMBeanInfo</li>
- * <li>getObjectInstance</li>
- * <li>instantiate</li>
- * <li>invoke</li>
- * <li>isInstanceOf</li>
- * <li>queryMBeans</li>
- * <li>queryNames</li>
- * <li>registerMBean</li>
- * <li>removeNotificationListener</li>
- * <li>setAttribute</li>
- * <li>unregisterMBean</li>
- * </ul>
- *
- * <p>In a comma-separated list of actions, spaces are allowed before
- * and after each action.</p>
- *
- * @since 1.7
- */
-public class JMXNamespacePermission extends Permission {
-
-    private static final long serialVersionUID = -2416928705275160661L;
-
-    private static final String WILDPATH = "**" +
-                JMXNamespaces.NAMESPACE_SEPARATOR + "*";
-
-    /**
-     * Actions list.
-     */
-    private static final int AddNotificationListener    = 0x00001;
-    private static final int GetAttribute               = 0x00002;
-    private static final int GetClassLoader             = 0x00004;
-    private static final int GetClassLoaderFor          = 0x00008;
-    private static final int GetClassLoaderRepository   = 0x00010;
-    // No GetDomains because it is not possible to route a call to
-    // getDomains() on a NamespaceInterceptor - getDomains() doesn't
-    // have any ObjectName.
-    // private static final int GetDomains                 = 0x00020;
-    private static final int GetMBeanInfo               = 0x00040;
-    private static final int GetObjectInstance          = 0x00080;
-    private static final int Instantiate                = 0x00100;
-    private static final int Invoke                     = 0x00200;
-    private static final int IsInstanceOf               = 0x00400;
-    private static final int QueryMBeans                = 0x00800;
-    private static final int QueryNames                 = 0x01000;
-    private static final int RegisterMBean              = 0x02000;
-    private static final int RemoveNotificationListener = 0x04000;
-    private static final int SetAttribute               = 0x08000;
-    private static final int UnregisterMBean            = 0x10000;
-
-    /**
-     * No actions.
-     */
-    private static final int NONE = 0x00000;
-
-    /**
-     * All actions.
-     */
-    // No GetDomains because it is not possible to route a call to
-    // getDomains() on a NamespaceInterceptor - getDomains() doesn't
-    // have any ObjectName.
-    //
-    private static final int ALL =
-        AddNotificationListener    |
-        GetAttribute               |
-        GetClassLoader             |
-        GetClassLoaderFor          |
-        GetClassLoaderRepository   |
-        GetMBeanInfo               |
-        GetObjectInstance          |
-        Instantiate                |
-        Invoke                     |
-        IsInstanceOf               |
-        QueryMBeans                |
-        QueryNames                 |
-        RegisterMBean              |
-        RemoveNotificationListener |
-        SetAttribute               |
-        UnregisterMBean;
-
-    /**
-     * The actions string.
-     */
-    private String actions;
-
-    /**
-     * The actions mask.
-     */
-    private transient int mask;
-
-    /**
-     * The name of the MBeanServer in which this permission is checked, or
-     * granted.  If null, is implied by any MBean server name
-     * but does not imply any non-null MBean server name.
-     */
-    private transient String mbeanServerName;
-
-    /**
-     * The member that must match.  If null, is implied by any member
-     * but does not imply any non-null member.
-     */
-    private transient String member;
-
-    /**
-     * The objectName that must match.  If null, is implied by any
-     * objectName but does not imply any non-null objectName.
-     */
-    private transient ObjectName objectName;
-
-    /**
-     * If objectName is missing from name, then allnames will be
-     * set to true.
-     */
-    private transient boolean  allnames = false;
-
-    /**
-     * Parse <code>actions</code> parameter.
-     */
-    private void parseActions() {
-
-        int amask;
-
-        if (actions == null)
-            throw new IllegalArgumentException("JMXNamespaceAccessPermission: " +
-                                               "actions can't be null");
-        if (actions.equals(""))
-            throw new IllegalArgumentException("JMXNamespaceAccessPermission: " +
-                                               "actions can't be empty");
-
-        amask = getMask(actions);
-
-        if ((amask & ALL) != amask)
-            throw new IllegalArgumentException("Invalid actions mask");
-        if (amask == NONE)
-            throw new IllegalArgumentException("Invalid actions mask");
-        this.mask = amask;
-    }
-
-    /**
-     * Parse <code>name</code> parameter.
-     */
-    private void parseName() {
-        String name = getName();
-
-        if (name == null)
-            throw new IllegalArgumentException("JMXNamespaceAccessPermission name " +
-                                               "cannot be null");
-
-        if (name.equals(""))
-            throw new IllegalArgumentException("JMXNamespaceAccessPermission name " +
-                                               "cannot be empty");
-        final int sepIndex = name.indexOf("::");
-        if (sepIndex < 0) {
-            setMBeanServerName("*");
-        } else {
-            setMBeanServerName(name.substring(0,sepIndex));
-        }
-
-        /* The name looks like "mbeanServerName::member[objectname]".
-           We subtract elements from the right as we parse, so after
-           parsing the objectname we have "class#member" and after parsing the
-           member we have "class".  Each element is optional.  */
-
-        // Parse ObjectName
-
-        final int start = (sepIndex<0)?0:sepIndex+2;
-        int openingBracket = name.indexOf("[",start);
-        if (openingBracket == -1) {
-            // If "[on]" missing then ObjectName("*:*")
-            //
-            objectName = null;
-            allnames = true;
-            openingBracket=name.length();
-        } else {
-            if (!name.endsWith("]")) {
-                throw new IllegalArgumentException("JMXNamespaceAccessPermission: " +
-                                                   "The ObjectName in the " +
-                                                   "target name must be " +
-                                                   "included in square " +
-                                                   "brackets");
-            } else {
-                // Create ObjectName
-                //
-                String on = name.substring(openingBracket + 1,
-                                           name.length() - 1);
-                try {
-                    // If "[]" then allnames are implied
-                    //
-                    final ObjectName target;
-                    final boolean    all;
-                    if (on.equals("")) {
-                        target = null;
-                        all = true;
-                    } else if (on.equals("-")) {
-                        target = null;
-                        all = false;
-                    } else {
-                        target = new ObjectName(on);
-                        all    = false;
-                    }
-                    setObjectName(target,all);
-                } catch (MalformedObjectNameException e) {
-                    throw new IllegalArgumentException(
-                            "JMXNamespaceAccessPermission: " +
-                            "The target name does " +
-                            "not specify a valid " +
-                            "ObjectName", e);
-                }
-            }
-        }
-
-        final String memberName = name.substring(start,openingBracket);
-        setMember(memberName);
-    }
-
-    private void setObjectName(ObjectName target, boolean all) {
-        if (target != null &&
-            !Util.wildpathmatch(target.getDomain(), WILDPATH)) {
-            throw new IllegalArgumentException(
-                    "The target name does not contain " +
-                    "any namespace: "+String.valueOf(target));
-        } else if (target != null) {
-            final String domain = target.getDomain();
-            final int seplen = JMXNamespaces.NAMESPACE_SEPARATOR.length();
-            final int sepc = domain.indexOf(JMXNamespaces.NAMESPACE_SEPARATOR);
-            if (sepc < 0 || (sepc+seplen)==domain.length()) {
-                throw new IllegalArgumentException(String.valueOf(target)+
-                        ": no namespace in domain");
-            }
-        }
-        objectName = target;
-        allnames = all;
-    }
-
-    /**
-     * Assign fields based on className, member, and objectName
-     * parameters.
-     */
-//    private void initName(String namespaceName, String member,
-//                          ObjectName objectName, boolean allnames) {
-//        setNamespace(namespaceName);
-    private void initName(String mbeanServerName, String member,
-                          ObjectName mbeanName, boolean all) {
-        setMBeanServerName(mbeanServerName);
-        setMember(member);
-        setObjectName(mbeanName, all);
-    }
-
-    private void setMBeanServerName(String mbeanServerName) {
-        if (mbeanServerName == null || mbeanServerName.equals("-")) {
-            this.mbeanServerName = null;
-        } else if (mbeanServerName.equals("")) {
-            this.mbeanServerName = "*";
-        } else {
-            this.mbeanServerName = mbeanServerName;
-        }
-    }
-
-    private void setMember(String member) {
-        if (member == null || member.equals("-"))
-            this.member = null;
-        else if (member.equals(""))
-            this.member = "*";
-        else
-            this.member = member;
-    }
-
-    /**
-     * <p>Create a new JMXNamespacePermission object with the
-     * specified target name and actions.</p>
-     *
-     * <p>The target name is of the form
-     * "<code>mbeanServerName::member[objectName]</code>" where each part is
-     * optional. This target name must not be empty or null.
-     * If <code>objectName</code> is present, it is of
-     * the form <code>namespace//MBeanName</code>.
-     * </p>
-     * <p>
-     * For a permission you need, {@code mbeanServerName} is the
-     * <a href="#MBeanServerName">name of the MBeanServer</a> from
-     * which {@code objectName} is being accessed.
-     * </p>
-     * <p>
-     * For a permission you have, {@code mbeanServerName} is the
-     * <a href="#MBeanServerName">name of the MBeanServer</a> from
-     * which access to {@code objectName} is granted.
-     * It can also be a pattern, and if omitted, {@code "*"} is assumed,
-     * meaning that access to {@code objectName} is granted in all
-     * MBean servers in the JVM.
-     * </p>
-     *
-     * <p>The actions parameter contains a comma-separated list of the
-     * desired actions granted on the target name.  It must not be
-     * empty or null.</p>
-     *
-     * @param name the triplet "mbeanServerName::member[objectName]".
-     * If <code>objectName</code> is present, it is of
-     * the form <code>namespace//MBeanName</code>.
-     * @param actions the action string.
-     *
-     * @exception IllegalArgumentException if the <code>name</code> or
-     * <code>actions</code> is invalid.
-     */
-    public JMXNamespacePermission(String name, String actions) {
-        super(name);
-
-        parseName();
-
-        this.actions = actions;
-        parseActions();
-    }
-
-    /**
-     * <p>Create a new JMXNamespacePermission object with the specified
-     * target name (namespace name, member, object name) and actions.</p>
-     *
-     * <p>The {@code MBeanServer} name, member and object name
-     * parameters define a target name of the form
-     * "<code>mbeanServerName::member[objectName]</code>" where each
-     * part is optional.  This will be the result of {@link #getName()} on the
-     * resultant JMXNamespacePermission.
-     * If the <code>mbeanServerName</code> is empty or exactly {@code "*"}, then
-     * "{@code mbeanServerName::}" is omitted in that result.
-     * </p>
-     *
-     * <p>The actions parameter contains a comma-separated list of the
-     * desired actions granted on the target name.  It must not be
-     * empty or null.</p>
-     *
-     * @param mbeanServerName the name of the {@code MBeanServer} to which this
-     * permission applies.
-     * May be null or <code>"-"</code>, which represents an MBeanServer name
-     * that is implied by any MBeanServer name but does not imply any other
-     * MBeanServer name.
-     * @param member the member to which this permission applies.  May
-     * be null or <code>"-"</code>, which represents a member that is
-     * implied by any member but does not imply any other member.
-     * @param objectName the object name to which this permission
-     * applies.
-     * May be null, which represents an object name that is
-     * implied by any object name but does not imply any other object
-     * name. If not null, the {@code objectName} must be of the
-     * form {@code <namespace>//<mbean name>} - where {@code <namespace>}
-     * can be a domain pattern, and {@code <mbean name>} can be an ObjectName
-     * pattern.
-     * For a permission you need, {@code <namespace>} is the name of the
-     * name space for which the permission is checked, and {@code <mbean name>}
-     * is the name of the MBean in that namespace.
-     * The composed name {@code <namespace>//<mbean name>} thus represents the
-     * name of the MBean as seen by the {@code mbeanServerName} containing
-     * {@code <namespace>}.
-     *
-     * @param actions the action string.
-     */
-    public JMXNamespacePermission(
-                           String mbeanServerName,
-                           String member,
-                           ObjectName objectName,
-                           String actions) {
-        this(mbeanServerName, member, objectName, false, actions);
-//        this(member, objectName, false, actions);
-    }
-
-    /**
-     * <p>Create a new JMXNamespacePermission object with the specified
-     * MBean Server name, member, and actions.</p>
-     *
-     * <p>The {@code MBeanServer} name and member
-     * parameters define a target name of the form
-     * "<code>mbeanServerName::member[]</code>" where each
-     * part is optional.  This will be the result of {@link #getName()} on the
-     * resultant JMXNamespacePermission.
-     * If the <code>mbeanServerName</code> is empty or exactly {@code "*"}, then
-     * "{@code mbeanServerName::}" is omitted in that result.
-     * </p>
-     *
-     * <p>The actions parameter contains a comma-separated list of the
-     * desired actions granted on the target name.  It must not be
-     * empty or null.</p>
-     *
-     * @param mbeanServerName the name of the {@code MBeanServer} to which this
-     * permission applies.
-     * May be null or <code>"-"</code>, which represents an MBeanServer name
-     * that is implied by any MBeanServer name but does not imply any other
-     * MBeanServer name.
-     * @param member the member to which this permission applies.  May
-     * be null or <code>"-"</code>, which represents a member that is
-     * implied by any member but does not imply any other member.
-     * @param actions the action string.
-     */
-    public JMXNamespacePermission(String mbeanServerName,
-                           String member,
-                           String actions) {
-        this(mbeanServerName,member,null,true,actions);
-        // this(member,null,allnames,actions);
-    }
-
-    /**
-     * <p>Create a new JMXNamespacePermission object with the specified
-     * target name (namespace name, member, object name) and actions.</p>
-     *
-     * <p>The MBean Server name, member and object name parameters define a
-     * target name of the form
-     * "<code>mbeanServerName::member[objectName]</code>" where each part is
-     * optional.  This will be the result of {@link
-     * java.security.Permission#getName() getName()} on the
-     * resultant JMXNamespacePermission.</p>
-     *
-     * <p>The actions parameter contains a comma-separated list of the
-     * desired actions granted on the target name.  It must not be
-     * empty or null.</p>
-     *
-     * @param mbeanServerName the name of the {@code MBeanServer} to which this
-     * permission applies.
-     * May be null or <code>"-"</code>, which represents an MBeanServer name
-     * that is implied by any MBeanServer name but does not imply any other
-     * MBeanServer name.
-     * @param member the member to which this permission applies.  May
-     * be null or <code>"-"</code>, which represents a member that is
-     * implied by any member but does not imply any other member.
-     * @param objectName the object name to which this permission
-     * applies.  If null, and allnames is false, represents an object
-     * name that is implied by any object name but does not imply any
-     * other object name. Otherwise, if allnames is true, it represents
-     * a meta wildcard that matches all object names. It is equivalent to
-     * a missing objectName ("[]") in the {@link
-     * java.security.Permission#getName() name} property.
-     * @param allnames represent a meta wildcard indicating that the
-     *        objectName was not specified. This implies all objectnames
-     *        that match "*:*" and all object names that match
-     *        "*&#42;//*:*"
-     * @param actions the action string.
-     */
-    private JMXNamespacePermission(String mbeanServerName,
-                           String member,
-                           ObjectName objectName,
-                           boolean allnames,
-                           String actions) {
-
-        super(makeName(mbeanServerName,
-                member, objectName, allnames));
-        initName(mbeanServerName,
-                member, objectName, allnames);
-
-        this.actions = actions;
-        parseActions();
-    }
-
-    private static String makeName(String mbeanServerName,
-            String memberName, ObjectName objName, boolean allMBeans) {
-        final StringBuilder name = new StringBuilder();
-        if (mbeanServerName == null)
-            mbeanServerName = "-";
-        if (!mbeanServerName.equals("") && !mbeanServerName.equals("*"))
-            name.append(mbeanServerName).append("::");
-        if (memberName == null)
-            memberName = "-";
-        name.append(memberName);
-        if (objName == null) {
-            if (allMBeans)
-                name.append("[]");
-            else
-                name.append("[-]");
-        } else {
-            final String domain = objName.getDomain();
-            final int seplen = JMXNamespaces.NAMESPACE_SEPARATOR.length();
-            final int sepc = domain.indexOf(JMXNamespaces.NAMESPACE_SEPARATOR);
-            if (sepc < 0 || (sepc+seplen)==domain.length()) {
-                throw new IllegalArgumentException(String.valueOf(objName)+
-                        ": no namespace in domain");
-            }
-            final String can = objName.getCanonicalName();
-            name.append("[").append(can).append("]");
-        }
-        return name.toString();
-    }
-
-    /**
-     * Returns the "canonical string representation" of the actions. That is,
-     * this method always returns actions in alphabetical order.
-     *
-     * @return the canonical string representation of the actions.
-     */
-    public String getActions() {
-
-        if (actions == null)
-            actions = getActions(this.mask);
-
-        return actions;
-    }
-
-    /**
-     * Returns the "canonical string representation"
-     * of the actions from the mask.
-     */
-    private static String getActions(int mask) {
-        final StringBuilder sb = new StringBuilder();
-        boolean comma = false;
-
-        if ((mask & AddNotificationListener) == AddNotificationListener) {
-            comma = true;
-            sb.append("addNotificationListener");
-        }
-
-        if ((mask & GetAttribute) == GetAttribute) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("getAttribute");
-        }
-
-        if ((mask & GetClassLoader) == GetClassLoader) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("getClassLoader");
-        }
-
-        if ((mask & GetClassLoaderFor) == GetClassLoaderFor) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("getClassLoaderFor");
-        }
-
-        if ((mask & GetClassLoaderRepository) == GetClassLoaderRepository) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("getClassLoaderRepository");
-        }
-
-        if ((mask & GetMBeanInfo) == GetMBeanInfo) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("getMBeanInfo");
-        }
-
-        if ((mask & GetObjectInstance) == GetObjectInstance) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("getObjectInstance");
-        }
-
-        if ((mask & Instantiate) == Instantiate) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("instantiate");
-        }
-
-        if ((mask & Invoke) == Invoke) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("invoke");
-        }
-
-        if ((mask & IsInstanceOf) == IsInstanceOf) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("isInstanceOf");
-        }
-
-        if ((mask & QueryMBeans) == QueryMBeans) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("queryMBeans");
-        }
-
-        if ((mask & QueryNames) == QueryNames) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("queryNames");
-        }
-
-        if ((mask & RegisterMBean) == RegisterMBean) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("registerMBean");
-        }
-
-        if ((mask & RemoveNotificationListener) == RemoveNotificationListener) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("removeNotificationListener");
-        }
-
-        if ((mask & SetAttribute) == SetAttribute) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("setAttribute");
-        }
-
-        if ((mask & UnregisterMBean) == UnregisterMBean) {
-            if (comma) sb.append(',');
-            else comma = true;
-            sb.append("unregisterMBean");
-        }
-
-        // No GetDomains because it is not possible to route a call to
-        // getDomains() on a NamespaceInterceptor - getDomains() doesn't
-        // have any ObjectName.
-
-        return sb.toString();
-    }
-
-    @Override
-    public int hashCode() {
-        return this.getName().hashCode() + this.getActions().hashCode();
-    }
-
-    /**
-     * Converts an action String to an integer action mask.
-     *
-     * @param action the action string.
-     * @return the action mask.
-     */
-    private static int getMask(String action) {
-
-        /*
-         * BE CAREFUL HERE! PARSING ORDER IS IMPORTANT IN THIS ALGORITHM.
-         *
-         * The 'string length' test must be performed for the lengthiest
-         * strings first.
-         *
-         * In this permission if the "unregisterMBean" string length test is
-         * performed after the "registerMBean" string length test the algorithm
-         * considers the 'unregisterMBean' action as being the 'registerMBean'
-         * action and a parsing error is returned.
-         */
-
-        int mask = NONE;
-
-        if (action == null) {
-            return mask;
-        }
-
-        if (action.equals("*")) {
-            return ALL;
-        }
-
-        char[] a = action.toCharArray();
-
-        int i = a.length - 1;
-        if (i < 0)
-            return mask;
-
-        while (i != -1) {
-            char c;
-
-            // skip whitespace
-            while ((i!=-1) && ((c = a[i]) == ' ' ||
-                               c == '\r' ||
-                               c == '\n' ||
-                               c == '\f' ||
-                               c == '\t'))
-                i--;
-
-            // check for the known strings
-            int matchlen;
-
-            // No GetDomains because it is not possible to route a call to
-            // getDomains() on a NamespaceInterceptor - getDomains() doesn't
-            // have any ObjectName.
-
-            if (i >= 25 && /* removeNotificationListener */
-                (a[i-25] == 'r') &&
-                (a[i-24] == 'e') &&
-                (a[i-23] == 'm') &&
-                (a[i-22] == 'o') &&
-                (a[i-21] == 'v') &&
-                (a[i-20] == 'e') &&
-                (a[i-19] == 'N') &&
-                (a[i-18] == 'o') &&
-                (a[i-17] == 't') &&
-                (a[i-16] == 'i') &&
-                (a[i-15] == 'f') &&
-                (a[i-14] == 'i') &&
-                (a[i-13] == 'c') &&
-                (a[i-12] == 'a') &&
-                (a[i-11] == 't') &&
-                (a[i-10] == 'i') &&
-                (a[i-9] == 'o') &&
-                (a[i-8] == 'n') &&
-                (a[i-7] == 'L') &&
-                (a[i-6] == 'i') &&
-                (a[i-5] == 's') &&
-                (a[i-4] == 't') &&
-                (a[i-3] == 'e') &&
-                (a[i-2] == 'n') &&
-                (a[i-1] == 'e') &&
-                (a[i] == 'r')) {
-                matchlen = 26;
-                mask |= RemoveNotificationListener;
-            } else if (i >= 23 && /* getClassLoaderRepository */
-                       (a[i-23] == 'g') &&
-                       (a[i-22] == 'e') &&
-                       (a[i-21] == 't') &&
-                       (a[i-20] == 'C') &&
-                       (a[i-19] == 'l') &&
-                       (a[i-18] == 'a') &&
-                       (a[i-17] == 's') &&
-                       (a[i-16] == 's') &&
-                       (a[i-15] == 'L') &&
-                       (a[i-14] == 'o') &&
-                       (a[i-13] == 'a') &&
-                       (a[i-12] == 'd') &&
-                       (a[i-11] == 'e') &&
-                       (a[i-10] == 'r') &&
-                       (a[i-9] == 'R') &&
-                       (a[i-8] == 'e') &&
-                       (a[i-7] == 'p') &&
-                       (a[i-6] == 'o') &&
-                       (a[i-5] == 's') &&
-                       (a[i-4] == 'i') &&
-                       (a[i-3] == 't') &&
-                       (a[i-2] == 'o') &&
-                       (a[i-1] == 'r') &&
-                       (a[i] == 'y')) {
-                matchlen = 24;
-                mask |= GetClassLoaderRepository;
-            } else if (i >= 22 && /* addNotificationListener */
-                       (a[i-22] == 'a') &&
-                       (a[i-21] == 'd') &&
-                       (a[i-20] == 'd') &&
-                       (a[i-19] == 'N') &&
-                       (a[i-18] == 'o') &&
-                       (a[i-17] == 't') &&
-                       (a[i-16] == 'i') &&
-                       (a[i-15] == 'f') &&
-                       (a[i-14] == 'i') &&
-                       (a[i-13] == 'c') &&
-                       (a[i-12] == 'a') &&
-                       (a[i-11] == 't') &&
-                       (a[i-10] == 'i') &&
-                       (a[i-9] == 'o') &&
-                       (a[i-8] == 'n') &&
-                       (a[i-7] == 'L') &&
-                       (a[i-6] == 'i') &&
-                       (a[i-5] == 's') &&
-                       (a[i-4] == 't') &&
-                       (a[i-3] == 'e') &&
-                       (a[i-2] == 'n') &&
-                       (a[i-1] == 'e') &&
-                       (a[i] == 'r')) {
-                matchlen = 23;
-                mask |= AddNotificationListener;
-            } else if (i >= 16 && /* getClassLoaderFor */
-                       (a[i-16] == 'g') &&
-                       (a[i-15] == 'e') &&
-                       (a[i-14] == 't') &&
-                       (a[i-13] == 'C') &&
-                       (a[i-12] == 'l') &&
-                       (a[i-11] == 'a') &&
-                       (a[i-10] == 's') &&
-                       (a[i-9] == 's') &&
-                       (a[i-8] == 'L') &&
-                       (a[i-7] == 'o') &&
-                       (a[i-6] == 'a') &&
-                       (a[i-5] == 'd') &&
-                       (a[i-4] == 'e') &&
-                       (a[i-3] == 'r') &&
-                       (a[i-2] == 'F') &&
-                       (a[i-1] == 'o') &&
-                       (a[i] == 'r')) {
-                matchlen = 17;
-                mask |= GetClassLoaderFor;
-            } else if (i >= 16 && /* getObjectInstance */
-                       (a[i-16] == 'g') &&
-                       (a[i-15] == 'e') &&
-                       (a[i-14] == 't') &&
-                       (a[i-13] == 'O') &&
-                       (a[i-12] == 'b') &&
-                       (a[i-11] == 'j') &&
-                       (a[i-10] == 'e') &&
-                       (a[i-9] == 'c') &&
-                       (a[i-8] == 't') &&
-                       (a[i-7] == 'I') &&
-                       (a[i-6] == 'n') &&
-                       (a[i-5] == 's') &&
-                       (a[i-4] == 't') &&
-                       (a[i-3] == 'a') &&
-                       (a[i-2] == 'n') &&
-                       (a[i-1] == 'c') &&
-                       (a[i] == 'e')) {
-                matchlen = 17;
-                mask |= GetObjectInstance;
-            } else if (i >= 14 && /* unregisterMBean */
-                       (a[i-14] == 'u') &&
-                       (a[i-13] == 'n') &&
-                       (a[i-12] == 'r') &&
-                       (a[i-11] == 'e') &&
-                       (a[i-10] == 'g') &&
-                       (a[i-9] == 'i') &&
-                       (a[i-8] == 's') &&
-                       (a[i-7] == 't') &&
-                       (a[i-6] == 'e') &&
-                       (a[i-5] == 'r') &&
-                       (a[i-4] == 'M') &&
-                       (a[i-3] == 'B') &&
-                       (a[i-2] == 'e') &&
-                       (a[i-1] == 'a') &&
-                       (a[i] == 'n')) {
-                matchlen = 15;
-                mask |= UnregisterMBean;
-            } else if (i >= 13 && /* getClassLoader */
-                       (a[i-13] == 'g') &&
-                       (a[i-12] == 'e') &&
-                       (a[i-11] == 't') &&
-                       (a[i-10] == 'C') &&
-                       (a[i-9] == 'l') &&
-                       (a[i-8] == 'a') &&
-                       (a[i-7] == 's') &&
-                       (a[i-6] == 's') &&
-                       (a[i-5] == 'L') &&
-                       (a[i-4] == 'o') &&
-                       (a[i-3] == 'a') &&
-                       (a[i-2] == 'd') &&
-                       (a[i-1] == 'e') &&
-                       (a[i] == 'r')) {
-                matchlen = 14;
-                mask |= GetClassLoader;
-            } else if (i >= 12 && /* registerMBean */
-                       (a[i-12] == 'r') &&
-                       (a[i-11] == 'e') &&
-                       (a[i-10] == 'g') &&
-                       (a[i-9] == 'i') &&
-                       (a[i-8] == 's') &&
-                       (a[i-7] == 't') &&
-                       (a[i-6] == 'e') &&
-                       (a[i-5] == 'r') &&
-                       (a[i-4] == 'M') &&
-                       (a[i-3] == 'B') &&
-                       (a[i-2] == 'e') &&
-                       (a[i-1] == 'a') &&
-                       (a[i] == 'n')) {
-                matchlen = 13;
-                mask |= RegisterMBean;
-            } else if (i >= 11 && /* getAttribute */
-                       (a[i-11] == 'g') &&
-                       (a[i-10] == 'e') &&
-                       (a[i-9] == 't') &&
-                       (a[i-8] == 'A') &&
-                       (a[i-7] == 't') &&
-                       (a[i-6] == 't') &&
-                       (a[i-5] == 'r') &&
-                       (a[i-4] == 'i') &&
-                       (a[i-3] == 'b') &&
-                       (a[i-2] == 'u') &&
-                       (a[i-1] == 't') &&
-                       (a[i] == 'e')) {
-                matchlen = 12;
-                mask |= GetAttribute;
-            } else if (i >= 11 && /* getMBeanInfo */
-                       (a[i-11] == 'g') &&
-                       (a[i-10] == 'e') &&
-                       (a[i-9] == 't') &&
-                       (a[i-8] == 'M') &&
-                       (a[i-7] == 'B') &&
-                       (a[i-6] == 'e') &&
-                       (a[i-5] == 'a') &&
-                       (a[i-4] == 'n') &&
-                       (a[i-3] == 'I') &&
-                       (a[i-2] == 'n') &&
-                       (a[i-1] == 'f') &&
-                       (a[i] == 'o')) {
-                matchlen = 12;
-                mask |= GetMBeanInfo;
-            } else if (i >= 11 && /* isInstanceOf */
-                       (a[i-11] == 'i') &&
-                       (a[i-10] == 's') &&
-                       (a[i-9] == 'I') &&
-                       (a[i-8] == 'n') &&
-                       (a[i-7] == 's') &&
-                       (a[i-6] == 't') &&
-                       (a[i-5] == 'a') &&
-                       (a[i-4] == 'n') &&
-                       (a[i-3] == 'c') &&
-                       (a[i-2] == 'e') &&
-                       (a[i-1] == 'O') &&
-                       (a[i] == 'f')) {
-                matchlen = 12;
-                mask |= IsInstanceOf;
-            } else if (i >= 11 && /* setAttribute */
-                       (a[i-11] == 's') &&
-                       (a[i-10] == 'e') &&
-                       (a[i-9] == 't') &&
-                       (a[i-8] == 'A') &&
-                       (a[i-7] == 't') &&
-                       (a[i-6] == 't') &&
-                       (a[i-5] == 'r') &&
-                       (a[i-4] == 'i') &&
-                       (a[i-3] == 'b') &&
-                       (a[i-2] == 'u') &&
-                       (a[i-1] == 't') &&
-                       (a[i] == 'e')) {
-                matchlen = 12;
-                mask |= SetAttribute;
-            } else if (i >= 10 && /* instantiate */
-                       (a[i-10] == 'i') &&
-                       (a[i-9] == 'n') &&
-                       (a[i-8] == 's') &&
-                       (a[i-7] == 't') &&
-                       (a[i-6] == 'a') &&
-                       (a[i-5] == 'n') &&
-                       (a[i-4] == 't') &&
-                       (a[i-3] == 'i') &&
-                       (a[i-2] == 'a') &&
-                       (a[i-1] == 't') &&
-                       (a[i] == 'e')) {
-                matchlen = 11;
-                mask |= Instantiate;
-            } else if (i >= 10 && /* queryMBeans */
-                       (a[i-10] == 'q') &&
-                       (a[i-9] == 'u') &&
-                       (a[i-8] == 'e') &&
-                       (a[i-7] == 'r') &&
-                       (a[i-6] == 'y') &&
-                       (a[i-5] == 'M') &&
-                       (a[i-4] == 'B') &&
-                       (a[i-3] == 'e') &&
-                       (a[i-2] == 'a') &&
-                       (a[i-1] == 'n') &&
-                       (a[i] == 's')) {
-                matchlen = 11;
-                mask |= QueryMBeans;
-            } else if (i >= 9 && /* queryNames */
-                       (a[i-9] == 'q') &&
-                       (a[i-8] == 'u') &&
-                       (a[i-7] == 'e') &&
-                       (a[i-6] == 'r') &&
-                       (a[i-5] == 'y') &&
-                       (a[i-4] == 'N') &&
-                       (a[i-3] == 'a') &&
-                       (a[i-2] == 'm') &&
-                       (a[i-1] == 'e') &&
-                       (a[i] == 's')) {
-                matchlen = 10;
-                mask |= QueryNames;
-            } else if (i >= 5 && /* invoke */
-                       (a[i-5] == 'i') &&
-                       (a[i-4] == 'n') &&
-                       (a[i-3] == 'v') &&
-                       (a[i-2] == 'o') &&
-                       (a[i-1] == 'k') &&
-                       (a[i] == 'e')) {
-                matchlen = 6;
-                mask |= Invoke;
-            } else {
-                // parse error
-                throw new IllegalArgumentException("Invalid permission: " +
-                                                   action);
-            }
-
-            // make sure we didn't just match the tail of a word
-            // like "ackbarfaccept".  Also, skip to the comma.
-            boolean seencomma = false;
-            while (i >= matchlen && !seencomma) {
-                switch(a[i-matchlen]) {
-                case ',':
-                    seencomma = true;
-                    break;
-                case ' ': case '\r': case '\n':
-                case '\f': case '\t':
-                    break;
-                default:
-                    throw new IllegalArgumentException("Invalid permission: " +
-                                                       action);
-                }
-                i--;
-            }
-
-            // point i at the location of the comma minus one (or -1).
-            i -= matchlen;
-        }
-
-        return mask;
-    }
-
-    /**
-     * <p>Checks if this JMXNamespacePermission object "implies" the
-     * specified permission.</p>
-     *
-     * <p>More specifically, this method returns true if:</p>
-     *
-     * <ul>
-     *
-     * <li> <i>p</i> is an instance of JMXNamespacePermission; and</li>
-     *
-     * <li> <i>p</i> has a null mbeanServerName or <i>p</i>'s mbeanServerName
-     * matches this object's mbeanServerName; and</li>
-     *
-     * <li> <i>p</i> has a null member or <i>p</i>'s member matches this
-     * object's member; and</li>
-     *
-     * <li> <i>p</i> has a null object name or <i>p</i>'s
-     * object name matches this object's object name; and</li>
-     *
-     * <li> <i>p</i>'s actions are a subset of this object's actions</li>
-     *
-     * </ul>
-     *
-     * <p>If this object's mbeanServerName is a pattern, then <i>p</i>'s
-     *    mbeanServerName is matched against that pattern. An empty
-     *    mbeanServerName is equivalent to "{@code *}". A null
-     *    mbeanServerName is equivalent to "{@code -}".</p>
-     * <p>If this object's mbeanServerName is "<code>*</code>" or is
-     * empty, <i>p</i>'s mbeanServerName always matches it.</p>
-     *
-     * <p>If this object's member is "<code>*</code>", <i>p</i>'s
-     * member always matches it.</p>
-     *
-     * <p>If this object's objectName <i>n1</i> is an object name pattern,
-     * <i>p</i>'s objectName <i>n2</i> matches it if
-     * {@link ObjectName#equals <i>n1</i>.equals(<i>n2</i>)} or if
-     * {@link ObjectName#apply <i>n1</i>.apply(<i>n2</i>)}.</p>
-     *
-     * <p>A permission that includes the <code>queryMBeans</code> action
-     * is considered to include <code>queryNames</code> as well.</p>
-     *
-     * @param p the permission to check against.
-     * @return true if the specified permission is implied by this object,
-     * false if not.
-     */
-    public boolean implies(Permission p) {
-        if (!(p instanceof JMXNamespacePermission))
-            return false;
-
-        JMXNamespacePermission that = (JMXNamespacePermission) p;
-
-        // Actions
-        //
-        // The actions in 'this' permission must be a
-        // superset of the actions in 'that' permission
-        //
-
-        /* "queryMBeans" implies "queryNames" */
-        if ((this.mask & QueryMBeans) == QueryMBeans) {
-            if (((this.mask | QueryNames) & that.mask) != that.mask) {
-                //System.out.println("action [with QueryNames] does not imply");
-                return false;
-            }
-        } else {
-            if ((this.mask & that.mask) != that.mask) {
-                //System.out.println("action does not imply");
-                return false;
-            }
-        }
-
-        // Target name
-        //
-        // The 'mbeanServerName' check is true iff:
-        // 1) the mbeanServerName in 'this' permission is omitted or "*", or
-        // 2) the mbeanServerName in 'that' permission is omitted or "*", or
-        // 3) the mbeanServerName in 'this' permission does pattern
-        //    matching with the mbeanServerName in 'that' permission.
-        //
-        // The 'member' check is true iff:
-        // 1) the member in 'this' member is omitted or "*", or
-        // 2) the member in 'that' member is omitted or "*", or
-        // 3) the member in 'this' permission equals the member in
-        //    'that' permission.
-        //
-        // The 'object name' check is true iff:
-        // 1) the object name in 'this' permission is omitted, or
-        // 2) the object name in 'that' permission is omitted, or
-        // 3) the object name in 'this' permission does pattern
-        //    matching with the object name in 'that' permission.
-        //
-
-        if (that.mbeanServerName == null) {
-            // bottom is implied
-        } else if (this.mbeanServerName == null) {
-            // bottom implies nothing but itself
-            return false;
-        } else if (that.mbeanServerName.equals(this.mbeanServerName)) {
-            // exact match
-        } else if (!Util.wildmatch(that.mbeanServerName,this.mbeanServerName)) {
-            return false; // no match
-        }
-
-        /* Check if this.member implies that.member */
-
-        if (that.member == null) {
-            // bottom is implied
-        } else if (this.member == null) {
-            // bottom implies nothing but itself
-            return false;
-        } else if (this.member.equals("*")) {
-            // wildcard implies everything (including itself)
-        } else if (this.member.equals(that.member)) {
-            // exact match
-        } else if (!Util.wildmatch(that.member,this.member)) {
-            return false; // no match
-        }
-
-        /* Check if this.objectName implies that.objectName */
-
-        if (that.objectName == null) {
-            // bottom is implied
-        } else if (this.objectName == null) {
-            // bottom implies nothing but itself
-            if (allnames == false) return false;
-        } else if (!this.objectName.apply(that.objectName)) {
-            /* ObjectName.apply returns false if that.objectName is a
-               wildcard so we also allow equals for that case.  This
-               never happens during real permission checks, but means
-               the implies relation is reflexive.  */
-            if (!this.objectName.equals(that.objectName))
-                return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * Checks two JMXNamespacePermission objects for equality. Checks
-     * that <i>obj</i> is an JMXNamespacePermission, and has the same
-     * name and actions as this object.
-     * <P>
-     * @param obj the object we are testing for equality with this object.
-     * @return true if obj is an JMXNamespacePermission, and has the
-     * same name and actions as this JMXNamespacePermission object.
-     */
-    public boolean equals(Object obj) {
-        if (obj == this)
-            return true;
-
-        if (! (obj instanceof JMXNamespacePermission))
-            return false;
-
-        JMXNamespacePermission that = (JMXNamespacePermission) obj;
-
-        return (this.mask == that.mask) &&
-            (this.getName().equals(that.getName()));
-    }
-
-    /**
-     * Deserialize this object based on its name and actions.
-     */
-    private void readObject(ObjectInputStream in)
-            throws IOException, ClassNotFoundException {
-        in.defaultReadObject();
-        parseName();
-        parseActions();
-    }
-}
--- a/src/share/classes/javax/management/namespace/JMXNamespaceView.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,300 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import java.io.IOException;
-import java.util.Set;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-/**
- * This class makes it possible to navigate easily within a hierarchical
- * namespace view.
- *
- * <pre>
- * MBeanServerConnnection rootConnection = ...;
- *
- * // create a view at the local root of the namespace hierarchy.
- * //
- * JMXNamespaceView view = new JMXNamespaceView(rootConnection);
- *
- * // list all top level namespaces
- * String[] list = view.list();
- *
- * // select one namespace from the list
- * String whereToGo = ... ;
- *
- * // go down to the selected namespace:
- * view = view.down(whereToGo);
- * System.out.println("I am now in: " + view.where());
- * System.out.println("I can see these MBeans:" +
- *    view.getMBeanServerConnection().queryNames(null,null));
- *
- * // list sub namespaces in current view ('whereToGo')
- * list = view.list();
- * System.out.println("Here are the sub namespaces of "+view.where()+": "+
- *                    Arrays.toString(list));
- *
- * // go up one level
- * view = view.up();
- * System.out.println("I am now back to: " +
- *    (view.isRoot() ? "root namespace" : view.where()));
- * </pre>
- * @since 1.7
- */
-public class JMXNamespaceView {
-
-    private static final ObjectName ALL_NAMESPACES;
-    static {
-        try {
-            ALL_NAMESPACES = ObjectName.getInstance("*" +
-                    JMXNamespaces.NAMESPACE_SEPARATOR + ":"+
-                    JMXNamespace.TYPE_ASSIGNMENT);
-        } catch (MalformedObjectNameException x) {
-            throw new ExceptionInInitializerError(x);
-        }
-    }
-    private static final int NAMESPACE_SEPARATOR_LENGTH =
-            JMXNamespaces.NAMESPACE_SEPARATOR.length();
-
-    private final JMXNamespaceView parent;
-    private final MBeanServerConnection here;
-    private final String where;
-
-    private static MBeanServerConnection checkRoot(MBeanServerConnection root) {
-        if (root == null)
-            throw new IllegalArgumentException(
-                    "namespaceRoot: null is not a valid value");
-        return root;
-    }
-
-    /**
-     * Creates a view at the top of a JMX namespace hierarchy.
-     * @param namespaceRoot The {@code MBeanServerConnection} at the
-     *        top of the hierarchy.
-     */
-    public JMXNamespaceView(MBeanServerConnection namespaceRoot) {
-        this(null,checkRoot(namespaceRoot),"");
-    }
-
-    // This constructor should remain private. A user can only create
-    // JMXNamespaceView at the top of the hierarchy.
-    // JMXNamespaceView sub nodes are created by their parent nodes.
-    private JMXNamespaceView(JMXNamespaceView parent,
-            MBeanServerConnection here, String where) {
-        this.parent = parent;
-        this.here   = here;
-        this.where  = where;
-    }
-
-    /**
-     * Returns the path leading to the namespace in this view, from
-     * the top of the hierarchy.
-     * @return The path to the namespace in this view.
-     */
-    public String where() {
-        return where;
-    }
-
-    /**
-     * Lists all direct sub namespaces in this view.  The returned strings
-     * do not contain the {@code //} separator.
-     *
-     * @return A list of direct sub name spaces accessible from this
-     *         namespace.
-     * @throws IOException if the attempt to list the namespaces fails because
-     * of a communication problem.
-     */
-    public String[] list() throws IOException {
-        final Set<ObjectName> names =
-                here.queryNames(ALL_NAMESPACES,null);
-        final String[] res = new String[names.size()];
-        int i = 0;
-        for (ObjectName dirName : names) {
-            final String dir = dirName.getDomain();
-            res[i++]=dir.substring(0,dir.length()-NAMESPACE_SEPARATOR_LENGTH);
-        }
-        return res;
-    }
-
-    /**
-     * Go down into a sub namespace.
-     * @param namespace the namespace to go down to.  It can contain one or
-     * more {@code //} separators, to traverse intermediate namespaces, but
-     * it must not begin or end with {@code //} or contain an empty
-     * intermediate namespace.  If it is the empty string, then {@code this} is
-     * returned.
-     * @return A view of the named sub namespace.
-     * @throws IllegalArgumentException if the {@code namespace} begins or
-     * ends with {@code //}.
-     */
-    public JMXNamespaceView down(String namespace) {
-        if (namespace.equals("")) return this;
-        if (namespace.startsWith(JMXNamespaces.NAMESPACE_SEPARATOR))
-            throw new IllegalArgumentException(namespace+": can't start with "+
-                    JMXNamespaces.NAMESPACE_SEPARATOR);
-
-        // This is a convenience to handle paths like xxx//yyy
-        final String[] elts =
-                namespace.split(JMXNamespaces.NAMESPACE_SEPARATOR);
-
-        // Go down the path, creating all sub namespaces along the way.
-        // Usually there will be a single element in the given namespace
-        // name, but we don't want to forbid things like
-        // down("xxx//yyy/www");
-        //
-        JMXNamespaceView previous = this;
-        String cursor = where;
-        for (String elt : elts) {
-            // empty path elements are not allowed. It means we
-            // had something like "xxx////yyy"
-            if (elt.equals(""))
-                throw new IllegalArgumentException(namespace+
-                        ": invalid path element");
-
-            // compute the "where" for the child.
-            cursor = JMXNamespaces.concat(cursor, elt);
-
-            // create the child...
-            final JMXNamespaceView next =
-                    makeJMXNamespaceView(root(), previous, cursor);
-
-            // the current child will be the parent of the next child...
-            previous = next;
-        }
-
-        // We return the last child that was created.
-        return previous;
-    }
-
-    /**
-     * Go back up one level. If this view is at the root of the
-     * hierarchy, returns {@code null}.
-     * @return A view of the parent namespace, or {@code null} if we're at
-     *         the root of the hierarchy.
-     */
-    public JMXNamespaceView up() {
-        return parent;
-    }
-
-    /**
-     * Tells whether this view is at the root of the hierarchy.
-     * @return {@code true} if this view is at the root of the hierachy.
-     */
-    public boolean isRoot() {
-        return parent == null;
-    }
-
-    /**
-     * Returns the view at the root of the hierarchy.
-     * If we are already at the root, this is {@code this}.
-     * @return the view at the root of the hierarchy.
-     */
-    public JMXNamespaceView root() {
-        if (parent == null) return this;
-        return parent.root();
-    }
-
-    /**
-     * A MBeanServerConnection to the namespace shown by this view.
-     * This is what would have been obtained by doing:
-     * <pre>
-     *   JMX.narrowToNamespace(this.root().getMBeanServerConnection(),
-     *       this.where());
-     * </pre>
-     * @return A MBeanServerConnection to the namespace shown by this view.
-     */
-    public MBeanServerConnection getMBeanServerConnection() {
-        return here;
-    }
-
-    /**
-     * <p>Get the name of the JMXNamespaceMBean handling the namespace shown by
-     * this view, relative to the root of the hierarchy.  If we are at the root
-     * of the hierarchy, this method returns {@code null}.</p>
-     *
-     * <p>You can use this method to make a proxy for the JMXNamespaceMBean
-     * as follows:</p>
-     *
-     * <pre>
-     * JMXNamespaceView view = ...;
-     * ObjectName namespaceMBeanName = view.getJMXNamespaceMBeanName();
-     * JMXNamespaceMBean namespaceMBean = JMX.newMBeanProxy(
-     *     view.root().getMBeanServerConnection(), namespaceMBeanName,
-     *     JMXNamespaceMBean.class);
-     * </pre>
-     *
-     * @return The name of the {@code JMXNamespaceMBean} handling the namespace
-     *         shown by this view, or {@code null}.
-     */
-    public ObjectName getJMXNamespaceMBeanName() {
-        if (parent == null)
-            return null;
-        else
-            return JMXNamespaces.getNamespaceObjectName(where);
-    }
-
-    @Override
-    public int hashCode() {
-        return where.hashCode();
-    }
-
-    /**
-     * Returns true if this object is equal to the given object.  The
-     * two objects are equal if the other object is also a {@code
-     * JMXNamespaceView} and both objects have the same {@linkplain #root root}
-     * MBeanServerConnection and the same {@linkplain #where path}.
-     * @param o the other object to compare to.
-     * @return true if both objects are equal.
-     */
-    @Override
-    public boolean equals(Object o) {
-        if (o==this) return true;
-        if (! (o instanceof JMXNamespaceView)) return false;
-        if (!where.equals(((JMXNamespaceView)o).where)) return false;
-        return root().getMBeanServerConnection().equals(
-                ((JMXNamespaceView)o).root().getMBeanServerConnection());
-    }
-
-    private JMXNamespaceView makeJMXNamespaceView(final JMXNamespaceView root,
-            final JMXNamespaceView directParent, final String pathFromRoot) {
-        if (pathFromRoot.equals("")) return root;
-
-        return new JMXNamespaceView(directParent,
-                narrowToNamespace(root.getMBeanServerConnection(),
-                pathFromRoot),pathFromRoot);
-    }
-
-    private MBeanServerConnection narrowToNamespace(MBeanServerConnection root,
-            String path) {
-        if (root instanceof MBeanServer)
-            return JMXNamespaces.narrowToNamespace((MBeanServer)root, path);
-        return JMXNamespaces.narrowToNamespace(root, path);
-    }
-
-}
--- a/src/share/classes/javax/management/namespace/JMXNamespaces.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,360 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.namespace.ObjectNameRouter;
-import com.sun.jmx.namespace.serial.RewritingProcessor;
-import com.sun.jmx.namespace.RoutingConnectionProxy;
-import com.sun.jmx.namespace.RoutingServerProxy;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-/**
- * Static constants and utility methods to help work with
- * JMX name spaces.  There are no instances of this class.
- * @since 1.7
- */
-public class JMXNamespaces {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-    /** Creates a new instance of JMXNamespaces */
-    private JMXNamespaces() {
-    }
-
-    /**
-     * The name space separator. This is an alias for {@link
-     * ObjectName#NAMESPACE_SEPARATOR}.
-     **/
-    public static final String NAMESPACE_SEPARATOR =
-            ObjectName.NAMESPACE_SEPARATOR;
-    private static final int NAMESPACE_SEPARATOR_LENGTH =
-            NAMESPACE_SEPARATOR.length();
-
-
-    /**
-     * Creates a new {@code MBeanServerConnection} proxy on a
-     * {@linkplain javax.management.namespace sub name space}
-     * of the given parent.
-     *
-     * @param parent The parent {@code MBeanServerConnection} that contains
-     *               the name space.
-     * @param namespace  The {@linkplain javax.management.namespace
-     *               name space} in which to narrow.
-     * @return A new {@code MBeanServerConnection} proxy that shows the content
-     *         of that name space.
-     * @throws IllegalArgumentException if either argument is null,
-     * or the name space does not exist, or if a proxy for that name space
-     * cannot be created.  The {@linkplain Throwable#getCause() cause} of
-     * this exception will be an {@link InstanceNotFoundException} if and only
-     * if the name space is found not to exist.
-     */
-    public static MBeanServerConnection narrowToNamespace(
-                        MBeanServerConnection parent,
-                        String namespace) {
-        if (LOG.isLoggable(Level.FINER))
-            LOG.finer("Making MBeanServerConnection for: " +namespace);
-        return RoutingConnectionProxy.cd(parent, namespace, true);
-    }
-
-    /**
-     * Creates a new {@code MBeanServer} proxy on a
-     * {@linkplain javax.management.namespace sub name space}
-     * of the given parent.
-     *
-     * @param parent The parent {@code MBeanServer} that contains
-     *               the name space.
-     * @param namespace  The {@linkplain javax.management.namespace
-     *               name space} in which to narrow.
-     * @return A new {@code MBeanServer} proxy that shows the content
-     *         of that name space.
-     * @throws IllegalArgumentException if either argument is null,
-     * or the name space does not exist, or if a proxy for that name space
-     * cannot be created.  The {@linkplain Throwable#getCause() cause} of
-     * this exception will be an {@link InstanceNotFoundException} if and only
-     * if the name space is found not to exist.
-     */
-    public static MBeanServer narrowToNamespace(MBeanServer parent,
-            String namespace) {
-        if (LOG.isLoggable(Level.FINER))
-            LOG.finer("Making MBeanServer for: " +namespace);
-        return RoutingServerProxy.cd(parent, namespace, true);
-    }
-
-    /**
-     * Returns an object that is the same as the given object except that
-     * any {@link ObjectName} it might contain has its domain modified.
-     * The returned object might be identical to the given object if it
-     * does not contain any {@code ObjectName} values or if none of them
-     * were modified.
-     * This method will replace a prefix ({@code toRemove}) from the path of
-     * the ObjectNames contained in {@code obj} by another prefix
-     * ({@code toAdd}).
-     * Therefore, all contained ObjectNames must have a path that start with
-     * the given {@code toRemove} prefix. If one of them doesn't, an {@link
-     * IllegalArgumentException} is thrown.
-     * <p>
-     * For instance, if {@code obj} contains the ObjectName
-     * {@code x//y//z//d:k=x}, and {@code toAdd} is {@code v//w}, and
-     * {@code toRemove}
-     *  is {@code x//y} this method will return a copy of {@code obj} that
-     * contains {@code v//w//z//d:k=x}.<br>
-     * On the other hand, if {@code obj} contains the ObjectName
-     * {@code x//y//z//d:k=x}, and {@code toAdd} is {@code v//w}, and
-     * {@code toRemove} is {@code v} this method
-     * will raise an exception, because {@code x//y//z//d:k=x} doesn't start
-     * with {@code v}
-     * </p>
-     * <p>Note: the default implementation of this method can use the
-     *   Java serialization framework to clone and replace ObjectNames in the
-     *   provided {@code obj}. It will usually fail if {@code obj} is not
-     *   Java serializable, or contains objects which are not Java
-     *   serializable.
-     * </p>
-     * @param obj    The object to deep-rewrite
-     * @param toRemove a prefix already present in contained ObjectNames.
-     *        If {@code toRemove} is the empty string {@code ""}, nothing
-     *        will be removed from the contained ObjectNames.
-     * @param toAdd the prefix that will replace (@code toRemove} in contained
-     *  ObjectNames.
-     *        If {@code toAdd} is the empty string {@code ""}, nothing
-     *        will be added to the contained ObjectNames.
-     * @return the rewritten object, or possibly {@code obj} if nothing needed
-     * to be changed.
-     * @throws IllegalArgumentException if {@code obj} couldn't be rewritten or
-     * if {@code toRemove} or {@code toAdd} is null.
-     **/
-    public static <T> T deepReplaceHeadNamespace(T obj, String toRemove, String toAdd) {
-        final RewritingProcessor processor =
-                RewritingProcessor.newRewritingProcessor(toAdd,toRemove);
-        return processor.rewriteOutput(obj);
-    }
-
-    /**
-     * Appends {@code namespace} to {@code path}.
-     * This methods appends {@code namespace} to {@code path} to obtain a
-     * a <i>full path</i>, and normalizes the result thus obtained:
-     * <ul>
-     * <li>If {@code path} is empty, the full path is
-     *     {@code namespace}.</li>
-     * <li>Otherwise, if {@code namespace} is empty,
-     *     the full path is {@code path}</li>
-     * <li>Otherwise, and this is the regular case, the full path is the
-     *     result of the concatenation of
-     *     {@code path}+{@value #NAMESPACE_SEPARATOR}+{@code namespace}</li>
-     * <li>finally, the full path is normalized: multiple consecutive
-     *     occurrences of {@value #NAMESPACE_SEPARATOR} are replaced by a
-     *     single {@value #NAMESPACE_SEPARATOR} in the result, and trailing
-     *     occurences of {@value #NAMESPACE_SEPARATOR} are removed.
-     * </li>
-     * </ul>
-     * @param path a name space path prefix
-     * @param namespace a name space name to append to the path
-     * @return a syntactically valid name space path, or "" if both parameters
-     * are null or empty.
-     * @throws IllegalArgumentException if either argument is null or ends with
-     * an odd number of {@code /} characters.
-     **/
-    public static String concat(String path, String namespace) {
-        if (path == null || namespace == null)
-            throw new IllegalArgumentException("Null argument");
-        checkTrailingSlashes(path);
-        checkTrailingSlashes(namespace);
-        final String result;
-        if (path.equals("")) result=namespace;
-        else if (namespace.equals("")) result=path;
-        else result=path+NAMESPACE_SEPARATOR+namespace;
-        return ObjectNameRouter.normalizeNamespacePath(result,false,true,false);
-    }
-
-    /**
-     * Returns a syntactically valid name space path.
-     * If the provided {@code namespace} ends with {@code "//"},
-     * recursively strips trailing {@code "//"}.  Each sequence of an
-     * even number of {@code "/"} characters is also replaced by {@code "//"},
-     * for example {@code "foo//bar////baz/////buh"} will become
-     * {@code "foo//bar//baz///buh"}.
-     *
-     * @param namespace A name space path
-     * @return {@code ""} - if the provided {@code namespace} resolves to
-     * the empty string; otherwise a syntactically valid name space string
-     * stripped of trailing and redundant {@code "//"}.
-     * @throws IllegalArgumentException if {@code namespace} is null or
-     * is not syntactically valid (e.g. it contains
-     * invalid characters like ':', or it ends with an odd
-     * number of '/').
-     */
-    public static String normalizeNamespaceName(String namespace) {
-        if (namespace == null)
-            throw new IllegalArgumentException("Null namespace");
-        final String sourcePath =
-                ObjectNameRouter.normalizeNamespacePath(namespace,false,true,false);
-        if (sourcePath.equals("")) return sourcePath;
-
-        // Will throw an IllegalArgumentException if the namespace name
-        // is not syntactically valid...
-        //
-        getNamespaceObjectName(sourcePath);
-        return sourcePath;
-    }
-
-
-    /**
-     * Return a canonical handler name for the provided {@code namespace},
-     * The handler name returned will be
-     * {@link #normalizeNamespaceName normalizeNamespaceName}{@code (namespace) +
-     * "//:type=JMXNamespace"}.
-     *
-     * @param namespace A name space path
-     * @return a canonical ObjectName for a name space handler.
-     * @see #normalizeNamespaceName
-     * @throws IllegalArgumentException if the provided
-     *          {@code namespace} is null or not valid.
-     */
-    public static ObjectName getNamespaceObjectName(String namespace) {
-        if (namespace == null || namespace.equals(""))
-            throw new IllegalArgumentException("Null or empty namespace");
-        final String sourcePath =
-                ObjectNameRouter.normalizeNamespacePath(namespace,false,
-                            true,false);
-        try {
-            // We could use ObjectName.valueOf here - but throwing an
-            // IllegalArgumentException that contains just the supplied
-            // namespace instead of the whole ObjectName seems preferable.
-            return ObjectName.getInstance(sourcePath+
-                    NAMESPACE_SEPARATOR+":"+
-                    JMXNamespace.TYPE_ASSIGNMENT);
-        } catch (MalformedObjectNameException x) {
-            throw new IllegalArgumentException("Invalid namespace: " +
-                                               namespace,x);
-        }
-    }
-
-    /**
-     * Returns an ObjectName pattern that can be used to query for all MBeans
-     * contained in the given name space.
-     * For instance, if {@code namespace="foo//bar"}, this method will
-     * return {@code "foo//bar//*:*"}
-     * @return an ObjectName pattern that selects all MBeans in the given
-     *         name space.
-     **/
-    public static ObjectName getWildcardFor(String namespace) {
-            return insertPath(namespace,ObjectName.WILDCARD);
-    }
-
-
-    /**
-     * Returns an ObjectName that can be used to access an MBean
-     * contained in the given name space.
-     * For instance, if {@code path="foo//bar"}, and
-     * {@code to="domain:type=Thing"} this method will
-     * return {@code "foo//bar//domain:type=Thing"}
-     * @return an ObjectName that can be used to invoke an MBean located in a
-     *         sub name space.
-     * @throws IllegalArgumentException if {@code path} ends with an
-     * odd number of {@code /} characters.
-     **/
-    public static ObjectName insertPath(String path, ObjectName to) {
-        if (path == null || to == null)
-            throw new IllegalArgumentException("Null argument");
-        checkTrailingSlashes(path);
-        String prefix = path;
-        if (!prefix.equals(""))
-            prefix = ObjectNameRouter.normalizeNamespacePath(
-                        prefix + NAMESPACE_SEPARATOR,false,false,false);
-         return to.withDomain(
-                    ObjectNameRouter.normalizeDomain(
-                        prefix+to.getDomain(),false));
-    }
-
-    /**
-     * Returns the normalized name space path of the name space expected to
-     * contain {@code ObjectName}.
-     * For instance, for {@code "foo//domain:type=Thing"} this will be
-     * {@code "foo"}. For {@code "//foo//bar//domain:type=Thing"} this will be
-     * {@code "foo//bar"}. For {@code //foo//bar//baz//domain:type=Thing}
-     * this will be {@code "foo//bar//baz"}. For
-     * {@code //foo//bar//baz//:type=JMXNamespace}
-     * this will be {@code "foo//bar"}.
-     *
-     * @param name an {@code ObjectName}
-     * @return the name space path of the name space that could contain such
-     *         a name. If {@code name} has no name space, returns {@code ""}.
-     * @throws IllegalArgumentException if {@code name} is null.
-     **/
-    public static String getContainingNamespace(ObjectName name) {
-        return getNormalizedPath(name,true);
-    }
-
-
-    static String getNormalizedPath(ObjectName name,
-            boolean removeLeadingSep) {
-        if (name == null)
-            throw new IllegalArgumentException("Null name");
-        String domain =
-                ObjectNameRouter.normalizeDomain(name.getDomain(),removeLeadingSep);
-        int end = domain.length();
-
-        // special case of domain part being a single '/'
-        //
-        if (domain.endsWith(NAMESPACE_SEPARATOR+"/"))
-            return domain.substring(0,end-NAMESPACE_SEPARATOR_LENGTH-1);
-
-        // special case of namespace handler
-        //
-        if (domain.endsWith(NAMESPACE_SEPARATOR))
-            domain = domain.substring(0,end-NAMESPACE_SEPARATOR_LENGTH);
-
-        int last = domain.lastIndexOf(NAMESPACE_SEPARATOR);
-        if (last < 0) return "";
-        if (last == 0) return domain;
-
-        // special case of domain part starting with '/'
-        // last=0 is not possible - we took care of this above.
-        if (domain.charAt(last-1) == '/') last--;
-
-        return domain.substring(0,last);
-    }
-
-    private static void checkTrailingSlashes(String path) {
-        int i;
-        for (i = path.length() - 1; i >= 0 && path.charAt(i) == '/'; i--)
-            continue;
-        if (path.length() - i % 2 == 0)
-            throw new IllegalArgumentException("Path ends with odd number of /");
-    }
-}
--- a/src/share/classes/javax/management/namespace/JMXRemoteNamespace.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,809 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.mbeanserver.Util;
-import com.sun.jmx.remote.util.EnvHelp;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.AttributeChangeNotification;
-
-import javax.management.ClientContext;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServerConnection;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.remote.JMXConnectionNotification;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * A {@link JMXNamespace} that will connect to a remote MBeanServer
- * by creating a {@link javax.management.remote.JMXConnector} from a
- * {@link javax.management.remote.JMXServiceURL}.
- * <p>
- * You can call {@link #connect() connect()} and {@link #close close()}
- * several times. This MBean will emit an {@link AttributeChangeNotification}
- * when the value of its {@link #isConnected Connected} attribute changes.
- * </p>
- * <p>
- * The JMX Remote Namespace MBean is not connected until {@link
- * #connect() connect()} is explicitly called. The usual sequence of code to
- * create a JMX Remote Namespace is thus:
- * </p>
- * <pre>
- *     final String namespace = "mynamespace";
- *     final ObjectName name = {@link JMXNamespaces#getNamespaceObjectName
- *       JMXNamespaces.getNamespaceObjectName(namespace)};
- *     final JMXServiceURL remoteServerURL = .... ;
- *     final Map<String,Object> optionsMap = .... ;
- *     final MBeanServer masterMBeanServer = .... ;
- *     final JMXRemoteNamespace namespaceMBean = {@link #newJMXRemoteNamespace
- *        JMXRemoteNamespace.newJMXRemoteNamespace(remoteServerURL, optionsMap)};
- *     masterMBeanServer.registerMBean(namespaceMBean, name);
- *     namespaceMBean.connect();
- *     // or: masterMBeanServer.invoke(name, {@link #connect() "connect"}, null, null);
- * </pre>
- * <p>
- * The JMX Remote Namespace MBean will register for {@linkplain
- * JMXConnectionNotification JMX Connection Notifications} with its underlying
- * {@link JMXConnector}. When a JMX Connection Notification indicates that
- * the underlying connection has failed, the JMX Remote Namespace MBean
- * closes its underlying connector and switches its {@link #isConnected
- * Connected} attribute to false, emitting an {@link
- * AttributeChangeNotification}.
- * </p>
- * <p>
- * At this point, a managing application (or an administrator connected
- * through a management console) can attempt to reconnect the
- * JMX Remote Namespace MBean by calling its {@link #connect() connect()} method
- * again.
- * </p>
- * <p>Note that when the connection with the remote namespace fails, or when
- *    {@link #close} is called, then any notification subscription to
- *    MBeans registered in that namespace will be lost - unless a custom
- *    {@linkplain javax.management.event event service} supporting connection-less
- *    mode was used.
- * </p>
- * @since 1.7
- */
-public class JMXRemoteNamespace
-        extends JMXNamespace
-        implements JMXRemoteNamespaceMBean, NotificationEmitter {
-
-    /**
-     * A logger for this class.
-     */
-    private static final Logger LOG = JmxProperties.NAMESPACE_LOGGER;
-
-
-    // This connection listener is used to listen for connection events from
-    // the underlying JMXConnector. It is used in particular to maintain the
-    // "connected" state in this MBean.
-    //
-    private class ConnectionListener implements NotificationListener {
-        private ConnectionListener() {
-        }
-        public void handleNotification(Notification notification,
-                Object handback) {
-            if (!(notification instanceof JMXConnectionNotification))
-                return;
-            final JMXConnectionNotification cn =
-                    (JMXConnectionNotification)notification;
-            final String type = cn.getType();
-            if (JMXConnectionNotification.CLOSED.equals(type)
-                    || JMXConnectionNotification.FAILED.equals(type)) {
-                checkState(this,cn,(JMXConnector)handback);
-            }
-        }
-    }
-
-    // When the JMXRemoteNamespace is originally created, it is not connected,
-    // which means that the source MBeanServer should be one that throws
-    // exceptions for most methods.  When it is subsequently connected,
-    // the methods should be forwarded to the MBeanServerConnection.
-    // We handle this using MBeanServerConnectionWrapper.  The
-    // MBeanServerConnection that is supplied to the constructor of
-    // MBeanServerConnectionWrapper is ignored (and in fact it is null)
-    // because the one that is actually used is the one supplied by the
-    // override of getMBeanServerConnection().
-    private static class JMXRemoteNamespaceDelegate
-            extends MBeanServerConnectionWrapper {
-        private volatile JMXRemoteNamespace parent=null;
-
-        JMXRemoteNamespaceDelegate() {
-            super(null,null);
-        }
-        @Override
-        public MBeanServerConnection getMBeanServerConnection() {
-            return parent.getMBeanServerConnection();
-        }
-        @Override
-        public ClassLoader getDefaultClassLoader() {
-            return parent.getDefaultClassLoader();
-        }
-
-        // Because this class is instantiated in the super() call from the
-        // constructor of JMXRemoteNamespace, it cannot be an inner class.
-        // This method achieves the effect that an inner class would have
-        // had, of giving the class a reference to the outer "this".
-        synchronized void initParentOnce(JMXRemoteNamespace parent) {
-            if (this.parent != null)
-                throw new UnsupportedOperationException("parent already set");
-            this.parent=parent;
-
-        }
-
-    }
-
-    private static final MBeanNotificationInfo connectNotification =
-        new MBeanNotificationInfo(new String[] {
-            AttributeChangeNotification.ATTRIBUTE_CHANGE},
-            "Connected",
-            "Emitted when the Connected state of this object changes");
-
-    private static AtomicLong seqNumber = new AtomicLong(0);
-
-    private final NotificationBroadcasterSupport broadcaster;
-    private final ConnectionListener listener;
-    private final JMXServiceURL jmxURL;
-    private final Map<String,?> optionsMap;
-
-    private volatile MBeanServerConnection server = null;
-    private volatile JMXConnector conn = null;
-    private volatile ClassLoader defaultClassLoader = null;
-
-    /**
-     * Creates a new instance of {@code JMXRemoteNamespace}.
-     * <p>
-     * This constructor is provided for subclasses.
-     * To create a new instance of {@code JMXRemoteNamespace} call
-     * {@link #newJMXRemoteNamespace
-     *  JMXRemoteNamespace.newJMXRemoteNamespace(sourceURL, optionsMap)}.
-     * </p>
-     * @param sourceURL a JMX service URL that can be used to {@linkplain
-     *        #connect() connect} to the
-     *        source MBean Server. The source MBean Server is the remote
-     *        MBean Server which contains the MBeans that will be mirrored
-     *        in this namespace.
-     * @param optionsMap the options map that will be passed to the
-     *        {@link JMXConnectorFactory} when {@linkplain
-     *        JMXConnectorFactory#newJMXConnector creating} the
-     *        {@link JMXConnector} used to {@linkplain #connect() connect}
-     *        to the remote source MBean Server.  Can be null, which is
-     *        equivalent to an empty map.
-     * @see #newJMXRemoteNamespace JMXRemoteNamespace.newJMXRemoteNamespace
-     * @see #connect
-     */
-    protected JMXRemoteNamespace(JMXServiceURL sourceURL,
-            Map<String,?> optionsMap) {
-         super(new JMXRemoteNamespaceDelegate());
-        ((JMXRemoteNamespaceDelegate)super.getSourceServer()).
-                initParentOnce(this);
-
-        // URL must not be null.
-        if (sourceURL == null)
-            throw new IllegalArgumentException("Null URL");
-        this.jmxURL     = sourceURL;
-        this.broadcaster =
-            new NotificationBroadcasterSupport(connectNotification);
-
-        // handles options
-        this.optionsMap = unmodifiableMap(optionsMap);
-
-        // handles (dis)connection events
-        this.listener = new ConnectionListener();
-    }
-
-    // returns un unmodifiable view of a map.
-    private static <K,V> Map<K,V> unmodifiableMap(Map<K,V> aMap) {
-        if (aMap == null || aMap.isEmpty())
-            return Collections.emptyMap();
-        return Collections.unmodifiableMap(aMap);
-    }
-
-   /**
-    * Returns the {@code JMXServiceURL} that is (or will be) used to
-    * connect to the remote name space. <p>
-    * @see #connect
-    * @return The {@code JMXServiceURL} used to connect to the remote
-    *         name space.
-    */
-    public JMXServiceURL getJMXServiceURL() {
-        return jmxURL;
-    }
-
-    /**
-    * In this class, this method never returns {@code null}, and the
-    * address returned is the {@link  #getJMXServiceURL JMXServiceURL}
-    * that is used by  this object to {@linkplain #connect} to the remote
-    * name space. <p>
-    * This behaviour might be overriden by subclasses, if needed.
-    * For instance, a subclass might want to return {@code null} if it
-    * doesn't want to expose that JMXServiceURL.
-    */
-    public JMXServiceURL getAddress() {
-        return getJMXServiceURL();
-    }
-
-    private Map<String,?> getEnvMap() {
-        return optionsMap;
-    }
-
-    public void addNotificationListener(NotificationListener listener,
-            NotificationFilter filter, Object handback) {
-        broadcaster.addNotificationListener(listener, filter, handback);
-    }
-
-    /**
-     * A subclass that needs to send its own notifications must override
-     * this method in order to return an {@link MBeanNotificationInfo
-     * MBeanNotificationInfo[]} array containing both its own notification
-     * infos and the notification infos of its super class. <p>
-     * The implementation should probably look like:
-     * <pre>
-     *      final MBeanNotificationInfo[] myOwnNotifs = { .... };
-     *      final MBeanNotificationInfo[] parentNotifs =
-     *            super.getNotificationInfo();
-     *      final Set<MBeanNotificationInfo> mergedResult =
-     *            new HashSet<MBeanNotificationInfo>();
-     *      mergedResult.addAll(Arrays.asList(myOwnNotifs));
-     *      mergedResult.addAll(Arrays.asList(parentNotifs));
-     *      return mergeResult.toArray(
-     *             new MBeanNotificationInfo[mergedResult.size()]);
-     * </pre>
-     */
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return broadcaster.getNotificationInfo();
-    }
-
-    public void removeNotificationListener(NotificationListener listener)
-    throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener);
-    }
-
-    public void removeNotificationListener(NotificationListener listener,
-            NotificationFilter filter, Object handback)
-            throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener, filter, handback);
-    }
-
-    private static long getNextSeqNumber() {
-        return seqNumber.getAndIncrement();
-    }
-
-
-    /**
-     * Sends a notification to registered listeners. Before the notification
-     * is sent, the following steps are performed:
-     * <ul><li>
-     * If {@code n.getSequenceNumber() <= 0} set it to the next available
-     * sequence number.</li>
-     * <li>If {@code n.getSource() == null}, set it to the value returned by {@link
-     * #getObjectName getObjectName()}.
-     * </li></ul>
-     * <p>This method can be called by subclasses in order to send their own
-     *    notifications.
-     *    In that case, these subclasses might also need to override
-     *    {@link #getNotificationInfo} in order to declare their own
-     *    {@linkplain MBeanNotificationInfo notification types}.
-     * </p>
-     * @param n The notification to send to registered listeners.
-     * @see javax.management.NotificationBroadcasterSupport
-     * @see #getNotificationInfo
-     **/
-    protected void sendNotification(Notification n) {
-        if (n.getSequenceNumber()<=0)
-            n.setSequenceNumber(getNextSeqNumber());
-        if (n.getSource()==null)
-            n.setSource(getObjectName());
-        broadcaster.sendNotification(n);
-    }
-
-    private void checkState(ConnectionListener listener,
-                            JMXConnectionNotification cn,
-                            JMXConnector emittingConnector) {
-
-        // Due to the asynchronous handling of notifications, it is
-        // possible that this method is called for a JMXConnector
-        // (or connection) which is already closed and replaced by a newer
-        // one.
-        //
-        // This method attempts to determine the real state of the
-        // connection - which might be different from what the notification
-        // says.
-        //
-        // This is quite complex logic - because we try not to hold any
-        // lock while evaluating the true value of the connected state,
-        // while anyone might also call close() or connect() from a
-        // different thread.
-        // The method switchConnection() (called from here too) also has the
-        // same kind of complex logic:
-        //
-        // We use the JMXConnector has a handback to the notification listener
-        // (emittingConnector) in order to be able to determine whether the
-        // notification concerns the current connector in use, or an older
-        // one. The 'emittingConnector' is the connector from which the
-        // notification originated. This could be an 'old' connector - as
-        // closed() and connect() could already have been called before the
-        // notification arrived. So what we do is to compare the
-        // 'emittingConnector' with the current connector, to see if the
-        // notification actually comes from the curent connector.
-        //
-        boolean remove = false;
-
-        // whether the emittingConnector is already 'removed'
-        synchronized (this) {
-            if (this.conn != emittingConnector ||
-                    JMXConnectionNotification.FAILED.equals(cn.getType()))
-                remove = true;
-        }
-
-        // We need to unregister our listener from this 'removed' connector.
-        // This is the only place where we remove the listener.
-        //
-        if (remove) {
-            try {
-                // This may fail if the connector is already closed.
-                // But better unregister anyway...
-                //
-                emittingConnector.removeConnectionNotificationListener(
-                        listener,null,
-                        emittingConnector);
-            } catch (Exception x) {
-                LOG.log(Level.FINE,
-                        "Failed to unregister connection listener"+x);
-                LOG.log(Level.FINEST,
-                        "Failed to unregister connection listener",x);
-            }
-            try {
-                // This may fail if the connector is already closed.
-                // But better call close twice and get an exception than
-                // leaking...
-                //
-                emittingConnector.close();
-            } catch (Exception x) {
-                LOG.log(Level.FINEST,
-                        "Failed to close old connector " +
-                        "(failure was expected): "+x);
-            }
-        }
-
-        // Now we checked whether our current connector is still alive.
-        //
-        boolean closed = false;
-        final JMXConnector thisconn = this.conn;
-        try {
-            if (thisconn != null)
-                thisconn.getConnectionId();
-        } catch (IOException x) {
-            LOG.finest("Connector already closed: "+x);
-            closed = true;
-        }
-
-        // We got an IOException - the connector is not connected.
-        // Need to forget it and switch our state to closed.
-        //
-        if (closed) {
-            switchConnection(thisconn,null,null);
-            try {
-                // Usually this will fail... Better call close twice
-                // and get an exception than leaking...
-                //
-                if (thisconn != emittingConnector || !remove)
-                    thisconn.close();
-            } catch (IOException x) {
-                LOG.log(Level.FINEST,
-                        "Failed to close connector (failure was expected): "
-                        +x);
-            }
-        }
-    }
-
-    private final void switchConnection(JMXConnector oldc,
-                                   JMXConnector newc,
-                                   MBeanServerConnection mbs) {
-        boolean connect = false;
-        boolean close   = false;
-        synchronized (this) {
-            if (oldc != conn) {
-                if (newc != null) {
-                    try {
-                        newc.close();
-                    } catch (IOException x) {
-                        LOG.log(Level.FINEST,
-                                "Failed to close connector",x);
-                    }
-                }
-                return;
-            }
-            if (conn == null && newc != null) connect=true;
-            if (newc == null && conn != null) close = true;
-            conn = newc;
-            server = mbs;
-        }
-        if (connect || close) {
-            boolean oldstate = close;
-            boolean newstate = connect;
-            final ObjectName myName = getObjectName();
-
-            // In the uncommon case where the MBean is connected before
-            // being registered, myName can be null...
-            // If myName is null - we use 'this' as the source instead...
-            //
-            final Object source = (myName==null)?this:myName;
-            final AttributeChangeNotification acn =
-                    new AttributeChangeNotification(source,
-                    getNextSeqNumber(),System.currentTimeMillis(),
-                    String.valueOf(source)+
-                    (newstate?" connected":" closed"),
-                    "Connected",
-                    "boolean",
-                    Boolean.valueOf(oldstate),
-                    Boolean.valueOf(newstate));
-            sendNotification(acn);
-        }
-    }
-
-    private void close(JMXConnector c) {
-        try {
-            if (c != null) c.close();
-        } catch (Exception x) {
-            // OK: we're gonna throw the original exception later.
-            LOG.finest("Ignoring exception when closing connector: "+x);
-        }
-    }
-
-    private JMXConnector connect(JMXServiceURL url, Map<String,?> env)
-            throws IOException {
-        final JMXConnector c = newJMXConnector(url, env);
-        c.connect(env);
-        return c;
-    }
-
-    /**
-     * <p>Creates a new JMXConnector with the specified {@code url} and
-     * {@code env} options map.  The default implementation of this method
-     * returns {@link JMXConnectorFactory#newJMXConnector
-     * JMXConnectorFactory.newJMXConnector(jmxURL, env)}.  Subclasses can
-     * override this method to customize behavior.</p>
-     *
-     * @param url  The JMXServiceURL of the remote server.
-     * @param optionsMap An options map that will be passed to the
-     *        {@link JMXConnectorFactory} when {@linkplain
-     *        JMXConnectorFactory#newJMXConnector creating} the
-     *        {@link JMXConnector} that can connect to the remote source
-     *        MBean Server.
-     * @return A JMXConnector to use to connect to the remote server
-     * @throws IOException if the connector could not be created.
-     * @see JMXConnectorFactory#newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map)
-     * @see #JMXRemoteNamespace
-     */
-    protected JMXConnector newJMXConnector(JMXServiceURL url,
-            Map<String,?> optionsMap) throws IOException {
-        return JMXConnectorFactory.newJMXConnector(jmxURL, optionsMap);
-    }
-
-    /**
-     * <p>Called when a new connection is established using {@link #connect}
-     * so that subclasses can customize the connection.  The default
-     * implementation of this method effectively does the following:</p>
-     *
-     * <pre>
-     * MBeanServerConnection mbsc = {@link JMXConnector#getMBeanServerConnection()
-     *                               jmxc.getMBeanServerConnection()};
-     * try {
-     *     return {@link ClientContext#withDynamicContext
-     *             ClientContext.withDynamicContext(mbsc)};
-     * } catch (IllegalArgumentException e) {
-     *     return mbsc;
-     * }
-     * </pre>
-     *
-     * <p>In other words, it arranges for the client context to be forwarded
-     * to the remote MBean Server if the remote MBean Server supports contexts;
-     * otherwise it ignores the client context.</p>
-     *
-     * <h4>Example: connecting to a remote namespace</h4>
-     *
-     * <p>A subclass that wanted to narrow into a namespace of
-     * the remote MBeanServer might look like this:</p>
-     *
-     * <pre>
-     * class JMXRemoteSubNamespace extends JMXRemoteNamespace {
-     *     private final String subnamespace;
-     *
-     *     JMXRemoteSubNamespace(
-     *             JMXServiceURL url, Map{@code <String, ?>} env, String subnamespace) {
-     *        super(url, env);
-     *        this.subnamespace = subnamespace;
-     *     }
-     *
-     *     {@code @Override}
-     *     protected MBeanServerConnection getMBeanServerConnection(
-     *             JMXConnector jmxc) throws IOException {
-     *         MBeanServerConnection mbsc = super.getMBeanServerConnection(jmxc);
-     *         return {@link JMXNamespaces#narrowToNamespace(MBeanServerConnection,String)
-     *                 JMXNamespaces.narrowToNamespace(mbsc, subnamespace)};
-     *     }
-     * }
-     * </pre>
-     *
-     * <h4>Example: using the Event Service for notifications</h4>
-     *
-     * <p>Some connectors may have been designed to work with an earlier
-     * version of the JMX API, and may not have been upgraded to use
-     * the {@linkplain javax.management.event Event Service} defined in
-     * this version of the JMX API.  In that case, and if the remote
-     * server to which this JMXRemoteNamespace connects also contains
-     * namespaces, it may be necessary to configure explicitly an {@linkplain
-     * javax.management.event.EventClientDelegate#newForwarder Event Client
-     * Forwarder} on the remote server side, and to force the use of an {@link
-     * EventClient} on this client side.</p>
-     *
-     * <p>A subclass of {@link JMXRemoteNamespace} can provide an
-     * implementation of {@code getMBeanServerConnection} that will force
-     * notification subscriptions to flow through an {@link EventClient} over
-     * a legacy protocol.  It can do so by overriding this method in the
-     * following way:</p>
-     *
-     * <pre>
-     * class JMXRemoteEventClientNamespace extends JMXRemoteNamespace {
-     *     JMXRemoteEventClientNamespace(JMXServiceURL url, {@code Map<String,?>} env) {
-     *         super(url, env);
-     *     }
-     *
-     *     {@code @Override}
-     *     protected MBeanServerConnection getMBeanServerConnection(JMXConnector jmxc)
-     *             throws IOException {
-     *         MBeanServerConnection mbsc = super.getMBeanServerConnection(jmxc);
-     *         return EventClient.getEventClientConnection(mbsc);
-     *     }
-     * }
-     * </pre>
-     *
-     * <p>
-     * Note that the remote server also needs to provide an {@link
-     * javax.management.event.EventClientDelegateMBean}: configuring only
-     * the client side (this object) is not enough.</p>
-     *
-     * <p>In summary, this technique should be used if the remote server
-     * supports JMX namespaces, but uses a JMX Connector Server whose
-     * implementation does not transparently use the new Event Service
-     * (as would be the case with the JMXMPConnectorServer implementation
-     * from the reference implementation of the JMX Remote API 1.0
-     * specification).</p>
-     *
-     * @param jmxc the newly-created {@code JMXConnector}.
-     *
-     * @return an {@code MBeanServerConnection} connected to the remote
-     * MBeanServer.
-     *
-     * @throws IOException if the connection cannot be made.  If this method
-     * throws {@code IOException} then the calling {@link #connect()} method
-     * will also fail with an {@code IOException}.
-     *
-     * @see #connect
-     */
-    protected MBeanServerConnection getMBeanServerConnection(JMXConnector jmxc)
-            throws IOException {
-        final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
-        try {
-            return ClientContext.withDynamicContext(mbsc);
-        } catch (IllegalArgumentException e) {
-            LOG.log(Level.FINER, "ClientContext.withDynamicContext", e);
-            return mbsc;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The sequence of events when this method is called includes,
-     * effectively, the following code:</p>
-     *
-     * <pre>
-     * JMXServiceURL url = {@link #getJMXServiceURL getJMXServiceURL}();
-     * JMXConnector jmxc = {@link #newJMXConnector newJMXConnector}(url, env);
-     * jmxc.connect();
-     * MBeanServerConnection mbsc = {@link #getMBeanServerConnection(JMXConnector)
-     *                               getMBeanServerConnection}(jmxc);
-     * </pre>
-     *
-     * <p>Here, {@code env} is a {@code Map} containing the entries from the
-     * {@code optionsMap} that was passed to the {@linkplain #JMXRemoteNamespace
-     * constructor} or to the {@link #newJMXRemoteNamespace newJMXRemoteNamespace}
-     * factory method.</p>
-     *
-     * <p>Subclasses can customize connection behavior by overriding the
-     * {@code getJMXServiceURL}, {@code newJMXConnector}, or
-     * {@code getMBeanServerConnection} methods.</p>
-     */
-    public void connect() throws IOException {
-        LOG.fine("connecting...");
-        final Map<String,Object> env =
-                new HashMap<String,Object>(getEnvMap());
-        try {
-            // XXX: We should probably document this...
-            // This allows to specify a loader name - which will be
-            // retrieved from the parent MBeanServer.
-            defaultClassLoader =
-                EnvHelp.resolveServerClassLoader(env,getMBeanServer());
-        } catch (InstanceNotFoundException x) {
-            final IOException io =
-                    new IOException("ClassLoader not found");
-            io.initCause(x);
-            throw io;
-        }
-        env.put(JMXConnectorFactory.DEFAULT_CLASS_LOADER,defaultClassLoader);
-        final JMXServiceURL url = getJMXServiceURL();
-        final JMXConnector aconn = connect(url,env);
-        final MBeanServerConnection msc;
-        try {
-            msc = getMBeanServerConnection(aconn);
-            aconn.addConnectionNotificationListener(listener,null,aconn);
-        } catch (IOException io) {
-            close(aconn);
-            throw io;
-        } catch (RuntimeException x) {
-            close(aconn);
-            throw x;
-        }
-
-        switchConnection(conn,aconn,msc);
-
-        LOG.fine("connected.");
-    }
-
-    public void close() throws IOException {
-        if (conn == null) return;
-        LOG.fine("closing...");
-        // System.err.println(toString()+": closing...");
-        conn.close();
-        // System.err.println(toString()+": connector closed");
-        switchConnection(conn,null,null);
-        LOG.fine("closed.");
-        // System.err.println(toString()+": closed");
-    }
-
-    MBeanServerConnection getMBeanServerConnection() {
-        if (conn == null)
-            throw newRuntimeIOException("getMBeanServerConnection: not connected");
-        return server;
-    }
-
-    // Better than throwing UndeclaredThrowableException ...
-    private RuntimeException newRuntimeIOException(String msg) {
-        final IllegalStateException illegal = new IllegalStateException(msg);
-        return Util.newRuntimeIOException(new IOException(msg,illegal));
-    }
-
-    /**
-     * Returns the default class loader used by the underlying
-     * {@link JMXConnector}.
-     * @return the default class loader used when communicating with the
-     *         remote source MBean server.
-     **/
-    ClassLoader getDefaultClassLoader() {
-        if (conn == null)
-            throw newRuntimeIOException("getMBeanServerConnection: not connected");
-        return defaultClassLoader;
-    }
-
-    public boolean isConnected() {
-        // This is a pleonasm
-        return (conn != null) && (server != null);
-    }
-
-
-    /**
-     * This name space handler will automatically {@link #close} its
-     * connection with the remote source in {@code preDeregister}.
-     **/
-    @Override
-    public void preDeregister() throws Exception {
-        try {
-            close();
-        } catch (IOException x) {
-            LOG.fine("Failed to close properly - exception ignored: " + x);
-            LOG.log(Level.FINEST,
-                    "Failed to close properly - exception ignored",x);
-        }
-        super.preDeregister();
-    }
-
-   /**
-    * This method calls {@link
-    * javax.management.MBeanServerConnection#getMBeanCount
-    * getMBeanCount()} on the remote namespace.
-    * @throws java.io.IOException if an {@link IOException} is raised when
-    *         communicating with the remote source namespace.
-    */
-    @Override
-    public Integer getMBeanCount() throws IOException {
-        return getMBeanServerConnection().getMBeanCount();
-    }
-
-   /**
-    * This method returns the result of calling {@link
-    * javax.management.MBeanServerConnection#getDomains
-    * getDomains()} on the remote namespace.
-    * @throws java.io.IOException if an {@link IOException} is raised when
-    *         communicating with the remote source namespace.
-    */
-    @Override
-   public String[] getDomains() throws IOException {
-       return getMBeanServerConnection().getDomains();
-    }
-
-   /**
-    * This method returns the result of calling {@link
-    * javax.management.MBeanServerConnection#getDefaultDomain
-    * getDefaultDomain()} on the remote namespace.
-    * @throws java.io.IOException if an {@link IOException} is raised when
-    *         communicating with the remote source namespace.
-    */
-    @Override
-    public String getDefaultDomain() throws IOException {
-        return getMBeanServerConnection().getDefaultDomain();
-    }
-
-    /**
-     * Creates a new instance of {@code JMXRemoteNamespace}.
-     * @param sourceURL a JMX service URL that can be used to connect to the
-     *        source MBean Server. The source MBean Server is the remote
-     *        MBean Server which contains the MBeans that will be mirrored
-     *        in this namespace.
-     * @param optionsMap An options map that will be passed to the
-     *        {@link JMXConnectorFactory} when {@linkplain
-     *        JMXConnectorFactory#newJMXConnector creating} the
-     *        {@link JMXConnector} used to connect to the remote source
-     *        MBean Server.  Can be null, which is equivalent to an empty map.
-     * @see #JMXRemoteNamespace JMXRemoteNamespace(sourceURL,optionsMap)
-     * @see JMXConnectorFactory#newJMXConnector(javax.management.remote.JMXServiceURL, java.util.Map)
-     */
-     public static JMXRemoteNamespace newJMXRemoteNamespace(
-             JMXServiceURL sourceURL,
-             Map<String,?> optionsMap) {
-         return new JMXRemoteNamespace(sourceURL, optionsMap);
-     }
-}
--- a/src/share/classes/javax/management/namespace/JMXRemoteNamespaceMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import java.io.IOException;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * A {@link JMXNamespaceMBean} that will connect to a remote MBeanServer
- * by creating a {@link javax.management.remote.JMXConnector} from a
- * {@link javax.management.remote.JMXServiceURL}.
- * You can call {@link #connect connect()} and {@link #close close()}
- * several times.
- * @since 1.7
- */
-public interface JMXRemoteNamespaceMBean
-        extends JMXNamespaceMBean {
-
-    /**
-     * Connects to the underlying remote source name space, if not already
-     * {@link #isConnected connected}.
-     * If connected, do nothing. Otherwise, creates a new connector from the
-     * {@link javax.management.remote.JMXServiceURL JMXServiceURL} provided at
-     * creation time, and connects to the remote source name space.
-     * <p>
-     * The source MBeans will not appear in the target name space until the
-     * JMXRemoteNamespaceMBean is connected.
-     * </p><p>
-     * It is possible to call {@code connect()}, {@link #close close()}, and
-     * {@code connect()} again.
-     * However, closing the connection with the remote name space may cause
-     * notification listeners to be lost, unless the client explicitly uses
-     * the new {@linkplain javax.management.event JMX event service}.
-     * </p><p>
-     * @throws IOException if connection to the remote source name space fails.
-     * @see #isConnected isConnected
-     **/
-    public void connect()
-        throws IOException;
-
-    /**
-     * Closes the connection with the remote source name space.
-     * If the connection is already closed, do nothing.
-     * Otherwise, closes the underlying {@link
-     * javax.management.remote.JMXConnector}.
-     * <p>Once closed, it is possible to reopen the connection by
-     * calling {@link #connect connect}.
-     * </p>
-     * @throws IOException if the connection to the remote source name space
-     *         can't be closed properly.
-     * @see #isConnected isConnected
-     **/
-    public void close()
-        throws IOException;
-
-    /**
-     * Tells whether the connection to the remote source name space is opened.
-     * @see #connect connect
-     * @see #close close
-     * @return {@code true} if connected.
-     **/
-    public boolean isConnected();
-
-    /**
-     * Returns the {@link JMXServiceURL} address that points to the remote name
-     * space mirrored by this {@link JMXNamespaceMBean JMXNamespace MBean},
-     * if available.
-     * @return The {@link JMXServiceURL} address that points to the remote name
-     * space mirrored by this {@link JMXNamespaceMBean JMXNamespace MBean},
-     * or {@code null}.
-     */
-    public JMXServiceURL getAddress();
-}
--- a/src/share/classes/javax/management/namespace/MBeanServerConnectionWrapper.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,702 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import com.sun.jmx.mbeanserver.Util;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Set;
-
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.OperationsException;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.loading.ClassLoaderRepository;
-
-/**
- * <p>An object of this class implements the MBeanServer interface
- * and, for each of its methods forwards the request to a wrapped
- * {@link MBeanServerConnection} object.
- * Some methods of the {@link MBeanServer} interface do not have
- * any equivalent in {@link MBeanServerConnection}. In that case, an
- * {@link UnsupportedOperationException} will be thrown.
- *
- * <p>A typical use of this class is to apply a {@link QueryExp} object locally,
- * on an MBean that resides in a remote MBeanServer. Since an
- * MBeanServerConnection is not an MBeanServer, it cannot be passed
- * to the <code>setMBeanServer()</code> method of the {@link QueryExp}
- * object. However, this object can.</p>
- *
- * @since 1.7
- */
-public class MBeanServerConnectionWrapper
-        implements MBeanServer {
-
-    private final MBeanServerConnection wrapped;
-    private final ClassLoader defaultCl;
-
-    /**
-     * Construct a new object that implements {@link MBeanServer} by
-     * forwarding its methods to the given {@link MBeanServerConnection}.
-     * This constructor is equivalent to {@link #MBeanServerConnectionWrapper(
-     * MBeanServerConnection, ClassLoader) MBeanServerConnectionWrapper(wrapped,
-     * null)}.
-     *
-     * @param wrapped the {@link MBeanServerConnection} to which methods
-     * are to be forwarded.  This parameter can be null, in which case the
-     * {@code MBeanServerConnection} will typically be supplied by overriding
-     * {@link #getMBeanServerConnection}.
-     */
-    public MBeanServerConnectionWrapper(MBeanServerConnection wrapped) {
-        this(wrapped, null);
-    }
-
-    /**
-     * Construct a new object that implements {@link MBeanServer} by
-     * forwarding its methods to the given {@link MBeanServerConnection}.
-     * The {@code defaultCl} parameter specifies the value to be returned
-     * by {@link #getDefaultClassLoader}.  A null value is equivalent to
-     * {@link Thread#getContextClassLoader()}.
-     *
-     * @param wrapped the {@link MBeanServerConnection} to which methods
-     * are to be forwarded.  This parameter can be null, in which case the
-     * {@code MBeanServerConnection} will typically be supplied by overriding
-     * {@link #getMBeanServerConnection}.
-     * @param defaultCl the value to be returned by {@link
-     * #getDefaultClassLoader}.  A null value is equivalent to the current
-     * thread's {@linkplain Thread#getContextClassLoader()}.
-     */
-    public MBeanServerConnectionWrapper(MBeanServerConnection wrapped,
-            ClassLoader defaultCl) {
-        this.wrapped = wrapped;
-        this.defaultCl = (defaultCl == null) ?
-            Thread.currentThread().getContextClassLoader() : defaultCl;
-    }
-
-    /**
-     * Returns an MBeanServerConnection. This method is called each time
-     * an operation must be invoked on the underlying MBeanServerConnection.
-     * The default implementation returns the MBeanServerConnection that
-     * was supplied to the constructor of this MBeanServerConnectionWrapper.
-     **/
-    protected MBeanServerConnection getMBeanServerConnection() {
-        return wrapped;
-    }
-
-    /**
-     * Returns the default class loader passed to the constructor.  If the
-     * value passed was null, then the returned value will be the
-     * {@linkplain Thread#getContextClassLoader() context class loader} at the
-     * time this object was constructed.
-     *
-     * @return the ClassLoader that was passed to the constructor.
-     **/
-    public ClassLoader getDefaultClassLoader() {
-        return defaultCl;
-    }
-
-    /**
-     * <p>This method is called each time an IOException is raised when
-     * trying to forward an operation to the underlying
-     * MBeanServerConnection, as a result of calling
-     * {@link #getMBeanServerConnection()} or as a result of invoking the
-     * operation on the returned connection.  Since the methods in
-     * {@link MBeanServer} are not declared to throw {@code IOException},
-     * this method must return a {@code RuntimeException} to be thrown
-     * instead.  Typically, the original {@code IOException} will be in the
-     * {@linkplain Throwable#getCause() cause chain} of the {@code
-     * RuntimeException}.</p>
-     *
-     * <p>Subclasses may redefine this method if they need to perform any
-     * specific handling of IOException (logging etc...).</p>
-     *
-     * @param x The raised IOException.
-     * @param method The name of the method in which the exception was
-     *        raised. This is one of the methods of the MBeanServer
-     *        interface.
-     *
-     * @return A RuntimeException that should be thrown by the caller.
-     *         In this default implementation, this is a
-     *         {@link RuntimeException} wrapping <var>x</var>.
-     **/
-    protected RuntimeException wrapIOException(IOException x, String method) {
-        return Util.newRuntimeIOException(x);
-    }
-
-    // Take care of getMBeanServerConnection returning null.
-    //
-    private synchronized MBeanServerConnection connection()
-        throws IOException {
-        final MBeanServerConnection c = getMBeanServerConnection();
-        if (c == null)
-            throw new IOException("MBeanServerConnection unavailable");
-        return c;
-    }
-
-    //--------------------------------------------
-    //--------------------------------------------
-    //
-    // Implementation of the MBeanServer interface
-    //
-    //--------------------------------------------
-    //--------------------------------------------
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void addNotificationListener(ObjectName name,
-                                        NotificationListener listener,
-                                        NotificationFilter filter,
-                                        Object handback)
-        throws InstanceNotFoundException {
-        try {
-            connection().addNotificationListener(name, listener,
-                                                 filter, handback);
-        } catch (IOException x) {
-            throw wrapIOException(x,"addNotificationListener");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void addNotificationListener(ObjectName name,
-                                        ObjectName listener,
-                                        NotificationFilter filter,
-                                        Object handback)
-        throws InstanceNotFoundException {
-        try {
-            connection().addNotificationListener(name, listener,
-                                                 filter, handback);
-        } catch (IOException x) {
-            throw wrapIOException(x,"addNotificationListener");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public ObjectInstance createMBean(String className, ObjectName name)
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException {
-        try {
-            return connection().createMBean(className, name);
-        } catch (IOException x) {
-            throw wrapIOException(x,"createMBean");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                      Object params[], String signature[])
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException {
-        try {
-            return connection().createMBean(className, name,
-                                            params, signature);
-        } catch (IOException x) {
-            throw wrapIOException(x,"createMBean");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public ObjectInstance createMBean(String className,
-                                      ObjectName name,
-                                      ObjectName loaderName)
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException,
-        InstanceNotFoundException {
-        try {
-            return connection().createMBean(className, name, loaderName);
-        } catch (IOException x) {
-            throw wrapIOException(x,"createMBean");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public ObjectInstance createMBean(String className,
-                                      ObjectName name,
-                                      ObjectName loaderName,
-                                      Object params[],
-                                      String signature[])
-        throws
-        ReflectionException,
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        MBeanException,
-        NotCompliantMBeanException,
-        InstanceNotFoundException {
-        try {
-            return connection().createMBean(className, name, loaderName,
-                                            params, signature);
-        } catch (IOException x) {
-            throw wrapIOException(x,"createMBean");
-        }
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     * @deprecated see {@link MBeanServer#deserialize(ObjectName,byte[])
-     *                 MBeanServer}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(ObjectName name, byte[] data)
-        throws InstanceNotFoundException, OperationsException {
-        throw new UnsupportedOperationException("deserialize");
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     * @deprecated see {@link MBeanServer#deserialize(String,byte[])
-     *                 MBeanServer}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className, byte[] data)
-        throws OperationsException, ReflectionException {
-        throw new UnsupportedOperationException("deserialize");
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     * @deprecated see {@link MBeanServer#deserialize(String,ObjectName,byte[])
-     *                 MBeanServer}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className,
-                                         ObjectName loaderName,
-                                         byte[] data)
-        throws
-        InstanceNotFoundException,
-        OperationsException,
-        ReflectionException {
-        throw new UnsupportedOperationException("deserialize");
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public Object getAttribute(ObjectName name, String attribute)
-        throws
-        MBeanException,
-        AttributeNotFoundException,
-        InstanceNotFoundException,
-        ReflectionException {
-        try {
-            return connection().getAttribute(name, attribute);
-        } catch (IOException x) {
-            throw wrapIOException(x,"getAttribute");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public AttributeList getAttributes(ObjectName name, String[] attributes)
-        throws InstanceNotFoundException, ReflectionException {
-        try {
-            return connection().getAttributes(name, attributes);
-        } catch (IOException x) {
-            throw wrapIOException(x,"getAttributes");
-        }
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     */
-    public ClassLoader getClassLoader(ObjectName loaderName)
-        throws InstanceNotFoundException {
-        throw new UnsupportedOperationException("getClassLoader");
-    }
-
-    /**
-     * Returns the {@linkplain #getDefaultClassLoader() default class loader}.
-     * This behavior can be changed by subclasses.
-     */
-    public ClassLoader getClassLoaderFor(ObjectName mbeanName)
-        throws InstanceNotFoundException {
-        return getDefaultClassLoader();
-    }
-
-    /**
-     * <p>Returns a {@link ClassLoaderRepository} based on the class loader
-     * returned by {@link #getDefaultClassLoader()}.</p>
-     * @return a {@link ClassLoaderRepository} that contains a single
-     *         class loader, returned by {@link #getDefaultClassLoader()}.
-     **/
-    public ClassLoaderRepository getClassLoaderRepository() {
-        // We return a new ClassLoaderRepository each time this method is
-        // called. This is by design, because there's no guarantee that
-        // getDefaultClassLoader() will always return the same class loader.
-        return Util.getSingleClassLoaderRepository(getDefaultClassLoader());
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public String getDefaultDomain() {
-        try {
-            return connection().getDefaultDomain();
-        } catch (IOException x) {
-            throw wrapIOException(x,"getDefaultDomain");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public String[] getDomains() {
-        try {
-            return connection().getDomains();
-        } catch (IOException x) {
-            throw wrapIOException(x,"getDomains");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public Integer getMBeanCount() {
-        try {
-            return connection().getMBeanCount();
-        } catch (IOException x) {
-            throw wrapIOException(x,"getMBeanCount");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public MBeanInfo getMBeanInfo(ObjectName name)
-        throws
-        InstanceNotFoundException,
-        IntrospectionException,
-        ReflectionException {
-        try {
-            return connection().getMBeanInfo(name);
-        } catch (IOException x) {
-            throw wrapIOException(x,"getMBeanInfo");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public ObjectInstance getObjectInstance(ObjectName name)
-        throws InstanceNotFoundException {
-        try {
-            return connection().getObjectInstance(name);
-        } catch (IOException x) {
-            throw wrapIOException(x,"getObjectInstance");
-        }
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     */
-    public Object instantiate(String className)
-        throws ReflectionException, MBeanException {
-        throw new UnsupportedOperationException("instantiate");
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     */
-    public Object instantiate(String className,
-                              Object params[],
-                              String signature[])
-        throws ReflectionException, MBeanException {
-        throw new UnsupportedOperationException("instantiate");
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     */
-    public Object instantiate(String className, ObjectName loaderName)
-        throws ReflectionException, MBeanException,
-               InstanceNotFoundException {
-        throw new UnsupportedOperationException("instantiate");
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     */
-    public Object instantiate(String className, ObjectName loaderName,
-                              Object params[], String signature[])
-        throws ReflectionException, MBeanException,
-               InstanceNotFoundException {
-        throw new UnsupportedOperationException("instantiate");
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public Object invoke(ObjectName name, String operationName,
-                         Object params[], String signature[])
-        throws
-        InstanceNotFoundException,
-        MBeanException,
-        ReflectionException {
-        try {
-            return connection().invoke(name,operationName,params,signature);
-        } catch (IOException x) {
-            throw wrapIOException(x,"invoke");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public boolean isInstanceOf(ObjectName name, String className)
-        throws InstanceNotFoundException {
-        try {
-            return connection().isInstanceOf(name, className);
-        } catch (IOException x) {
-            throw wrapIOException(x,"isInstanceOf");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public boolean isRegistered(ObjectName name) {
-        try {
-            return connection().isRegistered(name);
-        } catch (IOException x) {
-            throw wrapIOException(x,"isRegistered");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     * If an IOException is raised, returns an empty Set.
-     */
-    public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
-        try {
-            return connection().queryMBeans(name, query);
-        } catch (IOException x) {
-            throw wrapIOException(x,"queryMBeans");
-            //return Collections.emptySet();
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     * If an IOException is raised, returns an empty Set.
-     */
-    public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-        try {
-            return connection().queryNames(name, query);
-        } catch (IOException x) {
-            throw wrapIOException(x,"queryNames");
-            //return Collections.emptySet();
-        }
-    }
-
-    /**
-     * Throws an {@link UnsupportedOperationException}. This behavior can
-     * be changed by subclasses.
-     */
-    public ObjectInstance registerMBean(Object object, ObjectName name)
-        throws
-        InstanceAlreadyExistsException,
-        MBeanRegistrationException,
-        NotCompliantMBeanException {
-        throw new UnsupportedOperationException("registerMBean");
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void removeNotificationListener(ObjectName name,
-                                           NotificationListener listener)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            connection().removeNotificationListener(name, listener);
-        } catch (IOException x) {
-            throw wrapIOException(x,"removeNotificationListener");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void removeNotificationListener(ObjectName name,
-                                           NotificationListener listener,
-                                           NotificationFilter filter,
-                                           Object handback)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            connection().removeNotificationListener(name, listener,
-                                                    filter, handback);
-        } catch (IOException x) {
-            throw wrapIOException(x,"removeNotificationListener");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void removeNotificationListener(ObjectName name,
-                                           ObjectName listener)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            connection().removeNotificationListener(name, listener);
-        } catch (IOException x) {
-            throw wrapIOException(x,"removeNotificationListener");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void removeNotificationListener(ObjectName name,
-                                           ObjectName listener,
-                                           NotificationFilter filter,
-                                           Object handback)
-        throws InstanceNotFoundException, ListenerNotFoundException {
-        try {
-            connection().removeNotificationListener(name, listener,
-                                                    filter, handback);
-        } catch (IOException x) {
-            throw wrapIOException(x,"removeNotificationListener");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void setAttribute(ObjectName name, Attribute attribute)
-        throws
-        InstanceNotFoundException,
-        AttributeNotFoundException,
-        InvalidAttributeValueException,
-        MBeanException,
-        ReflectionException {
-        try {
-            connection().setAttribute(name, attribute);
-        } catch (IOException x) {
-            throw wrapIOException(x,"setAttribute");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public AttributeList setAttributes(ObjectName name,
-                                       AttributeList attributes)
-        throws InstanceNotFoundException, ReflectionException {
-        try {
-            return connection().setAttributes(name, attributes);
-        } catch (IOException x) {
-            throw wrapIOException(x,"setAttributes");
-        }
-    }
-
-    /**
-     * Forward this method to the
-     * wrapped object.
-     */
-    public void unregisterMBean(ObjectName name)
-        throws InstanceNotFoundException, MBeanRegistrationException {
-        try {
-            connection().unregisterMBean(name);
-        } catch (IOException x) {
-            throw wrapIOException(x,"unregisterMBean");
-        }
-    }
-
-    //----------------
-    // PRIVATE METHODS
-    //----------------
-
-}
--- a/src/share/classes/javax/management/namespace/MBeanServerSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1321 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import com.sun.jmx.defaults.JmxProperties;
-import com.sun.jmx.mbeanserver.Util;
-import java.io.ObjectInputStream;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.DynamicWrapperMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMRuntimeException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.OperationsException;
-import javax.management.QueryEval;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.RuntimeOperationsException;
-import javax.management.loading.ClassLoaderRepository;
-
-/**
- * <p>Base class for custom implementations of the {@link MBeanServer}
- * interface. The commonest use of this class is as the {@linkplain
- * JMXNamespace#getSourceServer() source server} for a {@link
- * JMXNamespace}, although this class can be used anywhere an {@code
- * MBeanServer} instance is required. Note that the usual ways to
- * obtain an {@code MBeanServer} instance are either to use {@link
- * java.lang.management.ManagementFactory#getPlatformMBeanServer()
- * ManagementFactory.getPlatformMBeanServer()} or to use the {@code
- * newMBeanServer} or {@code createMBeanServer} methods from {@link
- * javax.management.MBeanServerFactory MBeanServerFactory}. {@code
- * MBeanServerSupport} is for certain cases where those are not
- * appropriate.</p>
- *
- * <p>There are two main use cases for this class: <a
- * href="#special-purpose">special-purpose MBeanServer implementations</a>,
- * and <a href="#virtual">namespaces containing Virtual MBeans</a>. The next
- * sections explain these use cases.</p>
- *
- * <p>In the simplest case, a subclass needs to implement only two methods:</p>
- *
- * <ul>
- *     <li>
- *         {@link #getNames getNames} which returns the name of
- *         all MBeans handled by this {@code MBeanServer}.
- *     </li>
- *     <li>
- *         {@link #getDynamicMBeanFor getDynamicMBeanFor} which returns a
- *         {@link DynamicMBean} that can be used to invoke operations and
- *         obtain meta data (MBeanInfo) on a given MBean.
- *     </li>
- * </ul>
- *
- * <p>Subclasses can create such {@link DynamicMBean} MBeans on the fly - for
- * instance, using the class {@link javax.management.StandardMBean}, just for
- * the duration of an MBeanServer method call.</p>
- *
- * <h4 id="special-purpose">Special-purpose MBeanServer implementations</h4>
- *
- * <p>In some cases
- * the general-purpose {@code MBeanServer} that you get from
- * {@link javax.management.MBeanServerFactory MBeanServerFactory} is not
- * appropriate.  You might need different security checks, or you might
- * want a mock {@code MBeanServer} suitable for use in tests, or you might
- * want a simplified and optimized {@code MBeanServer} for a special purpose.</p>
- *
- * <p>As an example of a special-purpose {@code MBeanServer}, the class {@link
- * javax.management.QueryNotificationFilter QueryNotificationFilter} constructs
- * an {@code MBeanServer} instance every time it filters a notification,
- * with just one MBean that represents the notification. Although it could
- * use {@code MBeanServerFactory.newMBeanServer}, a special-purpose {@code
- * MBeanServer} will be quicker to create, use less memory, and have simpler
- * methods that execute faster.</p>
- *
- * <p>Here is an example of a special-purpose {@code MBeanServer}
- * implementation that contains exactly one MBean, which is specified at the
- * time of creation.</p>
- *
- * <pre>
- * public class SingletonMBeanServer extends MBeanServerSupport {
- *     private final ObjectName objectName;
- *     private final DynamicMBean mbean;
- *
- *     public SingletonMBeanServer(ObjectName objectName, DynamicMBean mbean) {
- *         this.objectName = objectName;
- *         this.mbean = mbean;
- *     }
- *
- *     &#64;Override
- *     protected {@code Set<ObjectName>} {@link #getNames getNames}() {
- *         return Collections.singleton(objectName);
- *     }
- *
- *     &#64;Override
- *     public DynamicMBean {@link #getDynamicMBeanFor
- *                                getDynamicMBeanFor}(ObjectName name)
- *             throws InstanceNotFoundException {
- *         if (objectName.equals(name))
- *             return mbean;
- *         else
- *             throw new InstanceNotFoundException(name);
- *     }
- * }
- * </pre>
- *
- * <p>Using this class, you could make an {@code MBeanServer} that contains
- * a {@link javax.management.timer.Timer Timer} MBean like this:</p>
- *
- * <pre>
- *     Timer timer = new Timer();
- *     DynamicMBean mbean = new {@link javax.management.StandardMBean
- *                                     StandardMBean}(timer, TimerMBean.class);
- *     ObjectName name = new ObjectName("com.example:type=Timer");
- *     MBeanServer timerMBS = new SingletonMBeanServer(name, mbean);
- * </pre>
- *
- * <p>When {@code getDynamicMBeanFor} always returns the same object for the
- * same name, as here, notifications work in the expected way: if the object
- * is a {@link NotificationEmitter} then listeners can be added using
- * {@link MBeanServer#addNotificationListener(ObjectName, NotificationListener,
- * NotificationFilter, Object) MBeanServer.addNotificationListener}.  If
- * {@code getDynamicMBeanFor} does not always return the same object for the
- * same name, more work is needed to make notifications work, as described
- * <a href="#notifs">below</a>.</p>
- *
- * <h4 id="virtual">Namespaces containing Virtual MBeans</h4>
- *
- * <p>Virtual MBeans are MBeans that do not exist as Java objects,
- * except transiently while they are being accessed.  This is useful when
- * there might be very many of them, or when keeping track of their creation
- * and deletion might be expensive or hard.  For example, you might have one
- * MBean per system process.  With an ordinary {@code MBeanServer}, you would
- * have to list the system processes in order to create an MBean object for
- * each one, and you would have to track the arrival and departure of system
- * processes in order to create or delete the corresponding MBeans.  With
- * Virtual MBeans, you only need the MBean for a given process at the exact
- * point where it is referenced with a call such as
- * {@link MBeanServer#getAttribute MBeanServer.getAttribute}.</p>
- *
- * <p>Here is an example of an {@code MBeanServer} implementation that has
- * one MBean for every system property.  The system property {@code "java.home"}
- * is represented by the MBean called {@code
- * com.example:type=Property,name="java.home"}, with an attribute called
- * {@code Value} that is the value of the property.</p>
- *
- * <pre>
- * public interface PropertyMBean {
- *     public String getValue();
- * }
- *
- * <a name="PropsMBS"></a>public class PropsMBS extends MBeanServerSupport {
- *     public static class PropertyImpl implements PropertyMBean {
- *         private final String name;
- *
- *         public PropertyImpl(String name) {
- *             this.name = name;
- *         }
- *
- *         public String getValue() {
- *             return System.getProperty(name);
- *         }
- *     }
- *
- *     &#64;Override
- *     public DynamicMBean {@link #getDynamicMBeanFor
- *                                getDynamicMBeanFor}(ObjectName name)
- *             throws InstanceNotFoundException {
- *
- *         // Check that the name is a legal one for a Property MBean
- *         ObjectName namePattern = ObjectName.valueOf(
- *                     "com.example:type=Property,name=\"*\"");
- *         if (!namePattern.apply(name))
- *             throw new InstanceNotFoundException(name);
- *
- *         // Extract the name of the property that the MBean corresponds to
- *         String propName = ObjectName.unquote(name.getKeyProperty("name"));
- *         if (System.getProperty(propName) == null)
- *             throw new InstanceNotFoundException(name);
- *
- *         // Construct and return a transient MBean object
- *         PropertyMBean propMBean = new PropertyImpl(propName);
- *         return new StandardMBean(propMBean, PropertyMBean.class, false);
- *     }
- *
- *     &#64;Override
- *     protected {@code Set<ObjectName>} {@link #getNames getNames}() {
- *         {@code Set<ObjectName> names = new TreeSet<ObjectName>();}
- *         Properties props = System.getProperties();
- *         for (String propName : props.stringPropertyNames()) {
- *             ObjectName objectName = ObjectName.valueOf(
- *                     "com.example:type=Property,name=" +
- *                     ObjectName.quote(propName));
- *             names.add(objectName);
- *         }
- *         return names;
- *     }
- * }
- * </pre>
- *
- * <p id="virtual-notif-example">Because the {@code getDynamicMBeanFor} method
- * returns a different object every time it is called, the default handling
- * of notifications will not work, as explained <a href="#notifs">below</a>.
- * In this case it does not matter, because the object returned by {@code
- * getDynamicMBeanFor} is not a {@code NotificationEmitter}, so {@link
- * MBeanServer#addNotificationListener(ObjectName, NotificationListener,
- * NotificationFilter, Object) MBeanServer.addNotificationListener} will
- * always fail. But if we wanted to extend {@code PropsMBS} so that the MBean
- * for property {@code "foo"} emitted a notification every time that property
- * changed, we would need to do it as shown below. (Because there is no API to
- * be informed when a property changes, this code assumes that some other code
- * calls the {@code propertyChanged} method every time a property changes.)</p>
- *
- * <pre>
- * public class PropsMBS {
- *     ...as <a href="#PropsMBS">above</a>...
- *
- *     private final {@link VirtualEventManager} vem = new VirtualEventManager();
- *
- *     &#64;Override
- *     public NotificationEmitter {@link #getNotificationEmitterFor
- *                                       getNotificationEmitterFor}(
- *             ObjectName name) throws InstanceNotFoundException {
- *         getDynamicMBeanFor(name);  // check that the name is valid
- *         return vem.{@link VirtualEventManager#getNotificationEmitterFor
- *                           getNotificationEmitterFor}(name);
- *     }
- *
- *     public void propertyChanged(String name, String newValue) {
- *         ObjectName objectName = ObjectName.valueOf(
- *                 "com.example:type=Property,name=" + ObjectName.quote(name));
- *         Notification n = new Notification(
- *                 "com.example.property.changed", objectName, 0L,
- *                 "Property " + name + " changed");
- *         n.setUserData(newValue);
- *         vem.{@link VirtualEventManager#publish publish}(objectName, n);
- *     }
- * }
- * </pre>
- *
- * <h4 id="creation">MBean creation and deletion</h4>
- *
- * <p>MBean creation through {@code MBeanServer.createMBean} is disabled
- * by default. Subclasses which need to support MBean creation
- * through {@code createMBean} need to implement a single method {@link
- * #createMBean(String, ObjectName, ObjectName, Object[], String[],
- * boolean)}.</p>
- *
- * <p>Similarly MBean registration and unregistration through {@code
- * registerMBean} and {@code unregisterMBean} are disabled by default.
- * Subclasses which need to support MBean registration and
- * unregistration will need to implement {@link #registerMBean registerMBean}
- * and {@link #unregisterMBean unregisterMBean}.</p>
- *
- * <h4 id="notifs">Notifications</h4>
- *
- * <p>By default {@link MBeanServer#addNotificationListener(ObjectName,
- * NotificationListener, NotificationFilter, Object) addNotificationListener}
- * is accepted for an MBean <em>{@code name}</em> if {@link #getDynamicMBeanFor
- * getDynamicMBeanFor}<code>(<em>name</em>)</code> returns an object that is a
- * {@link NotificationEmitter}.  That is appropriate if
- * {@code getDynamicMBeanFor}<code>(<em>name</em>)</code> always returns the
- * same object for the same <em>{@code name}</em>.  But with
- * Virtual MBeans, every call to {@code getDynamicMBeanFor} returns a new object,
- * which is discarded as soon as the MBean request has finished.
- * So a listener added to that object would be immediately forgotten.</p>
- *
- * <p>The simplest way for a subclass that defines Virtual MBeans
- * to support notifications is to create a private {@link VirtualEventManager}
- * and override the method {@link
- * #getNotificationEmitterFor getNotificationEmitterFor} as follows:</p>
- *
- * <pre>
- *     private final VirtualEventManager vem = new VirtualEventManager();
- *
- *     &#64;Override
- *     public NotificationEmitter getNotificationEmitterFor(
- *             ObjectName name) throws InstanceNotFoundException {
- *         // Check that the name is a valid Virtual MBean.
- *         // This is the easiest way to do that, but not always the
- *         // most efficient:
- *         getDynamicMBeanFor(name);
- *
- *         // Return an object that supports add/removeNotificationListener
- *         // through the VirtualEventManager.
- *         return vem.getNotificationEmitterFor(name);
- *     }
- * </pre>
- *
- * <p>A notification <em>{@code n}</em> can then be sent from the Virtual MBean
- * called <em>{@code name}</em> by calling {@link VirtualEventManager#publish
- * vem.publish}<code>(<em>name</em>, <em>n</em>)</code>.  See the example
- * <a href="#virtual-notif-example">above</a>.</p>
- *
- * @since 1.7
- */
-public abstract class MBeanServerSupport implements MBeanServer {
-
-    /**
-     * A logger for this class.
-     */
-    private static final Logger LOG =
-            JmxProperties.NAMESPACE_LOGGER;
-
-    /**
-     * <p>Make a new {@code MBeanServerSupport} instance.</p>
-     */
-    protected MBeanServerSupport() {
-    }
-
-    /**
-     * <p>Returns a dynamically created handle that makes it possible to
-     * access the named MBean for the duration of a method call.</p>
-     *
-     * <p>An easy way to create such a {@link DynamicMBean} handle is, for
-     * instance, to create a temporary MXBean instance and to wrap it in
-     * an instance of
-     * {@link javax.management.StandardMBean}.
-     * This handle should remain valid for the duration of the call
-     * but can then be discarded.</p>
-     * @param name the name of the MBean for which a request was received.
-     * @return a {@link DynamicMBean} handle that can be used to invoke
-     * operations on the named MBean.
-     * @throws InstanceNotFoundException if no such MBean is supposed
-     *         to exist.
-     */
-    public abstract DynamicMBean getDynamicMBeanFor(ObjectName name)
-                        throws InstanceNotFoundException;
-
-    /**
-     * <p>Subclasses should implement this method to return
-     * the names of all MBeans handled by this object instance.</p>
-     *
-     * <p>The object returned by getNames() should be safely {@linkplain
-     * Set#iterator iterable} even in the presence of other threads that may
-     * cause the set of names to change. Typically this means one of the
-     * following:</p>
-     *
-     * <ul>
-     * <li>the returned set of names is always the same; or
-     * <li>the returned set of names is an object such as a {@link
-     * java.util.concurrent.CopyOnWriteArraySet CopyOnWriteArraySet} that is
-     * safely iterable even if the set is changed by other threads; or
-     * <li>a new Set is constructed every time this method is called.
-     * </ul>
-     *
-     * @return the names of all MBeans handled by this object.
-     */
-    protected abstract Set<ObjectName> getNames();
-
-    /**
-     * <p>List names matching the given pattern.
-     * The default implementation of this method calls {@link #getNames()}
-     * and returns the subset of those names matching {@code pattern}.</p>
-     *
-     * @param pattern an ObjectName pattern
-     * @return the list of MBean names that match the given pattern.
-     */
-    protected Set<ObjectName> getMatchingNames(ObjectName pattern) {
-        return Util.filterMatchingNames(pattern, getNames());
-    }
-
-    /**
-     * <p>Returns a {@link NotificationEmitter} which can be used to
-     * subscribe or unsubscribe for notifications with the named
-     * mbean.</p>
-     *
-     * <p>The default implementation of this method calls {@link
-     * #getDynamicMBeanFor getDynamicMBeanFor(name)} and returns that object
-     * if it is a {@code NotificationEmitter}, otherwise null. See <a
-     * href="#notifs">above</a> for further discussion of notification
-     * handling.</p>
-     *
-     * @param name The name of the MBean whose notifications are being
-     * subscribed, or unsuscribed.
-     *
-     * @return A {@link NotificationEmitter} that can be used to subscribe or
-     * unsubscribe for notifications emitted by the named MBean, or {@code
-     * null} if the MBean does not emit notifications and should not be
-     * considered as a {@code NotificationEmitter}.
-     *
-     * @throws InstanceNotFoundException if {@code name} is not the name of
-     * an MBean in this {@code MBeanServer}.
-     */
-    public NotificationEmitter getNotificationEmitterFor(ObjectName name)
-            throws InstanceNotFoundException {
-        DynamicMBean mbean = getDynamicMBeanFor(name);
-        if (mbean instanceof NotificationEmitter)
-            return (NotificationEmitter) mbean;
-        else
-            return null;
-    }
-
-    private NotificationEmitter getNonNullNotificationEmitterFor(
-            ObjectName name)
-            throws InstanceNotFoundException {
-        NotificationEmitter emitter = getNotificationEmitterFor(name);
-        if (emitter == null) {
-            IllegalArgumentException iae = new IllegalArgumentException(
-                    "Not a NotificationEmitter: " + name);
-            throw new RuntimeOperationsException(iae);
-        }
-        return emitter;
-    }
-
-    /**
-     * <p>Creates a new MBean in the MBean name space.
-     * This operation is not supported in this base class implementation.</p>
-     * The default implementation of this method always throws an {@link
-     * UnsupportedOperationException}
-     * wrapped in a {@link RuntimeOperationsException}.</p>
-     *
-     * <p>Subclasses may redefine this method to provide an implementation.
-     * All the various flavors of {@code MBeanServer.createMBean} methods
-     * will eventually call this method. A subclass that wishes to
-     * support MBean creation through {@code createMBean} thus only
-     * needs to provide an implementation for this one method.</p>
-     *
-     * <p>A subclass implementation of this method should respect the contract
-     * of the various {@code createMBean} methods in the {@link MBeanServer}
-     * interface, in particular as regards exception wrapping.</p>
-     *
-     * @param className The class name of the MBean to be instantiated.
-     * @param name The object name of the MBean. May be null.
-     * @param params An array containing the parameters of the
-     * constructor to be invoked.
-     * @param signature An array containing the signature of the
-     * constructor to be invoked.
-     * @param loaderName The object name of the class loader to be used.
-     * @param useCLR This parameter is {@code true} when this method
-     *        is called from one of the {@code MBeanServer.createMBean} methods
-     *        whose signature does not include the {@code ObjectName} of an
-     *        MBean class loader to use for loading the MBean class.
-     *
-     * @return An <CODE>ObjectInstance</CODE>, containing the
-     * <CODE>ObjectName</CODE> and the Java class name of the newly
-     * instantiated MBean.  If the contained <code>ObjectName</code>
-     * is <code>n</code>, the contained Java class name is
-     * <code>{@link javax.management.MBeanServer#getMBeanInfo
-     * getMBeanInfo(n)}.getClassName()</code>.
-     *
-     * @exception ReflectionException Wraps a
-     * <CODE>java.lang.ClassNotFoundException</CODE> or a
-     * <CODE>java.lang.Exception</CODE> that occurred when trying to
-     * invoke the MBean's constructor.
-     * @exception InstanceAlreadyExistsException The MBean is already
-     * under the control of the MBean server.
-     * @exception MBeanRegistrationException The
-     * <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE>
-     * interface) method of the MBean has thrown an exception. The
-     * MBean will not be registered.
-     * @exception RuntimeMBeanException If the MBean's constructor or its
-     * {@code preRegister} or {@code postRegister} method threw
-     * a {@code RuntimeException}. If the <CODE>postRegister</CODE>
-     * (<CODE>MBeanRegistration</CODE> interface) method of the MBean throws a
-     * <CODE>RuntimeException</CODE>, the <CODE>createMBean</CODE> method will
-     * throw a <CODE>RuntimeMBeanException</CODE>, although the MBean creation
-     * and registration succeeded. In such a case, the MBean will be actually
-     * registered even though the <CODE>createMBean</CODE> method
-     * threw an exception. Note that <CODE>RuntimeMBeanException</CODE> can
-     * also be thrown by <CODE>preRegister</CODE>, in which case the MBean
-     * will not be registered.
-     * @exception MBeanException The constructor of the MBean has
-     * thrown an exception
-     * @exception NotCompliantMBeanException This class is not a JMX
-     * compliant MBean
-     * @exception InstanceNotFoundException The specified class loader
-     * is not registered in the MBean server.
-     * @exception RuntimeOperationsException Wraps either:
-     * <ul>
-     * <li>a <CODE>java.lang.IllegalArgumentException</CODE>: The className
-     * passed in parameter is null, the <CODE>ObjectName</CODE> passed in
-     * parameter contains a pattern or no <CODE>ObjectName</CODE> is specified
-     * for the MBean; or</li>
-     * <li>an {@code UnsupportedOperationException} if creating MBeans is not
-     * supported by this {@code MBeanServer} implementation.
-     * </ul>
-     */
-    public ObjectInstance createMBean(String className,
-            ObjectName name, ObjectName loaderName, Object[] params,
-            String[] signature, boolean useCLR)
-            throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, InstanceNotFoundException {
-        throw newUnsupportedException("createMBean");
-    }
-
-
-    /**
-     * <p>Attempts to determine whether the named MBean should be
-     * considered as an instance of a given class.  The default implementation
-     * of this method calls {@link #getDynamicMBeanFor getDynamicMBeanFor(name)}
-     * to get an MBean object.  Then its behaviour is the same as the standard
-     * {@link MBeanServer#isInstanceOf MBeanServer.isInstanceOf} method.</p>
-     *
-     * {@inheritDoc}
-     */
-    public boolean isInstanceOf(ObjectName name, String className)
-        throws InstanceNotFoundException {
-
-        final DynamicMBean instance = nonNullMBeanFor(name);
-
-        try {
-            final String mbeanClassName = instance.getMBeanInfo().getClassName();
-
-            if (mbeanClassName.equals(className))
-                return true;
-
-            final Object resource;
-            final ClassLoader cl;
-            if (instance instanceof DynamicWrapperMBean) {
-                DynamicWrapperMBean d = (DynamicWrapperMBean) instance;
-                resource = d.getWrappedObject();
-                cl = d.getWrappedClassLoader();
-            } else {
-                resource = instance;
-                cl = instance.getClass().getClassLoader();
-            }
-
-            final Class<?> classNameClass = Class.forName(className, false, cl);
-
-            if (classNameClass.isInstance(resource))
-                return true;
-
-            if (classNameClass == NotificationBroadcaster.class ||
-                    classNameClass == NotificationEmitter.class) {
-                try {
-                    getNotificationEmitterFor(name);
-                    return true;
-                } catch (Exception x) {
-                    LOG.finest("MBean " + name +
-                            " is not a notification emitter. Ignoring: "+x);
-                    return false;
-                }
-            }
-
-            final Class<?> resourceClass = Class.forName(mbeanClassName, false, cl);
-            return classNameClass.isAssignableFrom(resourceClass);
-        } catch (Exception x) {
-            /* Could be SecurityException or ClassNotFoundException */
-            LOG.logp(Level.FINEST,
-                    MBeanServerSupport.class.getName(),
-                    "isInstanceOf", "Exception calling isInstanceOf", x);
-            return false;
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method returns the string
-     * "DefaultDomain".</p>
-     */
-    public String getDefaultDomain() {
-        return "DefaultDomain";
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method returns
-     * {@link #getNames()}.size().</p>
-     */
-    public Integer getMBeanCount() {
-        return getNames().size();
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method first calls {@link #getNames
-     * getNames()} to get a list of all MBean names,
-     * and from this set of names, derives the set of domains which contain
-     * MBeans.</p>
-     */
-    public String[] getDomains() {
-        final Set<ObjectName> names = getNames();
-        final Set<String> res = new TreeSet<String>();
-        for (ObjectName n : names) {
-            if (n == null) continue; // not allowed but you never know.
-            res.add(n.getDomain());
-        }
-        return res.toArray(new String[res.size()]);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first
-     * call {@link
-     *    #getDynamicMBeanFor getDynamicMBeanFor(name)} to obtain a handle
-     * to the named MBean,
-     * and then call {@link DynamicMBean#getAttribute getAttribute}
-     * on that {@link DynamicMBean} handle.</p>
-     *
-     * @throws RuntimeOperationsException {@inheritDoc}
-     */
-    public Object getAttribute(ObjectName name, String attribute)
-        throws MBeanException, AttributeNotFoundException,
-               InstanceNotFoundException, ReflectionException {
-        final DynamicMBean mbean = nonNullMBeanFor(name);
-        return mbean.getAttribute(attribute);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first
-     * call {@link #getDynamicMBeanFor getDynamicMBeanFor(name)}
-     * to obtain a handle to the named MBean,
-     * and then call {@link DynamicMBean#setAttribute setAttribute}
-     * on that {@link DynamicMBean} handle.</p>
-     *
-     * @throws RuntimeOperationsException {@inheritDoc}
-     */
-    public void setAttribute(ObjectName name, Attribute attribute)
-        throws InstanceNotFoundException, AttributeNotFoundException,
-            InvalidAttributeValueException, MBeanException,
-            ReflectionException {
-        final DynamicMBean mbean = nonNullMBeanFor(name);
-        mbean.setAttribute(attribute);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first
-     * call {@link #getDynamicMBeanFor getDynamicMBeanFor(name)} to obtain a
-     * handle to the named MBean,
-     * and then call {@link DynamicMBean#getAttributes getAttributes}
-     * on that {@link DynamicMBean} handle.</p>
-     *
-     * @throws RuntimeOperationsException {@inheritDoc}
-     */
-    public AttributeList getAttributes(ObjectName name,
-            String[] attributes) throws InstanceNotFoundException,
-            ReflectionException {
-        final DynamicMBean mbean = nonNullMBeanFor(name);
-        return mbean.getAttributes(attributes);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first
-     * call {@link #getDynamicMBeanFor getDynamicMBeanFor(name)} to obtain a
-     * handle to the named MBean,
-     * and then call {@link DynamicMBean#setAttributes setAttributes}
-     * on that {@link DynamicMBean} handle.</p>
-     *
-     * @throws RuntimeOperationsException {@inheritDoc}
-     */
-    public AttributeList setAttributes(ObjectName name, AttributeList attributes)
-        throws InstanceNotFoundException, ReflectionException {
-        final DynamicMBean mbean = nonNullMBeanFor(name);
-        return mbean.setAttributes(attributes);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first
-     * call {@link #getDynamicMBeanFor getDynamicMBeanFor(name)} to obtain a
-     * handle to the named MBean,
-     * and then call {@link DynamicMBean#invoke invoke}
-     * on that {@link DynamicMBean} handle.</p>
-     */
-    public Object invoke(ObjectName name, String operationName,
-                Object[] params, String[] signature)
-                throws InstanceNotFoundException, MBeanException,
-                       ReflectionException {
-        final DynamicMBean mbean = nonNullMBeanFor(name);
-        return mbean.invoke(operationName, params, signature);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first
-     * call {@link #getDynamicMBeanFor getDynamicMBeanFor(name)} to obtain a
-     * handle to the named MBean,
-     * and then call {@link DynamicMBean#getMBeanInfo getMBeanInfo}
-     * on that {@link DynamicMBean} handle.</p>
-     */
-    public MBeanInfo getMBeanInfo(ObjectName name)
-        throws InstanceNotFoundException, IntrospectionException,
-               ReflectionException {
-        final DynamicMBean mbean = nonNullMBeanFor(name);
-        return mbean.getMBeanInfo();
-   }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will call
-     * {@link #getDynamicMBeanFor getDynamicMBeanFor(name)}.<!--
-     * -->{@link DynamicMBean#getMBeanInfo getMBeanInfo()}.<!--
-     * -->{@link MBeanInfo#getClassName getClassName()} to get the
-     * class name to combine with {@code name} to produce a new
-     * {@code ObjectInstance}.</p>
-     */
-    public ObjectInstance getObjectInstance(ObjectName name)
-            throws InstanceNotFoundException {
-        final DynamicMBean mbean = nonNullMBeanFor(name);
-        final String className = mbean.getMBeanInfo().getClassName();
-        return new ObjectInstance(name, className);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first call {@link
-     * #getDynamicMBeanFor getDynamicMBeanFor(name)} to obtain a handle to the
-     * named MBean. If {@code getDynamicMBeanFor} returns an object, {@code
-     * isRegistered} will return true. If {@code getDynamicMBeanFor} returns
-     * null or throws {@link InstanceNotFoundException}, {@code isRegistered}
-     * will return false.</p>
-     *
-     * @throws RuntimeOperationsException {@inheritDoc}
-     */
-    public boolean isRegistered(ObjectName name) {
-        try {
-            final DynamicMBean mbean = getDynamicMBeanFor(name);
-            return mbean!=null;
-        } catch (InstanceNotFoundException x) {
-            if (LOG.isLoggable(Level.FINEST))
-                LOG.finest("MBean "+name+" is not registered: "+x);
-            return false;
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method will first
-     * call {@link #queryNames queryNames}
-     * to get a list of all matching MBeans, and then, for each returned name,
-     * call {@link #getObjectInstance getObjectInstance(name)}.</p>
-     */
-    public Set<ObjectInstance> queryMBeans(ObjectName pattern, QueryExp query) {
-        final Set<ObjectName> names = queryNames(pattern, query);
-        if (names.isEmpty()) return Collections.emptySet();
-        final Set<ObjectInstance> mbeans = new HashSet<ObjectInstance>();
-        for (ObjectName name : names) {
-            try {
-                mbeans.add(getObjectInstance(name));
-            } catch (SecurityException x) { // DLS: OK
-                continue;
-            } catch (InstanceNotFoundException x) { // DLS: OK
-                continue;
-            }
-        }
-        return mbeans;
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method calls {@link #getMatchingNames
-     * getMatchingNames(pattern)} to obtain a list of MBeans matching
-     * the given name pattern. If the {@code query} parameter is null,
-     * this will be the result. Otherwise, it will evaluate the
-     * {@code query} parameter for each of the returned names, exactly
-     * as an {@code MBeanServer} would. This might result in
-     * {@link #getDynamicMBeanFor getDynamicMBeanFor} being called
-     * several times for each returned name.</p>
-     */
-    public Set<ObjectName> queryNames(ObjectName pattern, QueryExp query) {
-        try {
-            final Set<ObjectName> res = getMatchingNames(pattern);
-            return filterListOfObjectNames(res, query);
-        } catch (Exception x) {
-            LOG.fine("Unexpected exception raised in queryNames: "+x);
-            LOG.log(Level.FINEST, "Unexpected exception raised in queryNames", x);
-        }
-        // We reach here only when an exception was raised.
-        //
-        return Collections.emptySet();
-    }
-
-    private final static boolean apply(final QueryExp query,
-                  final ObjectName on,
-                  final MBeanServer srv) {
-        boolean res = false;
-        MBeanServer oldServer = QueryEval.getMBeanServer();
-        query.setMBeanServer(srv);
-        try {
-            res = query.apply(on);
-        } catch (Exception e) {
-            LOG.finest("QueryExp.apply threw exception, returning false." +
-                    " Cause: "+e);
-            res = false;
-        } finally {
-           /*
-            * query.setMBeanServer is probably
-            * QueryEval.setMBeanServer so put back the old
-            * value.  Since that method uses a ThreadLocal
-            * variable, this code is only needed for the
-            * unusual case where the user creates a custom
-            * QueryExp that calls a nested query on another
-            * MBeanServer.
-            */
-            query.setMBeanServer(oldServer);
-        }
-        return res;
-    }
-
-    /**
-     * Filters a {@code Set<ObjectName>} according to a pattern and a query.
-     * This might be quite inefficient for virtual name spaces.
-     */
-    Set<ObjectName>
-            filterListOfObjectNames(Set<ObjectName> list,
-                                    QueryExp query) {
-        if (list.isEmpty() || query == null)
-            return list;
-
-        // create a new result set
-        final Set<ObjectName> result = new HashSet<ObjectName>();
-
-        for (ObjectName on : list) {
-            // if on doesn't match query exclude it.
-            if (apply(query, on, this))
-                result.add(on);
-        }
-        return result;
-    }
-
-
-    // Don't use {@inheritDoc}, because we don't want to say that the
-    // MBeanServer replaces a reference to the MBean by its ObjectName.
-    /**
-     * <p>Adds a listener to a registered MBean. A notification emitted by
-     * the MBean will be forwarded to the listener.</p>
-     *
-     * <p>This implementation calls
-     * {@link #getNotificationEmitterFor getNotificationEmitterFor}
-     * and invokes {@code addNotificationListener} on the
-     * {@link NotificationEmitter} it returns.
-     *
-     * @see #getDynamicMBeanFor getDynamicMBeanFor
-     * @see #getNotificationEmitterFor getNotificationEmitterFor
-     */
-    public void addNotificationListener(ObjectName name,
-            NotificationListener listener, NotificationFilter filter,
-            Object handback) throws InstanceNotFoundException {
-        final NotificationEmitter emitter =
-                getNonNullNotificationEmitterFor(name);
-        emitter.addNotificationListener(listener, filter, handback);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This implementation calls
-     * {@link #getNotificationEmitterFor getNotificationEmitterFor}
-     * and invokes {@code removeNotificationListener} on the
-     * {@link NotificationEmitter} it returns.
-     * @see #getDynamicMBeanFor getDynamicMBeanFor
-     * @see #getNotificationEmitterFor getNotificationEmitterFor
-     */
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        final NotificationEmitter emitter =
-                getNonNullNotificationEmitterFor(name);
-        emitter.removeNotificationListener(listener);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This implementation calls
-     * {@link #getNotificationEmitterFor getNotificationEmitterFor}
-     * and invokes {@code removeNotificationListener} on the
-     * {@link NotificationEmitter} it returns.
-     * @see #getDynamicMBeanFor getDynamicMBeanFor
-     * @see #getNotificationEmitterFor getNotificationEmitterFor
-     */
-    public void removeNotificationListener(ObjectName name,
-            NotificationListener listener, NotificationFilter filter,
-            Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        NotificationEmitter emitter =
-                getNonNullNotificationEmitterFor(name);
-        emitter.removeNotificationListener(listener);
-    }
-
-
-    /**
-     * <p>Adds a listener to a registered MBean.</p>
-     *
-     * <p>The default implementation of this method first calls
-     * {@link #getDynamicMBeanFor getDynamicMBeanFor(listenerName)}.
-     * If that successfully returns an object, call it {@code
-     * mbean}, then (a) if {@code mbean} is an instance of {@link
-     * NotificationListener} then this method calls {@link
-     * #addNotificationListener(ObjectName, NotificationListener,
-     * NotificationFilter, Object) addNotificationListener(name, mbean, filter,
-     * handback)}, otherwise (b) this method throws an exception as specified
-     * for this case.</p>
-     *
-     * <p>This default implementation is not appropriate for Virtual MBeans,
-     * although that only matters if the object returned by {@code
-     * getDynamicMBeanFor} can be an instance of
-     * {@code NotificationListener}.</p>
-     *
-     * @throws RuntimeOperationsException {@inheritDoc}
-     */
-    public void addNotificationListener(ObjectName name, ObjectName listenerName,
-            NotificationFilter filter, Object handback)
-            throws InstanceNotFoundException {
-        NotificationListener listener = getListenerMBean(listenerName);
-        addNotificationListener(name, listener, filter, handback);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public void removeNotificationListener(ObjectName name,
-            ObjectName listenerName)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        NotificationListener listener = getListenerMBean(listenerName);
-        removeNotificationListener(name, listener);
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public void removeNotificationListener(ObjectName name,
-            ObjectName listenerName, NotificationFilter filter,
-            Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        NotificationListener listener = getListenerMBean(listenerName);
-        removeNotificationListener(name, listener, filter, handback);
-    }
-
-    private NotificationListener getListenerMBean(ObjectName listenerName)
-            throws InstanceNotFoundException {
-        Object mbean = getDynamicMBeanFor(listenerName);
-        if (mbean instanceof NotificationListener)
-            return (NotificationListener) mbean;
-        else {
-            throw newIllegalArgumentException(
-                    "MBean is not a NotificationListener: " + listenerName);
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link InstanceNotFoundException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @return the default implementation of this method never returns.
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public ClassLoader getClassLoader(ObjectName loaderName)
-            throws InstanceNotFoundException {
-        final UnsupportedOperationException failed =
-                new UnsupportedOperationException("getClassLoader");
-        final InstanceNotFoundException x =
-                new InstanceNotFoundException(String.valueOf(loaderName));
-        x.initCause(failed);
-        throw x;
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method calls
-     * {@link #getDynamicMBeanFor getDynamicMBeanFor(mbeanName)} and applies
-     * the logic just described to the result.</p>
-     */
-    public ClassLoader getClassLoaderFor(ObjectName mbeanName)
-            throws InstanceNotFoundException {
-        final DynamicMBean mbean = nonNullMBeanFor(mbeanName);
-        if (mbean instanceof DynamicWrapperMBean)
-            return ((DynamicWrapperMBean) mbean).getWrappedClassLoader();
-        else
-            return mbean.getClass().getClassLoader();
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>The default implementation of this method returns a
-     * {@link ClassLoaderRepository} containing exactly one loader,
-     * the {@linkplain Thread#getContextClassLoader() context class loader}
-     * for the current thread.
-     * Subclasses can override this method to return a different
-     * {@code ClassLoaderRepository}.</p>
-     */
-    public ClassLoaderRepository getClassLoaderRepository() {
-        // We return a new ClassLoaderRepository each time this
-        // method is called. This is by design, because the
-        // SingletonClassLoaderRepository is a very small object and
-        // getClassLoaderRepository() will not be called very often
-        // (the connector server calls it once) - in the context of
-        // MBeanServerSupport there's a very good chance that this method will
-        // *never* be called.
-        ClassLoader ccl = Thread.currentThread().getContextClassLoader();
-        return Util.getSingleClassLoaderRepository(ccl);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public ObjectInstance registerMBean(Object object, ObjectName name)
-            throws InstanceAlreadyExistsException, MBeanRegistrationException,
-            NotCompliantMBeanException {
-        throw newUnsupportedException("registerMBean");
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public void unregisterMBean(ObjectName name)
-            throws InstanceNotFoundException, MBeanRegistrationException {
-        throw newUnsupportedException("unregisterMBean");
-    }
-
-    /**
-     * Calls {@link #createMBean(String, ObjectName,
-     *           ObjectName, Object[], String[], boolean)
-     * createMBean(className, name, null, params, signature, true)};
-     */
-    public final ObjectInstance createMBean(String className, ObjectName name,
-            Object[] params, String[] signature)
-            throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException {
-        try {
-            return createMBean(className, name, null, params, signature, true);
-        } catch (InstanceNotFoundException ex) {
-            // should not happen!
-            throw new MBeanException(ex, "Unexpected exception: " + ex);
-        }
-    }
-
-    /**
-     * Calls {@link #createMBean(String, ObjectName,
-     *           ObjectName, Object[], String[], boolean)
-     * createMBean(className,name, loaderName, params, signature, false)};
-     */
-    public final ObjectInstance createMBean(String className, ObjectName name,
-            ObjectName loaderName, Object[] params, String[] signature)
-            throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, InstanceNotFoundException {
-        return createMBean(className, name, loaderName, params, signature, false);
-    }
-
-    /**
-     * Calls {@link #createMBean(String, ObjectName,
-     *           ObjectName, Object[], String[], boolean)
-     * createMBean(className, name, null, null, null, true)};
-     */
-    public final ObjectInstance createMBean(String className, ObjectName name)
-        throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException {
-        try {
-            return createMBean(className, name, null, null, null, true);
-        } catch (InstanceNotFoundException ex) {
-            // should not happen!
-            throw new MBeanException(ex, "Unexpected exception: " + ex);
-        }
-    }
-
-    /**
-     * Calls {@link #createMBean(String, ObjectName,
-     *           ObjectName, Object[], String[], boolean)
-     * createMBean(className, name, loaderName, null, null, false)};
-     */
-    public final ObjectInstance createMBean(String className, ObjectName name,
-            ObjectName loaderName)
-            throws ReflectionException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException,
-            NotCompliantMBeanException, InstanceNotFoundException {
-        return createMBean(className, name, loaderName, null, null, false);
-    }
-
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public Object instantiate(String className)
-            throws ReflectionException, MBeanException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public Object instantiate(String className, ObjectName loaderName)
-            throws ReflectionException, MBeanException,
-            InstanceNotFoundException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public Object instantiate(String className, Object[] params,
-            String[] signature) throws ReflectionException, MBeanException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    public Object instantiate(String className, ObjectName loaderName,
-            Object[] params, String[] signature)
-            throws ReflectionException, MBeanException,
-            InstanceNotFoundException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(ObjectName name, byte[] data)
-            throws InstanceNotFoundException, OperationsException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className, byte[] data)
-            throws OperationsException, ReflectionException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * <p>This operation is not supported in this base class implementation.
-     * The default implementation of this method always throws
-     * {@link RuntimeOperationsException} wrapping
-     * {@link UnsupportedOperationException}.</p>
-     *
-     * @throws javax.management.RuntimeOperationsException wrapping
-     *        {@link UnsupportedOperationException}
-     */
-    @Deprecated
-    public ObjectInputStream deserialize(String className,
-            ObjectName loaderName, byte[] data)
-            throws InstanceNotFoundException, OperationsException,
-            ReflectionException {
-        throw new UnsupportedOperationException("Not applicable.");
-    }
-
-
-    // Calls getDynamicMBeanFor, and throws an InstanceNotFoundException
-    // if the returned mbean is null.
-    // The DynamicMBean returned by this method is thus guaranteed to be
-    // non null.
-    //
-    private DynamicMBean nonNullMBeanFor(ObjectName name)
-            throws InstanceNotFoundException {
-        if (name == null)
-            throw newIllegalArgumentException("Null ObjectName");
-        if (name.getDomain().equals("")) {
-            String defaultDomain = getDefaultDomain();
-            try {
-                name = name.withDomain(getDefaultDomain());
-            } catch (Exception e) {
-                throw newIllegalArgumentException(
-                        "Illegal default domain: " + defaultDomain);
-            }
-        }
-        final DynamicMBean mbean = getDynamicMBeanFor(name);
-        if (mbean!=null) return mbean;
-        throw new InstanceNotFoundException(String.valueOf(name));
-    }
-
-    static RuntimeException newUnsupportedException(String operation) {
-        return new RuntimeOperationsException(
-            new UnsupportedOperationException(
-                operation+": Not supported in this namespace"));
-    }
-
-    static RuntimeException newIllegalArgumentException(String msg) {
-        return new RuntimeOperationsException(
-                new IllegalArgumentException(msg));
-    }
-
-}
--- a/src/share/classes/javax/management/namespace/VirtualEventManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,378 +0,0 @@
-/*
- * 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 javax.management.namespace;
-
-import com.sun.jmx.remote.util.ClassLogger;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import javax.management.InstanceNotFoundException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventConsumer;
-
-/**
- * <p>This class maintains a list of subscribers for ObjectName patterns and
- * allows a notification to be sent to all subscribers for a given ObjectName.
- * It is typically used in conjunction with {@link MBeanServerSupport}
- * to implement a namespace with Virtual MBeans that can emit notifications.
- * The {@code VirtualEventManager} keeps track of the listeners that have been
- * added to each Virtual MBean. When an event occurs that should trigger a
- * notification from a Virtual MBean, the {@link #publish publish} method can
- * be used to send it to the appropriate listeners.</p>
- * @since 1.7
- */
-public class VirtualEventManager implements EventConsumer {
-    /**
-     * <p>Create a new {@code VirtualEventManager}.</p>
-     */
-    public VirtualEventManager() {
-    }
-
-    public void subscribe(
-            ObjectName name,
-            NotificationListener listener,
-            NotificationFilter filter,
-            Object handback) {
-
-        if (logger.traceOn())
-            logger.trace("subscribe", "" + name);
-
-        if (name == null)
-            throw new IllegalArgumentException("Null MBean name");
-
-        if (listener == null)
-            throw new IllegalArgumentException("Null listener");
-
-        Map<ObjectName, List<ListenerInfo>> map =
-                name.isPattern() ? patternSubscriptionMap : exactSubscriptionMap;
-
-        final ListenerInfo li = new ListenerInfo(listener, filter, handback);
-        List<ListenerInfo> list;
-
-        synchronized (map) {
-            list = map.get(name);
-            if (list == null) {
-                list = new ArrayList<ListenerInfo>();
-                map.put(name, list);
-            }
-            list.add(li);
-        }
-    }
-
-    public void unsubscribe(
-            ObjectName name, NotificationListener listener)
-            throws ListenerNotFoundException {
-
-        if (logger.traceOn())
-            logger.trace("unsubscribe2", "" + name);
-
-        if (name == null)
-            throw new IllegalArgumentException("Null MBean name");
-
-        if (listener == null)
-            throw new ListenerNotFoundException();
-
-        Map<ObjectName, List<ListenerInfo>> map =
-                name.isPattern() ? patternSubscriptionMap : exactSubscriptionMap;
-
-        final ListenerInfo li = new ListenerInfo(listener, null, null);
-        List<ListenerInfo> list;
-        synchronized (map) {
-            list = map.get(name);
-            if (list == null || !list.remove(li))
-                throw new ListenerNotFoundException();
-
-            if (list.isEmpty())
-                map.remove(name);
-        }
-    }
-
-    /**
-     * <p>Unsubscribes a listener which is listening to an MBean or a set of
-     * MBeans represented by an {@code ObjectName} pattern.</p>
-     *
-     * <p>The listener to be removed must have been added by the {@link
-     * #subscribe subscribe} method with the given {@code name}, {@code filter},
-     * and {@code handback}. If the {@code
-     * name} is a pattern, then the {@code subscribe} must have used the same
-     * pattern. If the same listener has been subscribed more than once to the
-     * {@code name} with the same filter and handback, only one listener is
-     * removed.</p>
-     *
-     * @param name The name of the MBean or an {@code ObjectName} pattern
-     * representing a set of MBeans to which the listener was subscribed.
-     * @param listener A listener that was previously subscribed to the
-     * MBean(s).
-     *
-     * @throws ListenerNotFoundException The given {@code listener} was not
-     * subscribed to the given {@code name}.
-     *
-     * @see #subscribe
-     */
-    public void unsubscribe(
-            ObjectName name, NotificationListener listener,
-            NotificationFilter filter, Object handback)
-            throws ListenerNotFoundException {
-
-        if (logger.traceOn())
-            logger.trace("unsubscribe4", "" + name);
-
-        if (name == null)
-            throw new IllegalArgumentException("Null MBean name");
-
-        if (listener == null)
-            throw new ListenerNotFoundException();
-
-        Map<ObjectName, List<ListenerInfo>> map =
-                name.isPattern() ? patternSubscriptionMap : exactSubscriptionMap;
-
-        List<ListenerInfo> list;
-        synchronized (map) {
-            list = map.get(name);
-            boolean removed = false;
-            for (Iterator<ListenerInfo> it = list.iterator(); it.hasNext(); ) {
-                ListenerInfo li = it.next();
-                if (li.equals(listener, filter, handback)) {
-                    it.remove();
-                    removed = true;
-                    break;
-                }
-            }
-            if (!removed)
-                throw new ListenerNotFoundException();
-
-            if (list.isEmpty())
-                map.remove(name);
-        }
-    }
-
-    /**
-     * <p>Sends a notification to the subscribers for a given MBean.</p>
-     *
-     * <p>For each listener subscribed with an {@code ObjectName} that either
-     * is equal to {@code emitterName} or is a pattern that matches {@code
-     * emitterName}, if the associated filter accepts the notification then it
-     * is forwarded to the listener.</p>
-     *
-     * @param emitterName The name of the MBean emitting the notification.
-     * @param n The notification being sent by the MBean called
-     * {@code emitterName}.
-     *
-     * @throws IllegalArgumentException If the emitterName of the
-     * notification is null or is an {@code ObjectName} pattern.
-     */
-    public void publish(ObjectName emitterName, Notification n) {
-        if (logger.traceOn())
-            logger.trace("publish", "" + emitterName);
-
-        if (n == null)
-            throw new IllegalArgumentException("Null notification");
-
-        if (emitterName == null) {
-            throw new IllegalArgumentException(
-                    "Null emitter name");
-        } else if (emitterName.isPattern()) {
-            throw new IllegalArgumentException(
-                    "The emitter must not be an ObjectName pattern");
-        }
-
-        final List<ListenerInfo> listeners = new ArrayList<ListenerInfo>();
-
-        // If there are listeners for this exact name, add them.
-        synchronized (exactSubscriptionMap) {
-            List<ListenerInfo> exactListeners =
-                    exactSubscriptionMap.get(emitterName);
-            if (exactListeners != null)
-                listeners.addAll(exactListeners);
-        }
-
-        // Loop over subscription patterns, and add all listeners for each
-        // one that matches the emitterName name.
-        synchronized (patternSubscriptionMap) {
-            for (ObjectName on : patternSubscriptionMap.keySet()) {
-                if (on.apply(emitterName))
-                    listeners.addAll(patternSubscriptionMap.get(on));
-            }
-        }
-
-        // Send the notification to all the listeners we found.
-        sendNotif(listeners, n);
-    }
-
-    /**
-     * <p>Returns a {@link NotificationEmitter} object which can be used to
-     * subscribe or unsubscribe for notifications with the named
-     * mbean.  The returned object implements {@link
-     * NotificationEmitter#addNotificationListener
-     * addNotificationListener(listener, filter, handback)} as
-     * {@link #subscribe this.subscribe(name, listener, filter, handback)}
-     * and the two {@code removeNotificationListener} methods from {@link
-     * NotificationEmitter} as the corresponding {@code unsubscribe} methods
-     * from this class.</p>
-     *
-     * @param name   The name of the MBean whose notifications are being
-     *        subscribed, or unsuscribed.
-     *
-     * @return A {@link NotificationEmitter}
-     *         that can be used to subscribe or unsubscribe for
-     *         notifications emitted by the named MBean, or {@code null} if
-     *         the MBean does not emit notifications and should not
-     *         be considered as a {@code NotificationBroadcaster}.  This class
-     *         never returns null but a subclass is allowed to.
-     *
-     * @throws InstanceNotFoundException if {@code name} does not exist.
-     * This implementation never throws {@code InstanceNotFoundException} but
-     * a subclass is allowed to override this method to do so.
-     */
-    public NotificationEmitter
-            getNotificationEmitterFor(final ObjectName name)
-            throws InstanceNotFoundException {
-        final NotificationEmitter emitter = new NotificationEmitter() {
-            public void addNotificationListener(NotificationListener listener,
-                    NotificationFilter filter, Object handback)
-                    throws IllegalArgumentException {
-                subscribe(name, listener, filter, handback);
-            }
-
-            public void removeNotificationListener(
-                    NotificationListener listener)
-                    throws ListenerNotFoundException {
-                unsubscribe(name, listener);
-            }
-
-            public void removeNotificationListener(NotificationListener listener,
-                                                   NotificationFilter filter,
-                                                   Object handback)
-                    throws ListenerNotFoundException {
-                unsubscribe(name, listener, filter, handback);
-            }
-
-            public MBeanNotificationInfo[] getNotificationInfo() {
-                // Never called.
-                return null;
-            }
-        };
-        return emitter;
-    }
-
-    // ---------------------------------
-    // private stuff
-    // ---------------------------------
-
-    private static class ListenerInfo {
-        public final NotificationListener listener;
-        public final NotificationFilter filter;
-        public final Object handback;
-
-        public ListenerInfo(NotificationListener listener,
-                NotificationFilter filter,
-                Object handback) {
-
-            if (listener == null) {
-                throw new IllegalArgumentException("Null listener.");
-            }
-
-            this.listener = listener;
-            this.filter = filter;
-            this.handback = handback;
-        }
-
-        /* Two ListenerInfo instances are equal if they have the same
-         * NotificationListener.  This means that we can use List.remove
-         * to implement the two-argument removeNotificationListener.
-         */
-        @Override
-        public boolean equals(Object o) {
-            if (o == this) {
-                return true;
-            }
-
-            if (!(o instanceof ListenerInfo)) {
-                return false;
-            }
-
-            return listener.equals(((ListenerInfo)o).listener);
-        }
-
-        /* Method that compares all four fields, appropriate for the
-         * four-argument removeNotificationListener.
-         */
-        boolean equals(
-                NotificationListener listener,
-                NotificationFilter filter,
-                Object handback) {
-            return (this.listener == listener && same(this.filter, filter)
-                    && same(this.handback, handback));
-        }
-
-        private static boolean same(Object x, Object y) {
-            if (x == y)
-                return true;
-            if (x == null)
-                return false;
-            return x.equals(y);
-        }
-
-        @Override
-        public int hashCode() {
-            return listener.hashCode();
-        }
-    }
-
-    private static void sendNotif(List<ListenerInfo> listeners, Notification n) {
-        for (ListenerInfo li : listeners) {
-            if (li.filter == null ||
-                    li.filter.isNotificationEnabled(n)) {
-                try {
-                    li.listener.handleNotification(n, li.handback);
-                } catch (Exception e) {
-                    logger.trace("sendNotif", "handleNotification", e);
-                }
-            }
-        }
-    }
-
-    // ---------------------------------
-    // private variables
-    // ---------------------------------
-
-    private final Map<ObjectName, List<ListenerInfo>> exactSubscriptionMap =
-            new HashMap<ObjectName, List<ListenerInfo>>();
-    private final Map<ObjectName, List<ListenerInfo>> patternSubscriptionMap =
-            new HashMap<ObjectName, List<ListenerInfo>>();
-
-    // trace issue
-    private static final ClassLogger logger =
-            new ClassLogger("javax.management.event", "EventManager");
-}
--- a/src/share/classes/javax/management/namespace/package-info.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,629 +0,0 @@
-/*
- * 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.
- */
-
-/**
- *  <p>The <code>javax.management.namespace</code> package makes it possible
- *  to federate MBeanServers into a hierarchical name space.</p>
- *
- *  <h3 id="WhatIs">What Is a Name Space?</h3>
- *  <p>
- *      A name space is like an {@link javax.management.MBeanServer} within
- *      an {@code MBeanServer}. Just as a file system folder can contain
- *      another file system folder, an {@code MBeanServer} can contain another
- *      {@code MBeanServer}. Similarly, just as a remote folder on a remote
- *      disk can be mounted on a parent folder on a local disk, a remote name
- *      space in a remote {@code MBeanServer} can be mounted on a name
- *      space in a local parent {@code MBeanServer}.
- *  </p>
- *  <p>
- *      The <code>javax.management.namespace</code> API thus makes it possible to
- *      create a hierarchy of MBean servers federated in a hierarchical name
- *      space inside a single {@code MBeanServer}.
- *  </p>
- *  <h3 id="HowToCreate">How To Create a Name Space?</h3>
- *  <p>
- *      To create a name space, you only need to register a
- *      {@link javax.management.namespace.JMXNamespace} MBean in
- *      an MBean server. We have seen that a namespace is like
- *      an {@code MBeanServer} within an {@code MBeanServer}, and
- *      therefore, it is possible to create a namespace that shows the
- *      content of another {@code MBeanServer}. The simplest case is
- *      when that {@code MBeanServer} is another {@code MBeanServer}
- *      created by the {@link javax.management.MBeanServerFactory} as
- *      shown in the extract below:
- *  </p>
- *  <pre>
- *  final MBeanServer server = ....;
- *  final String namespace = "foo";
- *  final ObjectName namespaceName = {@link javax.management.namespace.JMXNamespaces#getNamespaceObjectName
- *        JMXNamespaces.getNamespaceObjectName(namespace)};
- *  server.registerMBean(new JMXNamespace(MBeanServerFactory.newMBeanServer()),
- *                      namespaceName);
- *  </pre>
- *  <p id="NamespaceView">
- *     To navigate in namespaces and view their content, the easiest way is
- *     to use an instance of {@link javax.management.namespace.JMXNamespaceView}. For instance, given
- *     the {@code server} above, in which we created a namespace {@code "foo"},
- *     it is possible to create a {@code JMXNamespaceView} that will make it
- *     possible to navigate easily in the namespaces and sub-namespaces of that
- *     server:
- *  </p>
- *  <pre>
- *  // create a namespace view for 'server'
- *  final JMXNamespaceView view = new JMXNamespaceView(server);
- *
- *  // list all top level namespaces in 'server'
- *  System.out.println("List of namespaces: " + Arrays.toString({@link javax.management.namespace.JMXNamespaceView#list() view.list()}));
- *
- *  // go down into namespace 'foo': provides a namespace view of 'foo' and its
- *  // sub namespaces...
- *  final JMXNamespaceView foo = {@link javax.management.namespace.JMXNamespaceView#down view.down("foo")};
- *
- *  // list all MBeans contained in namespace 'foo'
- *  System.out.println({@link javax.management.namespace.JMXNamespaceView#where() foo.where()} + " contains: " +
- *         {@link javax.management.namespace.JMXNamespaceView#getMBeanServerConnection foo.getMBeanServerConnection()}.queryNames(null,null));
- *  </pre>
- * <p>
- *   It is also possible to create more complex namespaces, such as namespaces
- *   that point to MBean servers located in remote JVMs.
- * </p>
- * <p>
- *      For instance, to mount the MBeanServer accessible
- *      at <code>service:jmx:rmi:///jndi/rmi://localhost:9000/jmxrmi</code>
- *      in a name space {@code "foo"} inside the {@linkplain
- *      java.lang.management.ManagementFactory#getPlatformMBeanServer platform
- *      MBeanServer} you would write the following piece of code:
- *  </p>
- *  <pre>
- *      final JMXServiceURL sourceURL =
- *         new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9000/jmxrmi");
- *      final MBeanServer platform = ManagementFactory.getPlatformMBeanServer();
- *      final Map&lt;String,Object&gt; options = Collections.emptyMap();
- *      final JMXRemoteNamespace mbean = {@link
- *            javax.management.namespace.JMXRemoteNamespace JMXRemoteNamespace}.
- *         {@link javax.management.namespace.JMXRemoteNamespace#newJMXRemoteNamespace newJMXRemoteNamespace(sourceURL, options)};
- *      final ObjectName name = {@link javax.management.namespace.JMXNamespaces JMXNamespaces}.{@link javax.management.namespace.JMXNamespaces#getNamespaceObjectName(String) getNamespaceObjectName("foo")};
- *      final ObjectInstance ref = platform.registerMBean(mbean,name);
- *      platform.invoke(ref.getObjectName(),"connect",null,null);
- *  </pre>
- *
- *  <h3 id="WhatLike">What Does a Name Space Look Like?</h3>
- *
- *  <p>
- *   We have seen that {@link javax.management.namespace.JMXNamespaceView} class
- *   provides an easy way to navigate within namespaces. It is however also
- *   possible to interact with namespaces directly from the top level
- *   {@code MBeanServer} in which they have been created.
- *      From the outside, a name space only appears as a special MBean in
- *      the MBean server. There's nothing much you can do with this MBean
- *      directly.
- *  </p>
- *  <p>
- *      For instance, let's assume you have registered a {@link
- *      javax.management.namespace.JMXRemoteNamespaceMBean
- *      JMXRemoteNamespaceMBean} to manage the name space {@code "foo"}.
- *      <br>If you query for
- *      <code>platform.queryNames("&#42;//:*",null)</code>, then you will see
- *      one MBean named {@code "foo//:type=JMXNamespace"}.
- *      <br>This is the {@link javax.management.namespace.JMXNamespace}
- *      MBean which is in charge of handling the namespace {@code "foo"}.
- *  </p>
- *  <p>
- *      In fact, name space handler MBeans are instances of
- *      the class {@link javax.management.namespace.JMXNamespace} - or
- *      instances of a subclass of that class.
- *      They have a special {@link javax.management.ObjectName} defined by
- *      {@link javax.management.namespace.JMXNamespaces#getNamespaceObjectName
- *      JMXNamespaces.getNamespaceObjectName}.<br>
- *      {@link javax.management.namespace.JMXNamespace} instances are able
- *      to return an {@link
- *      javax.management.namespace.JMXNamespace#getSourceServer MBeanServer}
- *      which corresponds to the MBeanServer within (= the name space itself).
- *  </p>
- *  <p>
- *      So how does it work? How can you see the MBeans contained in the new
- *      name space?
- *  </p>
- *  <p>In order to address scalability issues, MBeans registered in
- *     namespaces (such as our namespace {@code "foo"} above) can not be
- *     seen with {@code mbeanServer.queryNames("*:*",null)}. To see the MBeans
- *     contained in a namespace, you can use one of these methods:
- *  </p>
- *  <ol>
- *      <li>
- *          You can use the {@link javax.management.namespace.JMXNamespaceView}
- *          class <a href="#NamespaceView">shown above</a>,
- *      </li>
- *      <li>
- *          or you can <a href="#NamespacePrefix">directly look</a> for MBeans
- *          whose names match
- *         {@code "foo//*:*"},
- *      </li>
- *      <li>
- *          or you can <a href="#ChangeTo">narrow down</a> to the namespace
- *          and obtain an MBeanServer
- *          proxy that corresponds to an MBeanServer view of that namespace.
- *          The JMXNamespaces class provides a static method that
- *          allows you to narrow down to a name space, by calling
- *          {@link javax.management.namespace.JMXNamespaces#narrowToNamespace(MBeanServer,String)
- *                 JMXNamespaces.narrowToNamespace}.
- *      </li>
- *  </ol>
- *
- *  <h3 id="NamespacePrefix">Using Name Space Prefixes</h3>
- *  <p>
- *      As we have explained above, MBeans contained in name
- *      spaces are not returned by {@code server.queryNames(null,null)} - or
- *      <code>server.queryNames({@link javax.management.ObjectName#WILDCARD ObjectName.WILDCARD},null)</code>.
- *      <br>
- *      However, these MBeans can still be accessed from the top level
- *      {@code MBeanServer} interface, without using any API specific to the
- *      version 2.0 of the JMX API, simply by using object names with
- *      name space prefixes:
- *      <br>To list MBeans contained in a namespace {@code "foo"} you can
- *      query for MBeans whose names match {@code "foo//*:*"}, as shown
- *      earlier in this document:
- *      <pre>
- *         server.queryNames(new ObjectName("foo//*:*", null);
- *         // or equivalently:
- *         server.queryNames(JMXNamespaces.getWildcardFor("foo"), null);
- *      </pre>
- *      This will return a list of MBean names whose domain name starts
- *      with {@code foo//}.
- *  </p><p>
- *      Using these names, you can invoke any operation on the corresponding
- *      MBeans. For instance, to get the {@link javax.management.MBeanInfo
- *      MBeanInfo} of an MBean
- *      contained in name space {@code "foo"} (assuming
- *      the name of the MBean within its name space is <i>domain:type=Thing</i>,
- *      then simply call:
- *      <pre>
- *         server.getMBeanInfo(new ObjectName("foo//domain:type=Thing"));
- *      </pre>
- *      An easier way to access MBeans contained in a name space is to
- *      <i>cd</i> inside the name space, as shown in the following paragraph.
- *  </p><p id="RejectedNamespacePatterns">
- *      Although ObjectName patterns where the characters
- *      <code>*</code> and <code>?</code> appear in the namespace path are
- *      legal, they are not valid in the {@code name} parameter of the
- *      MBean Server {@link
- *      javax.management.MBeanServer#queryNames queryNames} and {@link
- *      javax.management.MBeanServer#queryMBeans queryMBeans} methods.<br>
- *      When invoking <code>queryNames</code> or  <code>queryMBeans</code>,
- *      only ObjectNames of the form:<br>
- *      [<em>namespace-without-pattern</em>//]*[<em>pattern-without-namespace</em>]:<em>key-properties-with-or-without-pattern</em>
- *      are valid.<br>
- *      In other words: in the case of {@link
- *      javax.management.MBeanServer#queryNames queryNames} and {@link
- *      javax.management.MBeanServer#queryMBeans queryMBeans}, if a
- *      namespace path is present, it must not contain any pattern.
- *  </p><p id="NamespaceAndQueries">
- *      There is no such restriction for the {@code query} parameter of these
- *      methods. However, it must be noted that the {@code query} parameter
- *      will be evaluated in the context of the namespace where the MBeans
- *      selected by the pattern specified in {@code name} are located.
- *      This means that if {@code query} parameter is an ObjectName pattern that
- *      contains a namespace path, no MBean name will match and the result of
- *      the query will be empty.<br>
- *      In other words:</p>
- * <ul><li>{@code queryNames("foo//bar//?a?:*","b?z:type=Monitor,*")} will select
- *         all MBeans in namespace <em>foo//bar</em> whose names match both
- *         <em>?a?:*</em> and <em>b?z:type=Monitor,*</em>, but</li>
- *     <li>{@code queryNames("foo//bar//?a?:*","foo//bar//b?z:type=Monitor,*")}
- *         will select nothing because no name matching <em>?a?:*</em> will
- *         also match <em>foo//bar//b?z:type=Monitor,*</em>.
- *     </li>
- *  </ul>
- *
- *  <h3 id="ChangeTo">Narrowing Down Into a Name Spaces</h3>
- *  <p>
- *      As we have seen, name spaces are like MBean servers within MBean servers.
- *      Therefore, it is possible to view a name space just as if it were
- *      an other MBean server. This is similar to opening a sub
- *      folder from a parent folder.<br>
- *      This operation is illustrated in the code extract below:
- *      <pre>
- *          final MBeanServer foo =
- *                JMXNamespaces.narrowToNamespace(platform, "foo");
- *          final MBeanInfo info =
- *                foo.getMBeanInfo(new ObjectName("domain:type=Thing"));
- *      </pre>
- *      The {@code MBeanServer} returned by {@link
- *      javax.management.namespace.JMXNamespaces#narrowToNamespace(MBeanServer,String)
- *      JMXNamespaces.narrowToNamespace} is an {@code MBeanServer} view that
- *      narrows down into a given namespace. The MBeans contained inside that
- *      namespace can now be accessed by their regular local name. <br>
- *      The MBean server obtained by narrowing down
- *      to name space {@code "foo"} behaves just like a regular MBean server.
- *      However, it may sometimes throw an {@link
- *      java.lang.UnsupportedOperationException UnsupportedOperationException}
- *      wrapped in a {@link javax.management.RuntimeOperationsException
- *      RuntimeOperationsException} if you try to call an operation which is not
- *      supported by the underlying name space handler.
- *      <br>For instance, {@link javax.management.MBeanServer#registerMBean
- *      registerMBean} is not supported for name spaces mounted from remote
- *      MBean servers.
- *  </p>
- *  <p>
- *      <u>Note:</u> If you have a deep hierarchy of namespaces, and if you
- *      are switching from one namespace to another in the course of your
- *      application, it might be more convenient to use a
- *      {@link javax.management.namespace.JMXNamespaceView}
- *      in order to navigate in your namespaces.
- *  </p>
- *
- *  <h3 id="NamespaceTypes">Different Types of Name Spaces</h3>
- *      <p>
- *          This API lets you create several types of name spaces:
- *          <ul>
- *              <li id="RemoteNS">
- *                  You can use the {@link
- *                  javax.management.namespace.JMXRemoteNamespace
- *                  JMXRemoteNamespace} to create
- *                  <b>remote</b> name spaces, mounted from
- *                  a remote sub {@code MBeanServer} source, as shown
- *                  <a href="#HowToCreate">earlier</a> in this document.
- *              </li>
- *              <li id="LocalNS">
- *                  You can also use {@link
- *                  javax.management.namespace.JMXNamespace
- *                  JMXNamespace} to create
- *                  <b>local</b> name spaces,
- *                  by providing a direct reference to another {@code MBeanServer}
- *                  instance living in the same JVM.
- *              </li>
- *              <li id="VirtualNS">
- *                  Finally, you can create
- *                  name spaces containing <b>virtual</b> MBeans,
- *                  by subclassing the {@link
- *                  javax.management.namespace.MBeanServerSupport
- *                  MBeanServerSupport}, and passing an instance of
- *                  your own subclass to a {@link
- *                  javax.management.namespace.JMXNamespace JMXNamespace}.
- *              </li>
- *              <li id="CustomNS">
- *                  If none of these classes suit your needs, you can also provide
- *                  <b>your own</b> subclass of {@link
- *                  javax.management.namespace.JMXNamespace
- *                  JMXNamespace}. This is however discouraged.
- *              </li>
- *          </ul>
- *      </p>
- *
- *      <h3 id="SpecialOp">Name Spaces And Special Operations</h3>
- *      <p>
- *          MBean Naming considerations aside, Name Spaces are transparent for
- *          most {@code MBeanServer} operations. There are however a few
- *          exceptions:
- *      </p>
- *      <ul>
- *          <li>
- *              <p>MBeanServer only operations - these are the operations which are
- *              supported by {@link javax.management.MBeanServer MBeanServer} but
- *              are not present in {@link
- *              javax.management.MBeanServerConnection
- *              MBeanServerConnection}. Since a name space can be a local view of
- *              a remote {@code MBeanServer}, accessible only through an
- *              {@code MBeanServerConnection}, these
- *              kinds of operations are not always supported.</p>
- *              <ul>
- *                  <li id="registerMBean">
- *                      <p>registerMBean:</p>
- *                      <p> The {@link javax.management.MBeanServer#registerMBean
- *                          registerMBean}
- *                          operation is not supported by most name spaces. A call
- *                          to
- *                          <pre>
- *   MBeanServer server = ....;
- *   ThingMBean mbean = new Thing(...);
- *   ObjectName name = new ObjectName("foo//domain:type=Thing");
- *   server.registerMBean(mbean, name);
- *                          </pre>
- *                          will usually fail, unless the name space
- *                          {@code "foo"} is a <a href="#LocalNS">local</a> name
- *                          space. In the case where you attempt to cross
- *                          multiple name spaces, then all name spaces in the
- *                          path must support the {@code registerMBean} operation
- *                          in order for it to succeed.<br>
- *                          To create an MBean inside a name space, it is
- *                          usually safer to use {@code createMBean} -
- *                          although some <a href="#MBeanCreation">special
- *                          considerations</a> can also apply.
- *                      </p>
- *         <p></p>
- *                  </li>
- *                  <li id="getClassLoader">
- *                      <p>getClassLoader:</p>
- *                      <p> Similarly to <a href="#registerMBean">registerMBean</a>,
- *                          and for the same reasons, {@link
- *                          javax.management.MBeanServer#getClassLoader
- *                          getClassLoader} will usually fail, unless the
- *                          class loader is an MBean registered in a
- *                          <a href="#LocalNS">local</a> name space.<br>
- *                      </p>
- *                  </li>
- *                  <li id="getClassLoaderFor">
- *                      <p>getClassLoaderFor:</p>
- *                      <p> The implementation of {@link
- *                          javax.management.MBeanServer#getClassLoaderFor
- *                          getClassLoaderFor} also depends on which
- *                          <a href="#NamespaceTypes">type of name space</a>
- *                          handler is used across the namespace path.
- *                      </p>
- *                      <p>
- *                          A <a href="#LocalNS">local</a> name space will usually
- *                          be able to implement this method just as a real
- *                          {@code MBeanServer} would. A
- *                          <a href="#RemoteNS">remote</a> name space will usually
- *                          return the default class loader configured on the
- *                          internal {@link javax.management.remote.JMXConnector
- *                          JMXConnector} used to connect to the remote server.
- *                          When a {@link
- *                          javax.management.namespace.JMXRemoteNamespace
- *                          JMXRemoteNamespace} is used to connect to a
- *                          remote server that contains MBeans which export
- *                          custom types, the {@link
- *                          javax.management.namespace.JMXRemoteNamespace
- *                          JMXRemoteNamespace} must thus be configured with
- *                          an options map such that the underlying connector
- *                          can obtain a default class loader able
- *                          to handle those types.
- *                      </p>
- *                      <p>
- *                          Other <a href="#NamespaceTypes">types of name spaces</a>
- *                          may implement this method
- *                          as best as they can.
- *                      </p>
- *                  </li>
- *              </ul>
- *          </li>
- *          <li id="MBeanCreation">
- *              <p>MBean creation</p>
- *              <p> MBean creation through {@link
- *                  javax.management.MBeanServerConnection#createMBean
- *                  createMBean} might not be supported by all
- *                  name spaces: <a href="#LocalNS">local</a> name spaces and
- *                  <a href="#LocalNS">remote</a> name spaces will usually
- *                  support it, but <a href="#VirtualNS">virtual</a> name
- *                  spaces and <a href="#CustomNS">custom</a> name
- *                  spaces might not.
- *              </p>
- *              <p>
- *                  In that case, they will throw an {@link
- *                  java.lang.UnsupportedOperationException
- *                  UnsupportedOperationException} usually wrapped into an {@link
- *                  javax.management.MBeanRegistrationException}.
- *              </p>
- *          </li>
- *          <li id="Notifications">
- *              <p>Notifications</p>
- *              <p> Some namespaces might not support JMX Notifications. In that
- *                  case, a call to add or remove notification listener for an
- *                  MBean contained in that name space will raise a
- *                  {@link javax.management.RuntimeOperationsException
- *                  RuntimeOperationsException} wrapping an {@link
- *                  java.lang.UnsupportedOperationException
- *                  UnsupportedOperationException} exception.
- *              </p>
- *          </li>
- *      </ul>
- *
- *      <h3 id="CrossingNamespace">Crossing Several Name Spaces</h3>
- *      <p>
- *          Just as folders can contain other folders, name spaces can contain
- *          other name spaces. For instance, if an {@code MBeanServer} <i>S1</i>
- *          containing a name space {@code "bar"} is mounted in another
- *          {@code MBeanServer} <i>S2</i> with name space {@code "foo"}, then
- *          an MBean <i>M1</i> named {@code "domain:type=Thing"} in namespace
- *          {@code "bar"} will appear as {@code "foo//bar//domain:type=Thing"} in
- *          {@code MBeanServer} <i>S2</i>.
- *      </p>
- *      <p>
- *          When accessing the MBean <i>M1</i> from server <i>S2</i>, the
- *          method call will traverse in a cascade {@code MBeanServer} <i>S2</i>,
- *          then the name space handler for name space {@code "foo"}, then
- *          {@code MBeanServer} <i>S1</i>, before coming to the name space
- *          handler for name space {@code "bar"}.  Any operation invoked
- *          on the MBean from a "top-level" name space will therefore need to
- *          traverse all the name spaces along the name space path until
- *          it eventually reaches the named MBean. This means that an operation
- *          like <a href="#registerMBean">registerMBean</a> for instance,
- *          can only succeed if all the name spaces along the path support it.
- *      </p>
- *      <p>
- *          Narrowing to a nested name space works just the same as narrowing
- *          to a top level name space:
- *      <pre>
- *          final MBeanServer S2 = .... ;
- *          final MBeanServer bar =
- *                JMXNamespaces.narrowToNamespace(S2, "foo//bar");
- *          final MBeanInfo info =
- *                foo.getMBeanInfo(new ObjectName("domain:type=Thing"));
- *      </pre>
- *      </p>
- *
- *      <h3 id="OperationResult">Name Spaces And Operation Results</h3>
- *      <p>
- *          Operation results, as well as attribute values returned by an MBean
- *          contained in a name space must be interpreted in the context of that
- *          name space.<br>
- *          In other words, if an MBean in name space "foo" has an attribute of
- *          type {@code ObjectName}, then it must be assumed that the
- *          {@code ObjectName} returned by that MBean is relative to
- *          name space "foo".<br>
- *          The same rule aplies for MBean names that can be returned by
- *          operations invoked on such an MBean. If one of the MBean operations
- *          return, say, a {@code Set<ObjectName>} then those MBean names must
- *          also be assumed to be relative to name space "foo".<br>
- *      </p>
- *      <p>
- *          In the usual case, a JMX client will first
- *          <a href="#ChangeTo">narrow to a name space</a> before invoking
- *          any operation on the MBeans it contains. In that case the names
- *          returned by the MBean invoked can be directly fed back to the
- *          narrowed connection.
- *          <br>
- *          If however, the JMX client directly invoked the MBean from a higher
- *          name space, without having narrowed to that name space first, then
- *          the names that might be returned by that MBean will not be directly
- *          usable - the JMX client will need to either
- *          <a href="#ChangeTo">narrow to the name space</a> before using the
- *          returned names, or convert the names to the higher level name space
- *          context.
- *          <br>
- *          The {@link javax.management.namespace.JMXNamespaces JMXNamespaces}
- *          class provides methods that can be used to perform that conversion.
- *      </p>
- *
- *      <h3 id="NamespacesAndNotifications">Name Spaces And Notifications</h3>
- *      <p>
- *          As <a href="#WhatIs">already explained</a>, name spaces are very
- *          similar to {@code MBeanServer}s. It is thus possible to get
- *          {@link javax.management.MBeanServerNotification MBeanServerNotifications}
- *          when MBeans are added or removed within a name space, by registering
- *          with the {@link javax.management.MBeanServerDelegate
- *          MBeanServerDelegate} MBean of the corresponding name space.<br>
- *          However, it must be noted that the notifications emitted by a
- *          name space must be interpreted in the context of that name space.
- *          For instance, if an MBean {@code "domain:type=Thing"} contained in
- *          namespace "foo//bar" emits a notification, the source of the
- *          notification will be {@code "domain:type=Thing"}, not
- *          {@code "foo//bar//domain:type=Thing"}. <br>
- *          It is therefore recommended to keep track of the name space
- *          information when registering a listener with an MBean contained in
- *          a name space, especially if the same listener is used to receive
- *          notifications from different name spaces. An easy solution is to
- *          use the handback, as illustrated in the code below.
- *          <pre>
- *            final MBeanServer server = ...;
- *            final NotificationListener listener = new NotificationListener() {
- *                public void handleNotification(Notification n, Object handback) {
- *                    if (!(n instanceof MBeanServerNotification)) {
- *                        System.err.println("Error: expected MBeanServerNotification");
- *                        return;
- *                    }
- *                    final MBeanServerNotification mbsn =
- *                            (MBeanServerNotification) n;
- *
- *                    // We will pass the namespace path in the handback.
- *                    //
- *                    // The received notification must be interpreted in
- *                    // the context of its source - therefore
- *                    // mbsn.getMBeanName() does not include the name space
- *                    // path...
- *                    //
- *                    final String namespace = (String) handback;
- *                    System.out.println("Received " + mbsn.getType() +
- *                            " for MBean " + mbsn.getMBeanName() +
- *                            " from name space " + namespace);
- *                }
- *            };
- *            server.addNotificationListener(JMXNamespaces.insertPath("foo//bar",
- *                    MBeanServerDelegate.DELEGATE_NAME),listener,null,"foo//bar");
- *            server.addNotificationListener(JMXNamespaces.insertPath("foo//joe",
- *                    MBeanServerDelegate.DELEGATE_NAME),listener,null,"foo//joe");
- *          </pre>
- *      </p>
- *      <p>
- *          JMX Connectors may require some configuration in order to be able
- *          to forward notifications from MBeans located in name spaces.
- *          The RMI JMX Connector Server
- *          in the Java SE 7 platform is configured by default to internally
- *          use the new {@linkplain javax.management.event event service} on
- *          the server side.
- *          When the connector server is configured in this way, JMX clients
- *          which use the old JMX Notifications mechanism (such as clients
- *          running on prior versions of the JDK) will be able to
- *          to receive notifications from MBeans located in sub name spaces.
- *          This is because the connector server will transparently delegate
- *          their subscriptions to the underlying {@linkplain
- *          javax.management.event event service}. In summary:
- *          <ul>
- *              <li>
- *                  On the server side: When exporting an {@code MBeanServer}
- *                  through a JMX Connector, you will need to make sure that the
- *                  connector server uses the new {@linkplain javax.management.event
- *                  event service} in order to register for notifications. If the
- *                  connector server doesn't use the event service, only clients
- *                  which explicitly use the new {@linkplain javax.management.event
- *                  event service} will be able to register for notifications
- *                  with MBeans located in sub name spaces.
- *              </li>
- *              <li>
- *                  On the client side: if the JMX Connector server (on the remote
- *                  server side) was configured to internally use the new
- *                  {@linkplain javax.management.event
- *                  event service}, then clients can continue to use the old
- *                  {@code MBeanServerConnection} add / remove notification
- *                  listener methods transparently. Otherwise, only clients which
- *                  explicitly use the new {@linkplain javax.management.event
- *                  event service} will be able to receive notifications from
- *                  MBeans contained in sub name spaces.
- *              </li>
- *          </ul>
- *      </p>
- *      <p>
- *          These configuration issues apply at each node in the name space path,
- *          whenever the name space points to a remote server. The
- *          {@link javax.management.namespace.JMXRemoteNamespace
- *          JMXRemoteNamespace} can be configured in such a way that it will
- *          explicitly use an {@link javax.management.event.EventClient EventClient}
- *          when forwarding subscription to the remote side. Note that this can be
- *          unnecessary (and a waste of resources) if the underlying JMXConnector
- *          returned by the JMXConnectorFactory (client side) already uses the
- *          {@linkplain javax.management.event event service} to register for
- *          notifications with the server side.
- *      </p>
- *
- *      <h3 id="Security">Name Spaces And Access Control</h3>
- *      <p>
- *          Access to MBeans exposed through JMX namespaces is controlled by
- *          {@linkplain javax.management.namespace.JMXNamespacePermission
- *           jmx namespace permissions}. These permissions are checked by the
- *          MBeanServer in which the {@link
- *            javax.management.namespace.JMXNamespace JMXNamespace} MBean is registered.
- *          This is <a href="JMXNamespace.html#PermissionChecks">described in
- *          details</a> in the {@link
- *            javax.management.namespace.JMXNamespace JMXNamespace} class.
- *      </p>
- *      <p>
- *         To implement a "firewall-like" access control in a JMX agent you
- *         can also place an {@link
- *         javax.management.remote.MBeanServerForwarder} in the JMX Connector
- *         Server which exposes the top-level MBeanServer of your application.
- *         This {@code MBeanServerForwarder} will be able to perform
- *         authorization checks for all MBeans, including those located in
- *         sub name spaces.
- *      </p>
- *      <p>
- *         For a tighter access control we recommend using a {@link
- *         java.lang.SecurityManager security manager}.
- *      </p>
- * @since 1.7
- * <p></p>
- **/
-
-package javax.management.namespace;
-
--- a/src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/openmbean/CompositeDataInvocationHandler.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
 package javax.management.openmbean;
 
 import com.sun.jmx.mbeanserver.MXBeanLookup;
+import com.sun.jmx.mbeanserver.MXBeanMapping;
+import com.sun.jmx.mbeanserver.MXBeanMappingFactory;
 import com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
@@ -115,12 +117,7 @@
        is null.
     */
     public CompositeDataInvocationHandler(CompositeData compositeData) {
-        this(compositeData, MXBeanMappingFactory.DEFAULT);
-    }
-
-    public CompositeDataInvocationHandler(CompositeData compositeData,
-                                          MXBeanMappingFactory mappingFactory) {
-        this(compositeData, mappingFactory, null);
+        this(compositeData, null);
     }
 
     /**
@@ -139,13 +136,11 @@
        is null.
     */
     CompositeDataInvocationHandler(CompositeData compositeData,
-                                   MXBeanMappingFactory mappingFactory,
                                    MXBeanLookup lookup) {
         if (compositeData == null)
             throw new IllegalArgumentException("compositeData");
         this.compositeData = compositeData;
         this.lookup = lookup;
-        this.mappingFactory = mappingFactory;
     }
 
     /**
@@ -204,7 +199,7 @@
             }
         }
         MXBeanMapping mapping =
-            mappingFactory.mappingForType(method.getGenericReturnType(),
+            MXBeanMappingFactory.DEFAULT.mappingForType(method.getGenericReturnType(),
                                    MXBeanMappingFactory.DEFAULT);
         return mapping.fromOpenValue(openValue);
     }
@@ -250,5 +245,4 @@
 
     private final CompositeData compositeData;
     private final MXBeanLookup lookup;
-    private final MXBeanMappingFactory mappingFactory;
 }
--- a/src/share/classes/javax/management/openmbean/CompositeDataSupport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/openmbean/CompositeDataSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -92,16 +92,16 @@
      * @param itemNames <tt>itemNames</tt> must list, in any order, all the
      * item names defined in <tt>compositeType</tt>; the order in which the
      * names are listed, is used to match values in <tt>itemValues[]</tt>; must
-     * not be null.
+     * not be null or empty.
      *
      * @param itemValues the values of the items, listed in the same order as
      * their respective names in <tt>itemNames</tt>; each item value can be
      * null, but if it is non-null it must be a valid value for the open type
      * defined in <tt>compositeType</tt> for the corresponding item; must be of
-     * the same size as <tt>itemNames</tt>; must not be null.
+     * the same size as <tt>itemNames</tt>; must not be null or empty.
      *
      * @throws IllegalArgumentException <tt>compositeType</tt> is null, or
-     * <tt>itemNames[]</tt> or <tt>itemValues[]</tt> is null, or one
+     * <tt>itemNames[]</tt> or <tt>itemValues[]</tt> is null or empty, or one
      * of the elements in <tt>itemNames[]</tt> is a null or empty string, or
      * <tt>itemNames[]</tt> and <tt>itemValues[]</tt> are not of the same size.
      *
@@ -124,6 +124,8 @@
 
         if (itemNames == null || itemValues == null)
             throw new IllegalArgumentException("Null itemNames or itemValues");
+        if (itemNames.length == 0 || itemValues.length == 0)
+            throw new IllegalArgumentException("Empty itemNames or itemValues");
         if (itemNames.length != itemValues.length) {
             throw new IllegalArgumentException(
                     "Different lengths: itemNames[" + itemNames.length +
@@ -154,10 +156,10 @@
      *                        must not be null.
      * @param  items  the mappings of all the item names to their values;
      *                <tt>items</tt> must contain all the item names defined in <tt>compositeType</tt>;
-     *                must not be null.
+     *                must not be null or empty.
      *
      * @throws IllegalArgumentException <tt>compositeType</tt> is null, or
-     * <tt>items</tt> is null, or one of the keys in <tt>items</tt> is a null
+     * <tt>items</tt> is null or empty, or one of the keys in <tt>items</tt> is a null
      * or empty string.
      * @throws OpenDataException <tt>items</tt>' size differs from the
      * number of items defined in <tt>compositeType</tt>, or one of the
@@ -167,8 +169,6 @@
      * <tt>compositeType</tt>.
      * @throws ArrayStoreException one or more keys in <tt>items</tt> is not of
      * the class <tt>java.lang.String</tt>.
-     *
-     * @see #toMap
      */
     public CompositeDataSupport(CompositeType compositeType,
                                 Map<String,?> items)
@@ -177,13 +177,13 @@
     }
 
     private static SortedMap<String, Object> makeMap(Map<String, ?> items) {
-        if (items == null)
-            throw new IllegalArgumentException("Null items map");
-        if (items.containsKey(null) || items.containsKey(""))
-            throw new IllegalArgumentException("Null or empty item name");
+        if (items == null || items.isEmpty())
+            throw new IllegalArgumentException("Null or empty items map");
 
         SortedMap<String, Object> map = new TreeMap<String, Object>();
         for (Object key : items.keySet()) {
+            if (key == null || key.equals(""))
+                throw new IllegalArgumentException("Null or empty item name");
             if (!(key instanceof String)) {
                 throw new ArrayStoreException("Item name is not string: " + key);
                 // This can happen because of erasure.  The particular
@@ -329,54 +329,6 @@
     }
 
     /**
-     * <p>Returns a Map representing the contents of the given CompositeData.
-     * Each item in the CompositeData is represented by an entry in the map,
-     * where the name and value of the item are the key and value of the entry.
-     * The returned value is modifiable but modifications to it have no effect
-     * on the original CompositeData.</p>
-     *
-     * <p>For example, if you have a CompositeData {@code cd1} and you want
-     * to produce another CompositeData {@code cd2} which is the same except
-     * that the value of its {@code id} item has been changed to 253, you
-     * could write:</p>
-     *
-     * <pre>
-     * CompositeData cd1 = ...;
-     * {@code Map<String, Object>} map = CompositeDataSupport.toMap(cd1);
-     * assert(map.get("id") instanceof Integer);
-     * map.put("id", 253);
-     * CompositeData cd2 = {@link #CompositeDataSupport(CompositeType, Map)
-     * new CompositeDataSupport}(cd1.getCompositeType(), map);
-     * </pre>
-     *
-     * <p>Logically, this method would be a method in the {@link CompositeData}
-     * interface, but cannot be for compatibility reasons.</p>
-     *
-     * @param cd the CompositeData to convert to a Map.
-     *
-     * @return a Map that is a copy of the contents of {@code cd}.
-     *
-     * @throws IllegalArgumentException if {@code cd} is null.
-     *
-     * @see #CompositeDataSupport(CompositeType, Map)
-     */
-    public static Map<String, Object> toMap(CompositeData cd) {
-        if (cd == null)
-            throw new IllegalArgumentException("Null argument");
-
-        // If we really wanted, we could check whether cd is a
-        // CompositeDataSupport and return a copy of cd.contents if so,
-        // but I don't think that would be substantially faster.
-        Map<String, Object> map = new LinkedHashMap<String, Object>();
-        CompositeType ct = cd.getCompositeType();
-        for (String key : ct.keySet()) {
-            Object value = cd.get(key);
-            map.put(key, value);
-        }
-        return map;
-    }
-
-    /**
      * Compares the specified <var>obj</var> parameter with this
      * <code>CompositeDataSupport</code> instance for equality.
      * <p>
--- a/src/share/classes/javax/management/openmbean/CompositeType.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/openmbean/CompositeType.java	Wed Nov 25 11:08:25 2009 -0800
@@ -89,7 +89,7 @@
      * <br>&nbsp;
      * @param  itemNames  The names of the items contained in the
      *                    composite data values described by this <code>CompositeType</code> instance;
-     *                    cannot be null; no element can be null or an empty string.
+     *                    cannot be null and should contain at least one element; no element can be a null or empty string.
      *                    Note that the order in which the item names are given is not important to differentiate a
      *                    <code>CompositeType</code> instance from another;
      *                    the item names are internally stored sorted in ascending alphanumeric order.
@@ -125,7 +125,7 @@
         //
         super(CompositeData.class.getName(), typeName, description, false);
 
-        // Check the 3 arrays are not null and that there is no null element or empty string in them
+        // Check the 3 arrays are not null or empty (ie length==0) and that there is no null element or empty string in them
         //
         checkForNullElement(itemNames, "itemNames");
         checkForNullElement(itemDescriptions, "itemDescriptions");
@@ -159,8 +159,8 @@
     }
 
     private static void checkForNullElement(Object[] arg, String argName) {
-        if (arg == null) {
-            throw new IllegalArgumentException("Argument "+ argName +"[] cannot be null.");
+        if ( (arg == null) || (arg.length == 0) ) {
+            throw new IllegalArgumentException("Argument "+ argName +"[] cannot be null or empty.");
         }
         for (int i=0; i<arg.length; i++) {
             if (arg[i] == null) {
--- a/src/share/classes/javax/management/openmbean/MXBeanMapping.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,210 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.openmbean;
-
-import java.io.InvalidObjectException;
-import java.lang.reflect.Type;
-
-/**
- * <p>A custom mapping between Java types and Open types for use in MXBeans.
- * To define such a mapping, subclass this class and define at least the
- * {@link #fromOpenValue fromOpenValue} and {@link #toOpenValue toOpenValue}
- * methods, and optionally the {@link #checkReconstructible} method.
- * Then either use an {@link MXBeanMappingClass} annotation on your custom
- * Java types, or include this MXBeanMapping in an
- * {@link MXBeanMappingFactory}.</p>
- *
- * <p>For example, suppose we have a class {@code MyLinkedList}, which looks
- * like this:</p>
- *
- * <pre>
- * public class MyLinkedList {
- *     public MyLinkedList(String name, MyLinkedList next) {...}
- *     public String getName() {...}
- *     public MyLinkedList getNext() {...}
- * }
- * </pre>
- *
- * <p>This is not a valid type for MXBeans, because it contains a
- * self-referential property "next" defined by the {@code getNext()}
- * method.  MXBeans do not support recursive types.  So we would like
- * to specify a mapping for {@code MyLinkedList} explicitly. When an
- * MXBean interface contains {@code MyLinkedList}, that will be mapped
- * into a {@code String[]}, which is a valid Open Type.</p>
- *
- * <p>To define this mapping, we first subclass {@code MXBeanMapping}:</p>
- *
- * <pre>
- * public class MyLinkedListMapping extends MXBeanMapping {
- *     public MyLinkedListMapping(Type type) throws OpenDataException {
- *         super(MyLinkedList.class, ArrayType.getArrayType(SimpleType.STRING));
- *         if (type != MyLinkedList.class)
- *             throw new OpenDataException("Mapping only valid for MyLinkedList");
- *     }
- *
- *     {@literal @Override}
- *     public Object fromOpenValue(Object openValue) throws InvalidObjectException {
- *         String[] array = (String[]) openValue;
- *         MyLinkedList list = null;
- *         for (int i = array.length - 1; i &gt;= 0; i--)
- *             list = new MyLinkedList(array[i], list);
- *         return list;
- *     }
- *
- *     {@literal @Override}
- *     public Object toOpenValue(Object javaValue) throws OpenDataException {
- *         ArrayList&lt;String&gt; array = new ArrayList&lt;String&gt;();
- *         for (MyLinkedList list = (MyLinkedList) javaValue; list != null;
- *              list = list.getNext())
- *             array.add(list.getName());
- *         return array.toArray(new String[0]);
- *     }
- * }
- * </pre>
- *
- * <p>The call to the superclass constructor specifies what the
- * original Java type is ({@code MyLinkedList.class}) and what Open
- * Type it is mapped to ({@code
- * ArrayType.getArrayType(SimpleType.STRING)}). The {@code
- * fromOpenValue} method says how we go from the Open Type ({@code
- * String[]}) to the Java type ({@code MyLinkedList}), and the {@code
- * toOpenValue} method says how we go from the Java type to the Open
- * Type.</p>
- *
- * <p>With this mapping defined, we can annotate the {@code MyLinkedList}
- * class appropriately:</p>
- *
- * <pre>
- * {@literal @MXBeanMappingClass}(MyLinkedListMapping.class)
- * public class MyLinkedList {...}
- * </pre>
- *
- * <p>Now we can use {@code MyLinkedList} in an MXBean interface and it
- * will work.</p>
- *
- * <p>If we are unable to modify the {@code MyLinkedList} class,
- * we can define an {@link MXBeanMappingFactory}.  See the documentation
- * of that class for further details.</p>
- *
- * @see <a href="../MXBean.html#custom">MXBean specification, section
- * "Custom MXBean type mappings"</a>
- */
-public abstract class MXBeanMapping {
-    private final Type javaType;
-    private final OpenType<?> openType;
-    private final Class<?> openClass;
-
-    /**
-     * <p>Construct a mapping between the given Java type and the given
-     * Open Type.</p>
-     *
-     * @param javaType the Java type (for example, {@code MyLinkedList}).
-     * @param openType the Open Type (for example, {@code
-     * ArrayType.getArrayType(SimpleType.STRING)})
-     *
-     * @throws NullPointerException if either argument is null.
-     */
-    protected MXBeanMapping(Type javaType, OpenType<?> openType) {
-        if (javaType == null || openType == null)
-            throw new NullPointerException("Null argument");
-        this.javaType = javaType;
-        this.openType = openType;
-        this.openClass = makeOpenClass(javaType, openType);
-    }
-
-    /**
-     * <p>The Java type that was supplied to the constructor.</p>
-     * @return the Java type that was supplied to the constructor.
-     */
-    public final Type getJavaType() {
-        return javaType;
-    }
-
-    /**
-     * <p>The Open Type that was supplied to the constructor.</p>
-     * @return the Open Type that was supplied to the constructor.
-     */
-    public final OpenType<?> getOpenType() {
-        return openType;
-    }
-
-    /**
-     * <p>The Java class that corresponds to instances of the
-     * {@linkplain #getOpenType() Open Type} for this mapping.</p>
-     * @return the Java class that corresponds to instances of the
-     * Open Type for this mapping.
-     * @see OpenType#getClassName
-     */
-    public final Class<?> getOpenClass() {
-        return openClass;
-    }
-
-    private static Class<?> makeOpenClass(Type javaType, OpenType<?> openType) {
-        if (javaType instanceof Class<?> && ((Class<?>) javaType).isPrimitive())
-            return (Class<?>) javaType;
-        try {
-            String className = OpenType.validClassName(openType.getClassName());
-            return Class.forName(className, false, null);
-        } catch (ClassNotFoundException e) {
-            throw new RuntimeException(e);  // should not happen
-        } catch (OpenDataException e) {
-            throw new IllegalArgumentException("Bad OpenType: " + openType, e);
-        }
-    }
-
-    /**
-     * <p>Convert an instance of the Open Type into the Java type.
-     * @param openValue the value to be converted.
-     * @return the converted value.
-     * @throws InvalidObjectException if the value cannot be converted.
-     */
-    public abstract Object fromOpenValue(Object openValue)
-    throws InvalidObjectException;
-
-    /**
-     * <p>Convert an instance of the Java type into the Open Type.
-     * @param javaValue the value to be converted.
-     * @return the converted value.
-     * @throws OpenDataException if the value cannot be converted.
-     */
-    public abstract Object toOpenValue(Object javaValue)
-    throws OpenDataException;
-
-
-    /**
-     * <p>Throw an appropriate InvalidObjectException if we will not
-     * be able to convert back from the open data to the original Java
-     * object.  The {@link #fromOpenValue fromOpenValue} throws an
-     * exception if a given open data value cannot be converted.  This
-     * method throws an exception if <em>no</em> open data values can
-     * be converted.  The default implementation of this method never
-     * throws an exception.  Subclasses can override it as
-     * appropriate.</p>
-     * @throws InvalidObjectException if {@code fromOpenValue} will throw
-     * an exception no matter what its argument is.
-     */
-    public void checkReconstructible() throws InvalidObjectException {}
-}
--- a/src/share/classes/javax/management/openmbean/MXBeanMappingClass.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.openmbean;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.management.NotCompliantMBeanException;
-
-/**
- * Specifies the MXBean mapping to be used for this Java type.
- * @see MXBeanMapping
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented @Inherited
-public @interface MXBeanMappingClass {
-    /**
-     * <p>The {@link MXBeanMapping} class to be used to map the
-     * annotated type.  This class must have a public constructor with
-     * a single argument of type {@link java.lang.reflect.Type}.  The
-     * constructor will be called with the annotated type as an
-     * argument.  See the {@code MXBeanMapping} documentation
-     * for an example.</p>
-     *
-     * <p>If the {@code MXBeanMapping} cannot in fact handle that
-     * type, the constructor should throw an {@link
-     * OpenDataException}.  If the constructor throws this or any other
-     * exception then an MXBean in which the annotated type appears is
-     * invalid, and registering it in the MBean Server will produce a
-     * {@link NotCompliantMBeanException}.
-     */
-    public Class<? extends MXBeanMapping> value();
-}
--- a/src/share/classes/javax/management/openmbean/MXBeanMappingFactory.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.openmbean;
-
-import com.sun.jmx.mbeanserver.DefaultMXBeanMappingFactory;
-import java.lang.reflect.Type;
-
-/**
- * <p>Defines how types are mapped for a given MXBean or set of MXBeans.
- * An {@code MXBeanMappingFactory} can be specified either through the
- * {@link MXBeanMappingFactoryClass} annotation, or through the
- * {@link javax.management.JMX.MBeanOptions JMX.MBeanOptions} argument to a
- * {@link javax.management.StandardMBean StandardMBean} constructor or MXBean
- * proxy.</p>
- *
- * <p>An {@code MXBeanMappingFactory} must return an {@code MXBeanMapping}
- * for any Java type that appears in the MXBeans that the factory is being
- * used for.  Usually it does that by handling any custom types, and
- * forwarding everything else to the {@linkplain #DEFAULT default mapping
- * factory}.</p>
- *
- * <p>Consider the {@code MyLinkedList} example from the {@link MXBeanMapping}
- * documentation.  If we are unable to change the {@code MyLinkedList} class
- * to add an {@link MXBeanMappingClass} annotation, we could achieve the same
- * effect by defining {@code MyLinkedListMappingFactory} as follows:</p>
- *
- * <pre>
- * public class MyLinkedListMappingFactory extends MXBeanMappingFactory {
- *     public MyLinkedListMappingFactory() {}
- *
- *     public MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f)
- *     throws OpenDataException {
- *         if (t == MyLinkedList.class)
- *             return new MyLinkedListMapping(t);
- *         else
- *             return MXBeanMappingFactory.DEFAULT.mappingForType(t, f);
- *     }
- * }
- * </pre>
- *
- * <p>The mapping factory handles only the {@code MyLinkedList} class.
- * Every other type is forwarded to the default mapping factory.
- * This includes types such as {@code MyLinkedList[]} and
- * {@code List<MyLinkedList>}; the default mapping factory will recursively
- * invoke {@code MyLinkedListMappingFactory} to map the contained
- * {@code MyLinkedList} type.</p>
- *
- * <p>Once we have defined {@code MyLinkedListMappingFactory}, we can use
- * it in an MXBean interface like this:</p>
- *
- * <pre>
- * {@literal @MXBeanMappingFactoryClass}(MyLinkedListMappingFactory.class)
- * public interface SomethingMXBean {
- *     public MyLinkedList getSomething();
- * }
- * </pre>
- *
- * <p>Alternatively we can annotate the package that {@code SomethingMXBean}
- * appears in, or we can supply the factory to a {@link
- * javax.management.StandardMBean StandardMBean} constructor or MXBean
- * proxy.</p>
- *
- * @see <a href="../MXBean.html#custom">MXBean specification, section
- * "Custom MXBean type mappings"</a>
- */
-public abstract class MXBeanMappingFactory {
-    /**
-     * <p>Construct an instance of this class.</p>
-     */
-    protected MXBeanMappingFactory() {}
-
-    /**
-     * <p>Mapping factory that applies the default rules for MXBean
-     * mappings, as described in the <a
-     * href="../MXBean.html#MXBean-spec">MXBean specification</a>.</p>
-     */
-    public static final MXBeanMappingFactory DEFAULT =
-            new DefaultMXBeanMappingFactory();
-
-    /**
-     * <p>Determine the appropriate MXBeanMappingFactory to use for the given
-     * MXBean interface, based on its annotations.  If the interface has an
-     * {@link MXBeanMappingFactoryClass @MXBeanMappingFactoryClass} annotation,
-     * that is used to determine the MXBeanMappingFactory.  Otherwise, if the
-     * package containing the interface has such an annotation, that is used.
-     * Otherwise the MXBeanMappingFactory is the {@linkplain #DEFAULT default}
-     * one.</p>
-     *
-     * @param intf the MXBean interface for which to determine the
-     * MXBeanMappingFactory.
-     *
-     * @return the MXBeanMappingFactory for the given MXBean interface.
-     *
-     * @throws IllegalArgumentException if {@code intf} is null, or if an
-     * exception occurs while trying constructing an MXBeanMappingFactory
-     * based on an annotation.  In the second case, the exception will appear
-     * in the {@linkplain Throwable#getCause() cause chain} of the
-     * {@code IllegalArgumentException}.
-     */
-    public static MXBeanMappingFactory forInterface(Class<?> intf) {
-        if (intf == null)
-            throw new IllegalArgumentException("Null interface");
-        MXBeanMappingFactoryClass annot =
-                intf.getAnnotation(MXBeanMappingFactoryClass.class);
-        if (annot == null) {
-            Package p = intf.getPackage();
-            if (p != null)
-                annot = p.getAnnotation(MXBeanMappingFactoryClass.class);
-        }
-        if (annot == null)
-            return MXBeanMappingFactory.DEFAULT;
-        Class<? extends MXBeanMappingFactory> factoryClass = annot.value();
-        try {
-            return annot.value().newInstance();
-        } catch (Exception e) {
-            throw new IllegalArgumentException(
-                    "Could not instantiate MXBeanMappingFactory " +
-                    factoryClass.getName() +
-                    " from @MXBeanMappingFactoryClass", e);
-        }
-    }
-
-    /**
-     * <p>Return the mapping for the given Java type.  Typically, a
-     * mapping factory will return mappings for types it handles, and
-     * forward other types to another mapping factory, most often
-     * the {@linkplain #DEFAULT default one}.</p>
-     * @param t the Java type to be mapped.
-     * @param f the original mapping factory that was consulted to do
-     * the mapping.  A mapping factory should pass this parameter intact
-     * if it forwards a type to another mapping factory.  In the example,
-     * this is how {@code MyLinkedListMappingFactory} works for types
-     * like {@code MyLinkedList[]} and {@code List<MyLinkedList>}.
-     * @return the mapping for the given type.
-     * @throws OpenDataException if this type cannot be mapped.  This
-     * exception is appropriate if the factory is supposed to handle
-     * all types of this sort (for example, all linked lists), but
-     * cannot handle this particular type.
-     */
-    public abstract MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f)
-    throws OpenDataException;
-}
--- a/src/share/classes/javax/management/openmbean/MXBeanMappingFactoryClass.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * 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.
- */
-
-package javax.management.openmbean;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * <p>Specifies the MXBean mapping factory to be used for Java types
- * in an MXBean interface, or in all MXBean interfaces in a package.</p>
- *
- * <p>Applying a mapping factory to all Java types in an MXBean interface
- * looks like this:</p>
- *
- * <pre>
- * {@literal @MXBeanMappingFactoryClass}(MyLinkedListMappingFactory.class)
- * public interface SomethingMXBean {
- *     public MyLinkedList getSomething();
- * }
- * </pre>
- *
- * <p>Applying a mapping factory to all Java types in all MXBean interfaces
- * in a package, say {@code com.example.mxbeans}, looks like this.  In the
- * package source directory, create a file called {@code package-info.java}
- * with these contents:</p>
- *
- * <pre>
- * {@literal @MXBeanMappingFactoryClass}(MyLinkedListMappingFactory.class)
- * package com.example.mxbeans;
- * </pre>
- *
- * @see MXBeanMappingFactory
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.PACKAGE})
-@Documented @Inherited
-public @interface MXBeanMappingFactoryClass {
-    /**
-     * <p>The {@link MXBeanMappingFactory} class to be used to map
-     * types in the annotated interface or package.  This class must
-     * have a public constructor with no arguments.  See the {@code
-     * MXBeanMappingFactory} documentation for an example.</p>
-     */
-    public Class<? extends MXBeanMappingFactory> value();
-}
--- a/src/share/classes/javax/management/openmbean/OpenType.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/openmbean/OpenType.java	Wed Nov 25 11:08:25 2009 -0800
@@ -219,7 +219,7 @@
         });
     }
 
-    static String validClassName(String className) throws OpenDataException {
+    private static String validClassName(String className) throws OpenDataException {
         className   = valid("className", className);
 
         // Check if className describes an array class, and determines its elements' class name.
--- a/src/share/classes/javax/management/package.html	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/package.html	Wed Nov 25 11:08:25 2009 -0800
@@ -128,42 +128,6 @@
         class.</p>
 
 
-        <h3 id="stdannot">Defining Standard MBeans with annotations</h3>
-
-        <p>As an alternative to creating an interface such as
-            <code>ConfigurationMBean</code> and a class that implements it,
-            you can write just the class, and use annotations to pick out the
-            public methods that will make up the management interface. For
-            example, the following class has the same management interface
-            as a <code>Configuration</code> class that implements the
-        <code>ConfigurationMBean</code> interface above.</p>
-
-        <pre>
-    {@link javax.management.MBean @MBean}
-    public class Configuration {
-        {@link javax.management.ManagedAttribute @ManagedAttribute}
-        public int getCacheSize() {...}
-        &#64;ManagedAttribute
-        public void setCacheSize(int size) {...}
-
-        &#64;ManagedAttribute
-        public long getLastChangedTime() {...}
-
-        {@link javax.management.ManagedOperation @ManagedOperation}
-        public void save() {...}
-        ...
-    }
-        </pre>
-
-        <p>This approach simplifies development, but it does have two
-            potential drawbacks.  First, if you run the Javadoc tool on
-            this class, the documentation of the management interface may
-            be mixed in with the documentation of non-management methods
-            in the class.  Second, you cannot make a proxy
-            as described <a href="#proxy">below</a> if you do not have an
-        interface like <code>ConfigurationMBean</code>.</p>
-
-
         <h3>MXBeans</h3>
 
         <p>An <em>MXBean</em> is a variant of Standard MBean where complex
@@ -173,11 +137,6 @@
             classes in your MBean interface.  They are described in detail
         in the specification for {@link javax.management.MXBean MXBean}.</p>
 
-        <p>You can define MXBeans using annotations as described
-            in the <a href="#stdannot">previous section</a>, but
-            using the <code>&#64;MXBean</code> annotation instead of
-        <code>&#64;MBean</code>.</p>
-
 
         <h3>Dynamic MBeans</h3>
 
@@ -305,7 +264,7 @@
         perform the query.</p>
 
 
-        <h3>MBean lifecycle and resource injection</h3>
+        <h3>MBean lifecycle</h3>
 
         <p>An MBean can implement the {@link javax.management.MBeanRegistration
             MBeanRegistration} interface in order to be told when it is registered
@@ -315,11 +274,6 @@
             object and to get its <code>ObjectName</code> within the MBean
         Server.</p>
 
-        <p>If the only reason to implement <code>MBeanRegistration</code> is to
-            discover the <code>MBeanServer</code> and <code>ObjectName</code>, <a
-                href="MBeanRegistration.html#injection">resource injection</a> may be
-        more convenient.</p>
-
 
         <h2>Notifications</h2>
 
@@ -329,26 +283,16 @@
             <em>type</em> string that can distinguish it from other
         notifications of the same class.</p>
 
-        <p>If an MBean is to emit notifications, it must do one of two things.</p>
-
-        <ul>
-            <li>It can implement the interface {@link
-                javax.management.NotificationEmitter NotificationEmitter} (or
-                its parent {@link javax.management.NotificationBroadcaster
-                NotificationBroadcaster}), usually by subclassing
-                {@link javax.management.NotificationBroadcasterSupport
-                NotificationBroadcasterSupport} or delegating to an instance of
-            that class.</li>
-            <li>It can use <a href="MBeanRegistration.html#injection">resource
-                injection</a> to obtain a {@link javax.management.SendNotification
-                SendNotification} object that it can use to send
-            notifications.</li>
-        </ul>
-
-        <p>The two classes below illustrate these two techniques:</p>
+        <p>An MBean that will emit notifications must implement the
+            {@link javax.management.NotificationBroadcaster
+            NotificationBroadcaster} or {@link
+            javax.management.NotificationEmitter NotificationEmitter}
+            interface.  Usually, it does this by subclassing
+            {@link javax.management.NotificationBroadcasterSupport
+            NotificationBroadcasterSupport} or delegating to an instance of
+        that class. Here is an example:</p>
 
         <pre>
-    // Implementing NotificationEmitter (via NotificationBroadcasterSupport)
     public class Configuration <b>extends NotificationBroadcasterSupport</b>
             implements ConfigurationMBean {
         ...
@@ -358,17 +302,6 @@
             sendNotification}(n)</b>;
         }
     }
-
-    // Getting a SendNotification through resource injection
-    public class Configuration implements ConfigurationMBean {
-        <b>&#64;Resource</b>
-        private volatile SendNotification sender;
-        ...
-        private void updated() {
-            Notification n = new Notification(...);
-            <b>sender.sendNotification(n)</b>;
-        }
-    }
         </pre>
 
 
@@ -410,88 +343,51 @@
 	<h3 id="interop">Interoperability between versions of the JMX
 	  specification</h3>
 
-	<p>When a client connects to a server using the JMX Remote
-	  API, it is possible that they do not have the same version
-	  of the JMX specification.  The version of the JMX
-	  specification described here is version 2.0.  Previous
-	  versions were 1.0, 1.1, 1.2, and 1.4.  (There was no 1.3.)
-	  The standard JMX Remote API is defined to work with version
-	  1.2 onwards, so in standards-based deployment the only
-	  interoperability questions that arise concern version 1.2
-	  onwards.</p>
+        <p>When a client connects to a server using the JMX Remote
+            API, it is possible that they do not have the same version
+            of the JMX specification.  The version of the JMX
+            specification described here is version 1.4.  Previous
+            versions were 1.0, 1.1, and 1.2.  (There was no 1.3.)
+            The standard JMX Remote API is defined to work with version
+            1.2 onwards, so in standards-based deployment the only
+            interoperability questions that arise concern version 1.2
+        onwards.</p>
 
-	<p>Every version of the JMX specification continues to
-	  implement the features of previous versions.  So when the
-	  client is running an earlier version than the server, there
-	  should not be any interoperability concerns.  The only
-	  exception is the unlikely one where a pre-2.0 client used
-	  the string {@code //} in the domain part of an {@link
-	  javax.management.ObjectName ObjectName}.</p>
+        <p>Every version of the JMX specification continues to
+            implement the features of previous versions.  So when the
+            client is running an earlier version than the server, there
+            should not be any interoperability concerns.</p>
 
-	<p>When the client is running a later version than the server,
-	  certain newer features may not be available, as detailed in
-	  the next sections.  The method {@link
-	  javax.management.JMX#getSpecificationVersion
-	  JMX.getSpecificationVersion} can be used to determine the
-	  server version to check if required features are
-	  available.</p>
+        <p>When the client is running a later version than the server,
+            certain newer features may not be available, as detailed in
+            the next sections.  The client can determine the server's
+            version by examining the {@link
+            javax.management.MBeanServerDelegateMBean#getSpecificationVersion
+            SpecificationVersion} attribute of the {@code
+        MBeanServerDelegate}.</p>
 
-	<h4 id="interop-1.4">If the remote MBean Server is 1.4</h4>
+        <h4 id="interop-1.2">If the remote MBean Server is 1.2</h4>
 
 	<ul>
 
-	  <li><p>You cannot use {@link
-	      javax.management.QueryNotificationFilter
-	      QueryNotificationFilter} in {@link
-	      javax.management.MBeanServerConnection#addNotificationListener
-	      addNotificationListener} since this class did not exist
-	      in 1.4.</p>
-
-	  <li><p>In an attribute in a query, you cannot access values
-	      inside complex types using dot syntax, for example
-	      {@link javax.management.Query#attr Query.attr}{@code
-	      ("HeapMemoryUsage.used")}.</p>
-
-	  <li><p>The packages {@link javax.management.event} and
-	      {@link javax.management.namespace} did not exist in 1.4,
-	      so you cannot remotely create instances of the MBeans
-	      they define.</p>
+            <li><p>You cannot use wildcards in a key property of an
+                {@link javax.management.ObjectName ObjectName}, for
+                example {@code domain:type=Foo,name=*}. Wildcards that
+                match whole properties are still allowed, for example
+            {@code *:*} or {@code *:type=Foo,*}.</p>
 
-	  <li><p>Even if the remote MBean Server is 2.0, you cannot in
-	      general suppose that {@link
-	      javax.management.event.EventClient EventClient} or
-	      {@link javax.management.ClientContext ClientContext}
-	      will work there without first checking. If the remote
-	      MBean Server is 1.4 then those checks will return false.
-	      An attempt to use these features without checking will
-	      fail in the same way as for a remote 2.0 that is not
-	      configured to support them.</p>
-	</ul>
-
-	<h4 id="interop-1.2">If the remote MBean Server is 1.2</h4>
-
-	<p><b>In addition to the above</b>,</p>
-
-	<ul>
+            <li><p>You cannot use {@link
+                javax.management.Query#isInstanceOf Query.isInstanceOf}
+            in a query.</p>
 
-	  <li><p>You cannot use wildcards in a key property of an
-	      {@link javax.management.ObjectName ObjectName}, for
-	      example {@code domain:type=Foo,name=*}. Wildcards that
-	      match whole properties are still allowed, for example
-	      {@code *:*} or {@code *:type=Foo,*}.</p>
+            <li><p>You cannot use dot syntax such as {@code
+                HeapMemoryUsage.used} in the {@linkplain
+                javax.management.monitor.Monitor#setObservedAttribute
+                observed attribute} of a monitor, as described in the
+                documentation for the {@link javax.management.monitor}
+            package.</p>
 
-	  <li><p>You cannot use {@link
-	      javax.management.Query#isInstanceOf Query.isInstanceOf}
-	      in a query.</p>
-
-	  <li><p>You cannot use dot syntax such as {@code
-	      HeapMemoryUsage.used} in the {@linkplain
-	      javax.management.monitor.Monitor#setObservedAttribute
-	      observed attribute} of a monitor, as described in the
-	      documentation for the {@link javax.management.monitor}
-	      package.</p>
-
-	</ul>
+        </ul>
 
         <p id="spec">
         @see <a href="{@docRoot}/../technotes/guides/jmx/index.html">
--- a/src/share/classes/javax/management/remote/IdentityMBeanServerForwarder.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
-/*
- * 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 javax.management.remote;
-
-import java.io.ObjectInputStream;
-import java.util.Set;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.IntrospectionException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.OperationsException;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.loading.ClassLoaderRepository;
-
-/**
- * An {@link MBeanServerForwarder} that forwards all {@link MBeanServer}
- * operations unchanged to the next {@code MBeanServer} in the chain.
- * This class is typically subclassed to override some but not all methods.
- */
-public class IdentityMBeanServerForwarder implements MBeanServerForwarder {
-
-    private MBeanServer next;
-
-    /**
-     * <p>Construct a forwarder that has no next {@code MBeanServer}.
-     * The resulting object will be unusable until {@link #setMBeanServer
-     * setMBeanServer} is called to establish the next item in the chain.</p>
-     */
-    public IdentityMBeanServerForwarder() {
-    }
-
-    /**
-     * <p>Construct a forwarder that forwards to the given {@code MBeanServer}.
-     * It is not an error for {@code next} to be null, but the resulting object
-     * will be unusable until {@link #setMBeanServer setMBeanServer} is called
-     * to establish the next item in the chain.</p>
-     */
-    public IdentityMBeanServerForwarder(MBeanServer next) {
-        this.next = next;
-    }
-
-    public synchronized MBeanServer getMBeanServer() {
-        return next;
-    }
-
-    public synchronized void setMBeanServer(MBeanServer mbs) {
-        next = mbs;
-    }
-
-    private synchronized MBeanServer next() {
-        return next;
-    }
-
-    public void unregisterMBean(ObjectName name)
-            throws InstanceNotFoundException, MBeanRegistrationException {
-        next().unregisterMBean(name);
-    }
-
-    public AttributeList setAttributes(ObjectName name,
-                                        AttributeList attributes)
-            throws InstanceNotFoundException, ReflectionException {
-        return next().setAttributes(name, attributes);
-    }
-
-    public void setAttribute(ObjectName name, Attribute attribute)
-            throws InstanceNotFoundException, AttributeNotFoundException,
-                   InvalidAttributeValueException, MBeanException,
-                   ReflectionException {
-        next().setAttribute(name, attribute);
-    }
-
-    public void removeNotificationListener(ObjectName name,
-                                            NotificationListener listener,
-                                            NotificationFilter filter,
-                                            Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        next().removeNotificationListener(name, listener, filter, handback);
-    }
-
-    public void removeNotificationListener(ObjectName name,
-                                            NotificationListener listener)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        next().removeNotificationListener(name, listener);
-    }
-
-    public void removeNotificationListener(ObjectName name, ObjectName listener,
-                                            NotificationFilter filter,
-                                            Object handback)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        next().removeNotificationListener(name, listener, filter, handback);
-    }
-
-    public void removeNotificationListener(ObjectName name, ObjectName listener)
-            throws InstanceNotFoundException, ListenerNotFoundException {
-        next().removeNotificationListener(name, listener);
-    }
-
-    public ObjectInstance registerMBean(Object object, ObjectName name)
-            throws InstanceAlreadyExistsException, MBeanRegistrationException,
-                   NotCompliantMBeanException {
-        return next().registerMBean(object, name);
-    }
-
-    public Set<ObjectName> queryNames(ObjectName name, QueryExp query) {
-        return next().queryNames(name, query);
-    }
-
-    public Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query) {
-        return next().queryMBeans(name, query);
-    }
-
-    public boolean isRegistered(ObjectName name) {
-        return next().isRegistered(name);
-    }
-
-    public boolean isInstanceOf(ObjectName name, String className)
-            throws InstanceNotFoundException {
-        return next().isInstanceOf(name, className);
-    }
-
-    public Object invoke(ObjectName name, String operationName, Object[] params,
-                          String[] signature)
-            throws InstanceNotFoundException, MBeanException,
-                   ReflectionException {
-        return next().invoke(name, operationName, params, signature);
-    }
-
-    public Object instantiate(String className, ObjectName loaderName,
-                               Object[] params, String[] signature)
-            throws ReflectionException, MBeanException,
-                   InstanceNotFoundException {
-        return next().instantiate(className, loaderName, params, signature);
-    }
-
-    public Object instantiate(String className, Object[] params,
-                               String[] signature)
-            throws ReflectionException, MBeanException {
-        return next().instantiate(className, params, signature);
-    }
-
-    public Object instantiate(String className, ObjectName loaderName)
-            throws ReflectionException, MBeanException,
-                   InstanceNotFoundException {
-        return next().instantiate(className, loaderName);
-    }
-
-    public Object instantiate(String className)
-            throws ReflectionException, MBeanException {
-        return next().instantiate(className);
-    }
-
-    public ObjectInstance getObjectInstance(ObjectName name)
-            throws InstanceNotFoundException {
-        return next().getObjectInstance(name);
-    }
-
-    public MBeanInfo getMBeanInfo(ObjectName name)
-            throws InstanceNotFoundException, IntrospectionException,
-                   ReflectionException {
-        return next().getMBeanInfo(name);
-    }
-
-    public Integer getMBeanCount() {
-        return next().getMBeanCount();
-    }
-
-    public String[] getDomains() {
-        return next().getDomains();
-    }
-
-    public String getDefaultDomain() {
-        return next().getDefaultDomain();
-    }
-
-    public ClassLoaderRepository getClassLoaderRepository() {
-        return next().getClassLoaderRepository();
-    }
-
-    public ClassLoader getClassLoaderFor(ObjectName mbeanName)
-            throws InstanceNotFoundException {
-        return next().getClassLoaderFor(mbeanName);
-    }
-
-    public ClassLoader getClassLoader(ObjectName loaderName)
-            throws InstanceNotFoundException {
-        return next().getClassLoader(loaderName);
-    }
-
-    public AttributeList getAttributes(ObjectName name, String[] attributes)
-            throws InstanceNotFoundException, ReflectionException {
-        return next().getAttributes(name, attributes);
-    }
-
-    public Object getAttribute(ObjectName name, String attribute)
-            throws MBeanException, AttributeNotFoundException,
-                   InstanceNotFoundException, ReflectionException {
-        return next().getAttribute(name, attribute);
-    }
-
-    @Deprecated
-    public ObjectInputStream deserialize(String className,
-                                          ObjectName loaderName,
-                                          byte[] data)
-            throws InstanceNotFoundException, OperationsException,
-                   ReflectionException {
-        return next().deserialize(className, loaderName, data);
-    }
-
-    @Deprecated
-    public ObjectInputStream deserialize(String className, byte[] data)
-            throws OperationsException, ReflectionException {
-        return next().deserialize(className, data);
-    }
-
-    @Deprecated
-    public ObjectInputStream deserialize(ObjectName name, byte[] data)
-            throws InstanceNotFoundException, OperationsException {
-        return next().deserialize(name, data);
-    }
-
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                       ObjectName loaderName, Object[] params,
-                                       String[] signature)
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException, InstanceNotFoundException {
-        return next().createMBean(className, name, loaderName, params, signature);
-    }
-
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                       Object[] params, String[] signature)
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException {
-        return next().createMBean(className, name, params, signature);
-    }
-
-    public ObjectInstance createMBean(String className, ObjectName name,
-                                       ObjectName loaderName)
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException, InstanceNotFoundException {
-        return next().createMBean(className, name, loaderName);
-    }
-
-    public ObjectInstance createMBean(String className, ObjectName name)
-            throws ReflectionException, InstanceAlreadyExistsException,
-                   MBeanRegistrationException, MBeanException,
-                   NotCompliantMBeanException {
-        return next().createMBean(className, name);
-    }
-
-    public void addNotificationListener(ObjectName name, ObjectName listener,
-                                         NotificationFilter filter,
-                                         Object handback)
-            throws InstanceNotFoundException {
-        next().addNotificationListener(name, listener, filter, handback);
-    }
-
-    public void addNotificationListener(ObjectName name,
-                                         NotificationListener listener,
-                                         NotificationFilter filter,
-                                         Object handback)
-            throws InstanceNotFoundException {
-        next().addNotificationListener(name, listener, filter, handback);
-    }
-}
--- a/src/share/classes/javax/management/remote/JMXConnector.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/JMXConnector.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2002-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
@@ -57,26 +57,6 @@
      public static final String CREDENTIALS =
          "jmx.remote.credentials";
 
-     /**
-      * <p>Name of the attribute that specifies whether to use the
-      * {@linkplain javax.management.event Event Service} to handle
-      * notifications for this connector.  The value associated with
-      * this attribute, if any, is a String, which must be equal,
-      * ignoring case, to {@code "true"} or {@code "false"}.</p>
-      *
-      * <p>Not all connectors will understand this attribute, but the
-      * standard {@linkplain javax.management.remote.rmi.RMIConnector
-      * RMI Connector} does.</p>
-      *
-      * <p>If this attribute is not present, then the system property of the
-      * same name (<code>{@value}</code>) is consulted. If that is not set
-      * either, then the Event Service is not used.</p>
-      *
-      * @since 1.7
-      */
-     public static final String USE_EVENT_SERVICE =
-         "jmx.remote.use.event.service";
-
     /**
      * <p>Establishes the connection to the connector server.  This
      * method is equivalent to {@link #connect(Map)
--- a/src/share/classes/javax/management/remote/JMXConnectorServer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/JMXConnectorServer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,22 +26,17 @@
 
 package javax.management.remote;
 
-import com.sun.jmx.remote.util.EnvHelp;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
-import java.util.NoSuchElementException;
-import javax.management.ClientContext;
-import javax.management.MBeanInfo;  // for javadoc
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanRegistration;
 import javax.management.MBeanServer;
 import javax.management.Notification;
 import javax.management.NotificationBroadcasterSupport;
 import javax.management.ObjectName;
-import javax.management.event.EventClientDelegate;
 
 /**
  * <p>Superclass of every connector server.  A connector server is
@@ -80,98 +75,6 @@
     public static final String AUTHENTICATOR =
         "jmx.remote.authenticator";
 
-     /**
-      * <p>Name of the attribute that specifies whether this connector
-      * server can delegate notification handling to the
-      * {@linkplain javax.management.event Event Service}.
-      * The value associated with
-      * this attribute, if any, is a String, which must be equal,
-      * ignoring case, to {@code "true"} or {@code "false"}.</p>
-      *
-      * <p>Not all connector servers will understand this attribute, but the
-      * standard {@linkplain javax.management.remote.rmi.RMIConnectorServer
-      * RMI Connector Server} does.</p>
-      *
-      * <p>If this attribute is not present, then the system property of the
-      * same name (<code>{@value}</code>) is consulted. If that is not set
-      * either, then the Event Service is used if the connector server
-      * supports it.</p>
-      *
-      * @since 1.7
-      */
-     public static final String DELEGATE_TO_EVENT_SERVICE =
-         "jmx.remote.delegate.event.service";
-
-     /**
-      * <p>Name of the attribute that specifies whether this connector
-      * server allows clients to communicate a context with each request.
-      * The value associated with this attribute, if any, must be a string
-      * that is equal to {@code "true"} or {@code "false"}, ignoring case.
-      * If it is {@code "true"}, then the connector server will simulate
-      * a namespace {@code jmx.context//}, as described in
-      * {@link ClientContext#newContextForwarder}.  This namespace is needed
-      * for {@link ClientContext#withContext ClientContext.withContext} to
-      * function correctly.</p>
-      *
-      * <p>Not all connector servers will understand this attribute, but the
-      * standard {@linkplain javax.management.remote.rmi.RMIConnectorServer
-      * RMI Connector Server} does.  For a connector server that understands
-      * this attribute, the default value is {@code "true"}.</p>
-      *
-      * @since 1.7
-      */
-     public static final String CONTEXT_FORWARDER =
-         "jmx.remote.context.forwarder";
-
-     /**
-      * <p>Name of the attribute that specifies whether this connector server
-      * localizes the descriptions in the {@link MBeanInfo} object returned by
-      * {@link MBeanServer#getMBeanInfo MBeanServer.getMBeanInfo}, based on the
-      * locale communicated by the client.</p>
-      *
-      * <p>The value associated with this attribute, if any, must be a string
-      * that is equal to {@code "true"} or {@code "false"}, ignoring case.
-      * If it is {@code "true"}, then the connector server will localize
-      * {@code MBeanInfo} descriptions as specified in {@link
-      * ClientContext#newLocalizeMBeanInfoForwarder}.</p>
-      *
-      * <p>Not all connector servers will understand this attribute, but the
-      * standard {@linkplain javax.management.remote.rmi.RMIConnectorServer
-      * RMI Connector Server} does.  For a connector server that understands
-      * this attribute, the default value is {@code "false"}.</p>
-      *
-      * <p>Because localization requires the client to be able to communicate
-      * its locale, it does not make sense to specify this attribute as
-      * {@code "true"} if {@link #CONTEXT_FORWARDER} is not also {@code "true"}.
-      * For a connector server that understands these attributes, specifying
-      * this inconsistent combination will result in an {@link
-      * IllegalArgumentException}.</p>
-      *
-      * @since 1.7
-      */
-     public static final String LOCALIZE_MBEAN_INFO_FORWARDER =
-        "jmx.remote.localize.mbean.info";
-
-     /**
-      * <p>Name of the attribute that specifies whether this connector
-      * server simulates the existence of the {@link EventClientDelegate}
-      * MBean. The value associated with this attribute, if any, must
-      * be a string that is equal to {@code "true"} or {@code "false"},
-      * ignoring case. If it is {@code "true"}, then the connector server
-      * will simulate an EventClientDelegate MBean, as described in {@link
-      * EventClientDelegate#newForwarder}. This MBean is needed for {@link
-      * javax.management.event.EventClient EventClient} to function correctly.</p>
-      *
-      * <p>Not all connector servers will understand this attribute, but the
-      * standard {@linkplain javax.management.remote.rmi.RMIConnectorServer
-      * RMI Connector Server} does.  For a connector server that understands
-      * this attribute, the default value is {@code "true"}.</p>
-      *
-      * @since 1.7
-      */
-     public static final String EVENT_CLIENT_DELEGATE_FORWARDER =
-         "jmx.remote.event.client.delegate.forwarder";
-
     /**
      * <p>Constructs a connector server that will be registered as an
      * MBean in the MBean server it is attached to.  This constructor
@@ -194,322 +97,27 @@
      * to an MBean server by being registered in it.
      */
     public JMXConnectorServer(MBeanServer mbeanServer) {
-        insertUserMBeanServer(mbeanServer);
+        this.mbeanServer = mbeanServer;
     }
 
     /**
      * <p>Returns the MBean server that this connector server is
-     * attached to, or the first in a chain of user-added
-     * {@link MBeanServerForwarder}s, if any.</p>
+     * attached to.</p>
      *
      * @return the MBean server that this connector server is attached
      * to, or null if it is not yet attached to an MBean server.
-     *
-     * @see #setMBeanServerForwarder
-     * @see #getSystemMBeanServerForwarder
      */
     public synchronized MBeanServer getMBeanServer() {
-        return userMBeanServer;
+        return mbeanServer;
     }
 
-    public synchronized void setMBeanServerForwarder(MBeanServerForwarder mbsf) {
+    public synchronized void setMBeanServerForwarder(MBeanServerForwarder mbsf)
+    {
         if (mbsf == null)
             throw new IllegalArgumentException("Invalid null argument: mbsf");
 
-        if (userMBeanServer != null)
-            mbsf.setMBeanServer(userMBeanServer);
-        insertUserMBeanServer(mbsf);
-    }
-
-    /**
-     * <p>Remove a forwarder from the chain of forwarders.  The forwarder can
-     * be in the system chain or the user chain.  On successful return from
-     * this method, the first occurrence in the chain of an object that is
-     * {@linkplain Object#equals equal} to {@code mbsf} will have been
-     * removed.</p>
-     *
-     * @param mbsf the forwarder to remove
-     *
-     * @throws NoSuchElementException if there is no occurrence of {@code mbsf}
-     * in the chain.
-     * @throws IllegalArgumentException if {@code mbsf} is null or is the
-     * {@linkplain #getSystemMBeanServerForwarder() system forwarder}.
-     *
-     * @since 1.7
-     */
-    public synchronized void removeMBeanServerForwarder(MBeanServerForwarder mbsf) {
-        if (mbsf == null)
-            throw new IllegalArgumentException("Invalid null argument: mbsf");
-        if (systemMBeanServerForwarder.equals(mbsf))
-            throw new IllegalArgumentException("Cannot remove system forwarder");
-
-        MBeanServerForwarder prev = systemMBeanServerForwarder;
-        MBeanServer curr;
-        while (true) {
-            curr = prev.getMBeanServer();
-            if (mbsf.equals(curr))
-                break;
-            if (curr instanceof MBeanServerForwarder)
-                prev = (MBeanServerForwarder) curr;
-            else
-                throw new NoSuchElementException("MBeanServerForwarder not in chain");
-        }
-        MBeanServer next = mbsf.getMBeanServer();
-        prev.setMBeanServer(next);
-        if (userMBeanServer == mbsf)
-            userMBeanServer = next;
-    }
-
-    /*
-     * Set userMBeanServer to mbs and arrange for the end of the chain of
-     * system MBeanServerForwarders to point to it.  See the comment before
-     * the systemMBeanServer and userMBeanServer field declarations.
-     */
-    private void insertUserMBeanServer(MBeanServer mbs) {
-        MBeanServerForwarder lastSystemMBSF = systemMBeanServerForwarder;
-        while (true) {
-            MBeanServer mbsi = lastSystemMBSF.getMBeanServer();
-            if (mbsi == userMBeanServer)
-                break;
-            lastSystemMBSF = (MBeanServerForwarder) mbsi;
-        }
-        userMBeanServer = mbs;
-        lastSystemMBSF.setMBeanServer(mbs);
-    }
-
-    /**
-     * <p>Returns the first item in the chain of system and then user
-     * forwarders.  There is a chain of {@link MBeanServerForwarder}s between
-     * a {@code JMXConnectorServer} and its {@code MBeanServer}.  This chain
-     * consists of two sub-chains: first the <em>system chain</em> and then
-     * the <em>user chain</em>.  Incoming requests are given to the first
-     * forwarder in the system chain.  Each forwarder can handle a request
-     * itself, or more usually forward it to the next forwarder, perhaps with
-     * some extra behavior such as logging or security checking before or after
-     * the forwarding.  The last forwarder in the system chain is followed by
-     * the first forwarder in the user chain.</p>
-     *
-     * <p>The object returned by this method is the first forwarder in the
-     * system chain.  For a given {@code JMXConnectorServer}, this method
-     * always returns the same object, which simply forwards every request
-     * to the next object in the chain.</p>
-     *
-     * <p>Not all connector servers support a system chain of forwarders,
-     * although the standard {@linkplain
-     * javax.management.remote.rmi.RMIConnectorServer RMI connector
-     * server} does.  For those that do not, this method will throw {@code
-     * UnsupportedOperationException}.  All
-     * connector servers do support a user chain of forwarders.</p>
-     *
-     * <p>The <em>system chain</em> is usually defined by a
-     * connector server based on the environment Map; see {@link
-     * JMXConnectorServerFactory#newJMXConnectorServer
-     * JMXConnectorServerFactory.newJMXConnectorServer}.  Allowing
-     * the connector server to define its forwarders in this way
-     * ensures that they are in the correct order - some forwarders
-     * need to be inserted before others for correct behavior.  It is
-     * possible to modify the system chain, for example using {@code
-     * connectorServer.getSystemMBeanServerForwarder().setMBeanServer(mbsf)} or
-     * {@link #removeMBeanServerForwarder removeMBeanServerForwarder}, but in
-     * that case the system chain is no longer guaranteed to be correct.</p>
-     *
-     * <p>The <em>user chain</em> is defined by calling {@link
-     * #setMBeanServerForwarder setMBeanServerForwarder} to insert forwarders
-     * at the head of the user chain.</p>
-     *
-     * <p>This code illustrates how the chains can be traversed:</p>
-     *
-     * <pre>
-     * JMXConnectorServer cs;
-     * System.out.println("system chain:");
-     * MBeanServer mbs = cs.getSystemMBeanServerForwarder();
-     * while (true) {
-     *     if (mbs == cs.getMBeanServer())
-     *         System.out.println("user chain:");
-     *     if (!(mbs instanceof MBeanServerForwarder))
-     *         break;
-     *     MBeanServerForwarder mbsf = (MBeanServerForwarder) mbs;
-     *     System.out.println("--forwarder: " + mbsf);
-     *     mbs = mbsf.getMBeanServer();
-     * }
-     * System.out.println("--MBean Server");
-     * </pre>
-     *
-     * <h4>Note for connector server implementors</h4>
-     *
-     * <p>Existing connector server implementations can be updated to support
-     * a system chain of forwarders as follows:</p>
-     *
-     * <ul>
-     * <li><p>Override the {@link #supportsSystemMBeanServerForwarder()}
-     * method so that it returns true.</p>
-     *
-     * <li><p>Call {@link #installStandardForwarders} from the constructor of
-     * the connector server.</p>
-     *
-     * <li><p>Direct incoming requests to the result of {@link
-     * #getSystemMBeanServerForwarder()} instead of the result of {@link
-     * #getMBeanServer()}.</p>
-     * </ul>
-     *
-     * @return the first item in the system chain of forwarders.
-     *
-     * @throws UnsupportedOperationException if {@link
-     * #supportsSystemMBeanServerForwarder} returns false.
-     *
-     * @see #supportsSystemMBeanServerForwarder
-     * @see #setMBeanServerForwarder
-     *
-     * @since 1.7
-     */
-    public MBeanServerForwarder getSystemMBeanServerForwarder() {
-        if (!supportsSystemMBeanServerForwarder()) {
-            throw new UnsupportedOperationException(
-                    "System MBeanServerForwarder not supported by this " +
-                    "connector server");
-        }
-        return systemMBeanServerForwarder;
-    }
-
-    /**
-     * <p>Returns true if this connector server supports a system chain of
-     * {@link MBeanServerForwarder}s.  The default implementation of this
-     * method returns false.  Connector servers that do support the system
-     * chain must override this method to return true.
-     *
-     * @return true if this connector server supports the system chain of
-     * forwarders.
-     *
-     * @since 1.7
-     */
-    public boolean supportsSystemMBeanServerForwarder() {
-        return false;
-    }
-
-    /**
-     * Closes a client connection. If the connection is successfully closed,
-     * the method {@link #connectionClosed} is called to notify interested parties.
-     * <P>Not all connector servers support this method. For those that do, it
-     * should be possible to cause a new client connection to fail before it
-     * can be used, by calling this method from within a
-     * {@link javax.management.NotificationListener}
-     * when it receives a {@link JMXConnectionNotification#OPENED} notification.
-     * This allows the owner of a connector server to deny certain connections,
-     * typically based on the information in the connection id.
-     * <P>The implementation of this method in {@code JMXConnectorServer} throws
-     * {@code UnsupportedOperationException}. Subclasses can override this
-     * method to support closing a specified client connection.
-     *
-     * @param connectionId the id of the client connection to be closed.
-     * @throws IllegalStateException if the server is not started or is closed.
-     * @throws IllegalArgumentException if {@code connectionId} is null or is
-     * not the id of any open connection.
-     * @throws java.io.IOException if an I/O error appears when closing the
-     * connection.
-     *
-     * @since 1.7
-     */
-    public void closeConnection(String connectionId)
-            throws IOException {
-        throw new UnsupportedOperationException();
-    }
-
-    /**
-     * <p>Install {@link MBeanServerForwarder}s in the system chain
-     * based on the attributes in the given {@code Map}.  A connector
-     * server that {@linkplain #supportsSystemMBeanServerForwarder supports}
-     * a system chain of {@code MBeanServerForwarder}s can call this method
-     * to add forwarders to that chain based on the contents of {@code env}.
-     * In order:</p>
-     *
-     * <ul>
-     *
-     * <li>If {@link #EVENT_CLIENT_DELEGATE_FORWARDER} is absent, or is
-     * present with the value {@code "true"}, then a forwarder
-     * equivalent to {@link EventClientDelegate#newForwarder
-     * EventClientDelegate.newForwarder}{@code (sysMBSF.getMBeanServer(),
-     * sysMBSF)} is inserted at the start of the system chain,
-     * where {@code sysMBSF} is the object returned by {@link
-     * #getSystemMBeanServerForwarder()}. </li>
-     *
-     * <li>If {@link #LOCALIZE_MBEAN_INFO_FORWARDER} is present with the
-     * value {@code "true"}, then a forwarder equivalent to
-     * {@link ClientContext#newLocalizeMBeanInfoForwarder
-     * ClientContext.newLocalizeMBeanInfoForwarder}{@code
-     * (sysMBSF.getMBeanServer())} is inserted at the start of the system
-     * chain.</li>
-     *
-     * <li>If {@link #CONTEXT_FORWARDER} is absent, or is present with
-     * the value {@code "true"}, then a forwarder equivalent to
-     * {@link ClientContext#newContextForwarder
-     * ClientContext.newContextForwarder}{@code (sysMSBF.getMBeanServer(),
-     * sysMBSF)} is inserted at the tart of the system chain.</li>
-     *
-     * </ul>
-     *
-     * <p>For {@code EVENT_CLIENT_DELEGATE_FORWARDER} and {@code
-     * CONTEXT_FORWARDER}, if the attribute is absent from the {@code
-     * Map} and a system property of the same name is defined, then
-     * the value of the system property is used as if it were in the
-     * {@code Map}.
-     *
-     * <p>Since each forwarder is inserted at the start of the chain,
-     * the final order of the forwarders is the <b>reverse</b> of the order
-     * above.  This is important, because the {@code
-     * LOCALIZE_MBEAN_INFO_FORWARDER} can only work if the {@code
-     * CONTEXT_FORWARDER} has already installed the remote client's locale
-     * in the {@linkplain ClientContext#getContext context} of the current
-     * thread.</p>
-     *
-     * <p>Attributes in {@code env} that are not listed above are ignored
-     * by this method.</p>
-     *
-     * @throws UnsupportedOperationException if {@link
-     * #supportsSystemMBeanServerForwarder} is false.
-     *
-     * @throws IllegalArgumentException if the relevant attributes in {@code env} are
-     * inconsistent, for example if {@link #LOCALIZE_MBEAN_INFO_FORWARDER} is
-     * {@code "true"} but {@link #CONTEXT_FORWARDER} is {@code "false"}; or
-     * if one of the attributes has an illegal value.
-     *
-     * @since 1.7
-     */
-    protected void installStandardForwarders(Map<String, ?> env) {
-        MBeanServerForwarder sysMBSF = getSystemMBeanServerForwarder();
-
-        // Remember that forwarders must be added in reverse order!
-
-        boolean ecd = EnvHelp.computeBooleanFromString(
-                env, EVENT_CLIENT_DELEGATE_FORWARDER, false, true);
-        boolean localize = EnvHelp.computeBooleanFromString(
-                env, LOCALIZE_MBEAN_INFO_FORWARDER, false, false);
-        boolean context = EnvHelp.computeBooleanFromString(
-                env, CONTEXT_FORWARDER, false, true);
-
-        if (localize && !context) {
-            throw new IllegalArgumentException(
-                    "Inconsistent environment parameters: " +
-                    LOCALIZE_MBEAN_INFO_FORWARDER + "=\"true\" requires " +
-                    CONTEXT_FORWARDER + "=\"true\"");
-        }
-
-        if (ecd) {
-            MBeanServerForwarder mbsf = EventClientDelegate.newForwarder(
-                    sysMBSF.getMBeanServer(), sysMBSF);
-            sysMBSF.setMBeanServer(mbsf);
-        }
-
-        if (localize) {
-            MBeanServerForwarder mbsf = ClientContext.newLocalizeMBeanInfoForwarder(
-                    sysMBSF.getMBeanServer());
-            sysMBSF.setMBeanServer(mbsf);
-        }
-
-        if (context) {
-            MBeanServerForwarder mbsf = ClientContext.newContextForwarder(
-                    sysMBSF.getMBeanServer(), sysMBSF);
-            sysMBSF.setMBeanServer(mbsf);
-        }
+        if (mbeanServer !=  null) mbsf.setMBeanServer(mbeanServer);
+        mbeanServer = mbsf;
     }
 
     public String[] getConnectionIds() {
@@ -753,8 +361,8 @@
                                                ObjectName name) {
         if (mbs == null || name == null)
             throw new NullPointerException("Null MBeanServer or ObjectName");
-        if (userMBeanServer == null) {
-            insertUserMBeanServer(mbs);
+        if (mbeanServer == null) {
+            mbeanServer = mbs;
             myName = name;
         }
         return name;
@@ -788,53 +396,10 @@
         myName = null;
     }
 
-    /*
-     * Fields describing the chains of forwarders (MBeanServerForwarders).
-     * In the general case, the forwarders look something like this:
-     *
-     *                                        userMBeanServer
-     *                                        |
-     *                                        v
-     * systemMBeanServerForwarder -> mbsf2 -> mbsf3 -> mbsf4 -> mbsf5 -> mbs
-     *
-     * Here, each mbsfi is an MBeanServerForwarder, and the arrows
-     * illustrate its getMBeanServer() method.  The last MBeanServerForwarder
-     * can point to an MBeanServer that is not instanceof MBeanServerForwarder,
-     * here mbs.
-     *
-     * The system chain is never empty because it always has at least
-     * systemMBeanServerForwarder.  Initially, the user chain can be empty if
-     * this JMXConnectorServer was constructed without an MBeanServer.  In
-     * this case, userMBS will be null.  If there is initially an MBeanServer,
-     * userMBS will point to it.
-     *
-     * Whenever userMBS is changed, the system chain must be updated.  Before
-     * the update, the last forwarder in the system chain points to the old
-     * value of userMBS (possibly null).  It must be updated to point to
-     * the new value. The invariant is that starting from systemMBSF and
-     * repeatedly calling MBSF.getMBeanServer() you will end up at userMBS.
-     * The implication is that you will not see any MBeanServer object on the
-     * way that is not also an MBeanServerForwarder.
-     *
-     * The method insertUserMBeanServer contains the logic to change userMBS
-     * and adjust the system chain appropriately.
-     *
-     * If userMBS is null and this JMXConnectorServer is registered in an
-     * MBeanServer, then userMBS becomes that MBeanServer, and the system
-     * chain must be updated as just described.
-     *
-     * When systemMBSF is updated, there is no effect on userMBS. The system
-     * chain may contain forwarders even though the user chain is empty
-     * (there is no MBeanServer). In that case an attempt to forward an
-     * incoming request through the chain will fall off the end and fail with a
-     * NullPointerException. Usually a connector server will refuse to start()
-     * if it is not attached to an MBS, so this situation should not arise.
+    /**
+     * The MBeanServer used by this server to execute a client request.
      */
-
-    private MBeanServer userMBeanServer;
-
-    private final MBeanServerForwarder systemMBeanServerForwarder =
-            new IdentityMBeanServerForwarder();
+    private MBeanServer mbeanServer = null;
 
     /**
      * The name used to registered this server in an MBeanServer.
@@ -842,7 +407,7 @@
      */
     private ObjectName myName;
 
-    private List<String> connectionIds = new ArrayList<String>();
+    private final List<String> connectionIds = new ArrayList<String>();
 
     private static final int[] sequenceNumberLock = new int[0];
     private static long sequenceNumber;
--- a/src/share/classes/javax/management/remote/JMXConnectorServerMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/JMXConnectorServerMBean.java	Wed Nov 25 11:08:25 2009 -0800
@@ -130,18 +130,12 @@
      * <code>MBeanServer</code>.</p>
      * </ul>
      *
-     * <p>A connector server may support two chains of forwarders,
-     * a system chain and a user chain.  See {@link
-     * JMXConnectorServer#getSystemMBeanServerForwarder} for details.</p>
-     *
      * @param mbsf the new <code>MBeanServerForwarder</code>.
      *
      * @exception IllegalArgumentException if the call to {@link
      * MBeanServerForwarder#setMBeanServer mbsf.setMBeanServer} fails
      * with <code>IllegalArgumentException</code>.  This includes the
      * case where <code>mbsf</code> is null.
-     *
-     * @see JMXConnectorServer#getSystemMBeanServerForwarder
      */
     public void setMBeanServerForwarder(MBeanServerForwarder mbsf);
 
--- a/src/share/classes/javax/management/remote/JMXServiceURL.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/JMXServiceURL.java	Wed Nov 25 11:08:25 2009 -0800
@@ -36,8 +36,6 @@
 import java.net.UnknownHostException;
 import java.util.BitSet;
 import java.util.StringTokenizer;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.InvalidKeyException;
 
 /**
  * <p>The address of a JMX API connector server.  Instances of this class
@@ -338,50 +336,6 @@
         validate();
     }
 
-    /**
-     * <p>Construct a {@code JMXServiceURL} instance from the given
-     * {@code CompositeData}.  The presence of this method means that
-     * {@code JMXServiceURL} is <a href="../MXBean.html#reconstructible-def">
-     * reconstructible</a> in MXBeans.</p>
-     *
-     * <p>(The effect of this method could have been obtained more simply
-     * with a &#64;{@link java.beans.ConstructorProperties ConstructorProperties}
-     * annotation on the four-parameter {@linkplain #JMXServiceURL(
-     * String, String, int, String) constructor}, but that would have meant
-     * that this API could not be implemented on versions of the Java platform
-     * that predated the introduction of that annotation.)</p>
-     *
-     * @param cd a {@code CompositeData} object that must contain items called
-     * {@code protocol}, {@code host}, and {@code URLPath} of type {@code String}
-     * and {@code port} of type {@code Integer}.  Such an object will be produced
-     * by the MXBean framework when <a
-     * href="../MXBean.html#composite-map">mapping</a> a {@code JMXServiceURL}
-     * instance to an Open Data value.
-     *
-     * @return a {@code JMXServiceURL} constructed with the protocol, host,
-     * port, and URL path extracted from the given {@code CompositeData}.
-     *
-     * @throws MalformedURLException if the given {@code CompositeData} does
-     * not contain all the required items with the required types or if the
-     * resultant URL is syntactically incorrect.
-     */
-    public static JMXServiceURL from(CompositeData cd)
-            throws MalformedURLException {
-        try {
-            String proto = (String) cd.get("protocol");
-            String host = (String) cd.get("host");
-            int port = (Integer) cd.get("port");
-            String urlPath = (String) cd.get("URLPath");
-            return new JMXServiceURL(proto, host, port, urlPath);
-        } catch (RuntimeException e) {
-            // Could be InvalidKeyException if the item is missing,
-            // or ClassCastException if it is present but with the wrong type.
-            MalformedURLException x = new MalformedURLException(e.getMessage());
-            x.initCause(e);
-            throw x;
-        }
-    }
-
     private void validate() throws MalformedURLException {
 
         // Check protocol
--- a/src/share/classes/javax/management/remote/rmi/NoCallStackClassLoader.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/rmi/NoCallStackClassLoader.java	Wed Nov 25 11:08:25 2009 -0800
@@ -225,4 +225,72 @@
     (insert "\"")
     (switch-to-buffer buf)))
 
+Alternatively, the following class reads a class file and outputs a string
+that can be used by the stringToBytes method above.
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+public class BytesToString {
+
+    public static void main(String[] args) throws IOException {
+        File f = new File(args[0]);
+        int len = (int)f.length();
+        byte[] classBytes = new byte[len];
+
+        FileInputStream in = new FileInputStream(args[0]);
+        try {
+            int pos = 0;
+            for (;;) {
+                int n = in.read(classBytes, pos, (len-pos));
+                if (n < 0)
+                    throw new RuntimeException("class file changed??");
+                pos += n;
+                if (pos >= n)
+                    break;
+            }
+        } finally {
+            in.close();
+        }
+
+        int pos = 0;
+        boolean lastWasOctal = false;
+        for (int i=0; i<len; i++) {
+            int value = classBytes[i];
+            if (value < 0)
+                value += 256;
+            String s = null;
+            if (value == '\\')
+                s = "\\\\";
+            else if (value == '\"')
+                s = "\\\"";
+            else {
+                if ((value >= 32 && value < 127) && ((!lastWasOctal ||
+                    (value < '0' || value > '7')))) {
+                    s = Character.toString((char)value);
+                }
+            }
+            if (s == null) {
+                s = "\\" + Integer.toString(value, 8);
+                lastWasOctal = true;
+            } else {
+                lastWasOctal = false;
+            }
+            if (pos > 61) {
+                System.out.print("\"");
+                if (i<len)
+                    System.out.print("+");
+                System.out.println();
+                pos = 0;
+            }
+            if (pos == 0)
+                System.out.print("                \"");
+            System.out.print(s);
+            pos += s.length();
+        }
+        System.out.println("\"");
+    }
+}
+
 */
--- a/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,12 +25,10 @@
 
 package javax.management.remote.rmi;
 
-import com.sun.jmx.mbeanserver.Util;
 import static com.sun.jmx.mbeanserver.Util.cast;
 import com.sun.jmx.remote.internal.ServerCommunicatorAdmin;
 import com.sun.jmx.remote.internal.ServerNotifForwarder;
 import com.sun.jmx.remote.security.JMXSubjectDomainCombiner;
-import com.sun.jmx.remote.security.NotificationAccessController;
 import com.sun.jmx.remote.security.SubjectDelegator;
 import com.sun.jmx.remote.util.ClassLoaderWithRepository;
 import com.sun.jmx.remote.util.ClassLogger;
@@ -38,7 +36,6 @@
 import com.sun.jmx.remote.util.OrderClassLoaders;
 
 import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
 import java.rmi.MarshalledObject;
 import java.rmi.UnmarshalException;
 import java.rmi.server.Unreferenced;
@@ -59,25 +56,18 @@
 import javax.management.InstanceNotFoundException;
 import javax.management.IntrospectionException;
 import javax.management.InvalidAttributeValueException;
-import javax.management.JMX;
 import javax.management.ListenerNotFoundException;
 import javax.management.MBeanException;
 import javax.management.MBeanInfo;
 import javax.management.MBeanRegistrationException;
 import javax.management.MBeanServer;
 import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
 import javax.management.NotificationFilter;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 import javax.management.QueryExp;
 import javax.management.ReflectionException;
 import javax.management.RuntimeOperationsException;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.EventClientNotFoundException;
-import javax.management.event.FetchingEventForwarder;
-import javax.management.namespace.JMXNamespaces;
 import javax.management.remote.JMXServerErrorException;
 import javax.management.remote.NotificationResult;
 import javax.management.remote.TargetedNotification;
@@ -168,6 +158,17 @@
         this.env = env;
     }
 
+    private synchronized ServerNotifForwarder getServerNotifFwd() {
+        // Lazily created when first use. Mainly when
+        // addNotificationListener is first called.
+        if (serverNotifForwarder == null)
+            serverNotifForwarder =
+                new ServerNotifForwarder(mbeanServer,
+                                         env,
+                                         rmiServer.getNotifBuffer(),
+                                         connectionId);
+        return serverNotifForwarder;
+    }
 
     public String getConnectionId() throws IOException {
         // We should call reqIncomming() here... shouldn't we?
@@ -178,7 +179,6 @@
         final boolean debug = logger.debugOn();
         final String  idstr = (debug?"["+this.toString()+"]":null);
 
-        final SubscriptionManager mgr;
         synchronized (this) {
             if (terminated) {
                 if (debug) logger.debug("close",idstr + " already terminated.");
@@ -193,12 +193,11 @@
                 serverCommunicatorAdmin.terminate();
             }
 
-            mgr = subscriptionManager;
-            subscriptionManager = null;
+            if (serverNotifForwarder != null) {
+                serverNotifForwarder.terminate();
+            }
         }
 
-        if (mgr != null) mgr.terminate();
-
         rmiServer.clientClosed(this);
 
         if (debug) logger.debug("close",idstr + " closed.");
@@ -997,7 +996,8 @@
             // remove all registered listeners
             for (int j=0; j<i; j++) {
                 try {
-                    doRemoveListener(names[j],ids[j]);
+                    getServerNotifFwd().removeNotificationListener(names[j],
+                                                                   ids[j]);
                 } catch (Exception eee) {
                     // strange
                 }
@@ -1247,330 +1247,22 @@
             final long csn = clientSequenceNumber;
             final int mn = maxNotifications;
             final long t = timeout;
-
-            final PrivilegedExceptionAction<NotificationResult> action =
-                new PrivilegedExceptionAction<NotificationResult>() {
-                    public NotificationResult run() throws IOException {
-                            return doFetchNotifs(csn, t, mn);
+            PrivilegedAction<NotificationResult> action =
+                new PrivilegedAction<NotificationResult>() {
+                    public NotificationResult run() {
+                        return getServerNotifFwd().fetchNotifs(csn, t, mn);
                     }
             };
-            try {
-                if (acc == null)
-                    return action.run();
-                else
-                    return AccessController.doPrivileged(action, acc);
-            } catch (IOException x) {
-                throw x;
-            } catch (RuntimeException x) {
-                throw x;
-            } catch (Exception x) {
-                // should not happen
-                throw new UndeclaredThrowableException(x);
-            }
-
+            if (acc == null)
+                return action.run();
+            else
+                return AccessController.doPrivileged(action, acc);
         } finally {
             serverCommunicatorAdmin.rspOutgoing();
         }
     }
 
     /**
-     * This is an abstraction class that let us use the legacy
-     * ServerNotifForwarder and the new EventClientDelegateMBean
-     * indifferently.
-     **/
-    private static interface SubscriptionManager {
-        public void removeNotificationListener(ObjectName name, Integer id)
-            throws InstanceNotFoundException, ListenerNotFoundException, IOException;
-        public void removeNotificationListener(ObjectName name, Integer[] ids)
-            throws Exception;
-        public NotificationResult fetchNotifications(long csn, long timeout, int maxcount)
-            throws IOException;
-        public Integer addNotificationListener(ObjectName name, NotificationFilter filter)
-            throws InstanceNotFoundException, IOException;
-        public void terminate()
-            throws IOException;
-    }
-
-    /**
-     * A SubscriptionManager that uses a ServerNotifForwarder.
-     **/
-    private static class LegacySubscriptionManager implements SubscriptionManager {
-        private final ServerNotifForwarder forwarder;
-        LegacySubscriptionManager(ServerNotifForwarder forwarder) {
-            this.forwarder = forwarder;
-        }
-
-        public void removeNotificationListener(ObjectName name, Integer id)
-            throws InstanceNotFoundException, ListenerNotFoundException,
-                IOException {
-            if (!JMXNamespaces.getContainingNamespace(name).equals("")) {
-                logger.debug("removeNotificationListener",
-                        "This connector server is not configured to support " +
-                        "forwarding of notification subscriptions to name spaces");
-                throw new RuntimeOperationsException(
-                    new UnsupportedOperationException(
-                    "removeNotificationListener on name space MBeans. "));
-                }
-            forwarder.removeNotificationListener(name,id);
-        }
-
-        public void removeNotificationListener(ObjectName name, Integer[] ids)
-            throws Exception {
-            if (!JMXNamespaces.getContainingNamespace(name).equals("")) {
-                logger.debug("removeNotificationListener",
-                        "This connector server is not configured to support " +
-                        "forwarding of notification subscriptions to name spaces");
-                throw new RuntimeOperationsException(
-                    new UnsupportedOperationException(
-                    "removeNotificationListener on name space MBeans. "));
-            }
-            forwarder.removeNotificationListener(name,ids);
-        }
-
-        public NotificationResult fetchNotifications(long csn, long timeout, int maxcount) {
-            return forwarder.fetchNotifs(csn,timeout,maxcount);
-        }
-
-        public Integer addNotificationListener(ObjectName name,
-                NotificationFilter filter)
-            throws InstanceNotFoundException, IOException {
-            if (!JMXNamespaces.getContainingNamespace(name).equals("")) {
-                logger.debug("addNotificationListener",
-                        "This connector server is not configured to support " +
-                        "forwarding of notification subscriptions to name spaces");
-                throw new RuntimeOperationsException(
-                    new UnsupportedOperationException(
-                    "addNotificationListener on name space MBeans. "));
-            }
-            return forwarder.addNotificationListener(name,filter);
-        }
-
-        public void terminate() {
-            forwarder.terminate();
-        }
-    }
-
-    /**
-     * A SubscriptionManager that uses an EventClientDelegateMBean.
-     **/
-    private static class EventSubscriptionManager
-            implements SubscriptionManager {
-        private final MBeanServer mbeanServer;
-        private final EventClientDelegateMBean delegate;
-        private final NotificationAccessController notifAC;
-        private final boolean checkNotificationEmission;
-        private final String clientId;
-        private final String connectionId;
-        private volatile String mbeanServerName;
-
-        EventSubscriptionManager(
-                MBeanServer mbeanServer,
-                EventClientDelegateMBean delegate,
-                Map<String, ?> env,
-                String clientId,
-                String connectionId) {
-            this.mbeanServer = mbeanServer;
-            this.delegate = delegate;
-            this.notifAC = EnvHelp.getNotificationAccessController(env);
-            this.checkNotificationEmission =
-                EnvHelp.computeBooleanFromString(
-                    env, "jmx.remote.x.check.notification.emission", false);
-            this.clientId = clientId;
-            this.connectionId = connectionId;
-        }
-
-        private String mbeanServerName() {
-            if (mbeanServerName != null) return mbeanServerName;
-            else return (mbeanServerName = getMBeanServerName(mbeanServer));
-        }
-
-        @SuppressWarnings("serial")  // no serialVersionUID
-        private class AccessControlFilter implements NotificationFilter {
-            private final NotificationFilter wrapped;
-            private final ObjectName name;
-
-            AccessControlFilter(ObjectName name, NotificationFilter wrapped) {
-                this.name = name;
-                this.wrapped = wrapped;
-            }
-
-            public boolean isNotificationEnabled(Notification notification) {
-                try {
-                    if (checkNotificationEmission) {
-                        ServerNotifForwarder.checkMBeanPermission(
-                                mbeanServerName(), mbeanServer, name,
-                                "addNotificationListener");
-                    }
-                    notifAC.fetchNotification(
-                            connectionId, name, notification, getSubject());
-                    return (wrapped == null) ? true :
-                        wrapped.isNotificationEnabled(notification);
-                } catch (InstanceNotFoundException e) {
-                    return false;
-                } catch (SecurityException e) {
-                    return false;
-                }
-            }
-
-        }
-
-        public Integer addNotificationListener(
-                ObjectName name, NotificationFilter filter)
-                throws InstanceNotFoundException, IOException {
-            if (notifAC != null) {
-                notifAC.addNotificationListener(connectionId, name, getSubject());
-                filter = new AccessControlFilter(name, filter);
-            }
-            try {
-                return delegate.addListener(clientId,name,filter);
-            } catch (EventClientNotFoundException x) {
-                throw new IOException("Unknown clientId: "+clientId,x);
-            }
-        }
-
-        public void removeNotificationListener(ObjectName name, Integer id)
-                throws InstanceNotFoundException, ListenerNotFoundException,
-                       IOException {
-            if (notifAC != null)
-                notifAC.removeNotificationListener(connectionId, name, getSubject());
-            try {
-                delegate.removeListenerOrSubscriber(clientId, id);
-            } catch (EventClientNotFoundException x) {
-                throw new IOException("Unknown clientId: "+clientId,x);
-            }
-        }
-
-        public void removeNotificationListener(ObjectName name, Integer[] ids)
-                throws InstanceNotFoundException, ListenerNotFoundException,
-                       IOException {
-            if (notifAC != null)
-                notifAC.removeNotificationListener(connectionId, name, getSubject());
-            try {
-                for (Integer id : ids)
-                    delegate.removeListenerOrSubscriber(clientId, id);
-            } catch (EventClientNotFoundException x) {
-                throw new IOException("Unknown clientId: "+clientId,x);
-            }
-        }
-
-        public NotificationResult fetchNotifications(long csn, long timeout,
-                int maxcount)
-            throws IOException {
-            try {
-                // For some reason the delegate doesn't accept a negative
-                // sequence number. However legacy clients will always call
-                // fetchNotifications with a negative sequence number, when
-                // they call it for the first time.
-                // In that case, we will use 0 instead.
-                //
-                return delegate.fetchNotifications(
-                        clientId, Math.max(csn, 0), maxcount, timeout);
-            } catch (EventClientNotFoundException x) {
-                throw new IOException("Unknown clientId: "+clientId,x);
-            }
-        }
-
-        public void terminate()
-            throws IOException {
-            try {
-                delegate.removeClient(clientId);
-            } catch (EventClientNotFoundException x) {
-                throw new IOException("Unknown clientId: "+clientId,x);
-            }
-        }
-
-        private static Subject getSubject() {
-            return Subject.getSubject(AccessController.getContext());
-        }
-    }
-
-    /**
-     * Creates a SubscriptionManager that uses either the legacy notifications
-     * mechanism (ServerNotifForwarder) or the new event service
-     * (EventClientDelegateMBean) depending on which option was passed in
-     * the connector's map.
-     **/
-    private SubscriptionManager createSubscriptionManager()
-        throws IOException {
-        if (EnvHelp.delegateToEventService(env) &&
-                mbeanServer.isRegistered(EventClientDelegate.OBJECT_NAME)) {
-            final EventClientDelegateMBean mbean =
-                    JMX.newMBeanProxy(mbeanServer,
-                        EventClientDelegate.OBJECT_NAME,
-                        EventClientDelegateMBean.class);
-            String clientId;
-            try {
-                 clientId =
-                    mbean.addClient(
-                FetchingEventForwarder.class.getName(),
-                new Object[] {EnvHelp.getNotifBufferSize(env)},
-                new String[] {int.class.getName()});
-            } catch (Exception e) {
-                if (e instanceof IOException)
-                    throw (IOException) e;
-                else
-                    throw new IOException(e);
-            }
-
-            // we're going to call remove client...
-            try {
-                mbean.lease(clientId, Long.MAX_VALUE);
-            } catch (EventClientNotFoundException x) {
-                throw new IOException("Unknown clientId: "+clientId,x);
-            }
-            return new EventSubscriptionManager(mbeanServer, mbean, env,
-                    clientId, connectionId);
-        } else {
-            final ServerNotifForwarder serverNotifForwarder =
-                new ServerNotifForwarder(mbeanServer,
-                                         env,
-                                         rmiServer.getNotifBuffer(),
-                                         connectionId);
-             return new LegacySubscriptionManager(serverNotifForwarder);
-        }
-    }
-
-    /**
-     * Lazy creation of a  SubscriptionManager.
-     **/
-    private synchronized SubscriptionManager getSubscriptionManager()
-        throws IOException {
-        // Lazily created when first use. Mainly when
-        // addNotificationListener is first called.
-
-        if (subscriptionManager == null) {
-             subscriptionManager = createSubscriptionManager();
-        }
-        return subscriptionManager;
-    }
-
-    // calls SubscriptionManager.
-    private void doRemoveListener(ObjectName name, Integer id)
-        throws InstanceNotFoundException, ListenerNotFoundException,
-            IOException {
-           getSubscriptionManager().removeNotificationListener(name,id);
-    }
-
-    // calls SubscriptionManager.
-    private void doRemoveListener(ObjectName name, Integer[] ids)
-        throws Exception {
-           getSubscriptionManager().removeNotificationListener(name,ids);
-    }
-
-    // calls SubscriptionManager.
-    private NotificationResult doFetchNotifs(long csn, long timeout, int maxcount)
-         throws IOException {
-         return getSubscriptionManager().fetchNotifications(csn, timeout, maxcount);
-    }
-
-    // calls SubscriptionManager.
-    private Integer doAddListener(ObjectName name, NotificationFilter filter)
-         throws InstanceNotFoundException, IOException {
-         return getSubscriptionManager().addNotificationListener(name,filter);
-    }
-
-
-    /**
      * <p>Returns a string representation of this object.  In general,
      * the <code>toString</code> method returns a string that
      * "textually represents" this object. The result should be a
@@ -1787,8 +1479,9 @@
             return null;
 
         case ADD_NOTIFICATION_LISTENERS:
-            return doAddListener((ObjectName)params[0],
-                                 (NotificationFilter)params[1]);
+            return getServerNotifFwd().addNotificationListener(
+                                                (ObjectName)params[0],
+                                                (NotificationFilter)params[1]);
 
         case ADD_NOTIFICATION_LISTENER_OBJECTNAME:
             mbeanServer.addNotificationListener((ObjectName)params[0],
@@ -1798,7 +1491,9 @@
             return null;
 
         case REMOVE_NOTIFICATION_LISTENER:
-            doRemoveListener((ObjectName)params[0],(Integer[])params[1]);
+            getServerNotifFwd().removeNotificationListener(
+                                                   (ObjectName)params[0],
+                                                   (Integer[])params[1]);
             return null;
 
         case REMOVE_NOTIFICATION_LISTENER_OBJECTNAME:
@@ -1909,15 +1604,6 @@
         return e;
     }
 
-    private static String getMBeanServerName(final MBeanServer server) {
-        final PrivilegedAction<String> action = new PrivilegedAction<String>() {
-            public String run() {
-                return Util.getMBeanServerSecurityName(server);
-            }
-        };
-        return AccessController.doPrivileged(action);
-    }
-
     private static final Object[] NO_OBJECTS = new Object[0];
     private static final String[] NO_STRINGS = new String[0];
 
@@ -2033,7 +1719,7 @@
     // SERVER NOTIFICATION
     //--------------------
 
-    private SubscriptionManager subscriptionManager;
+    private ServerNotifForwarder serverNotifForwarder;
     private Map<String, ?> env;
 
     // TRACES & DEBUG
--- a/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,15 +25,12 @@
 
 package javax.management.remote.rmi;
 
-import com.sun.jmx.event.DaemonThreadFactory;
-import com.sun.jmx.event.EventConnection;
-import com.sun.jmx.mbeanserver.PerThreadGroupPool;
 import com.sun.jmx.mbeanserver.Util;
 import com.sun.jmx.remote.internal.ClientCommunicatorAdmin;
 import com.sun.jmx.remote.internal.ClientListenerInfo;
 import com.sun.jmx.remote.internal.ClientNotifForwarder;
-import com.sun.jmx.remote.internal.ProxyInputStream;
 import com.sun.jmx.remote.internal.ProxyRef;
+import com.sun.jmx.remote.internal.IIOPHelper;
 import com.sun.jmx.remote.util.ClassLogger;
 import com.sun.jmx.remote.util.EnvHelp;
 import java.io.ByteArrayInputStream;
@@ -72,11 +69,6 @@
 import java.util.Properties;
 import java.util.Set;
 import java.util.WeakHashMap;
-import java.util.concurrent.Executor;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
 import javax.management.Attribute;
 import javax.management.AttributeList;
 import javax.management.AttributeNotFoundException;
@@ -84,7 +76,6 @@
 import javax.management.InstanceNotFoundException;
 import javax.management.IntrospectionException;
 import javax.management.InvalidAttributeValueException;
-import javax.management.JMX;
 import javax.management.ListenerNotFoundException;
 import javax.management.MBeanException;
 import javax.management.MBeanInfo;
@@ -102,8 +93,6 @@
 import javax.management.ObjectName;
 import javax.management.QueryExp;
 import javax.management.ReflectionException;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegateMBean;
 import javax.management.remote.JMXConnectionNotification;
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorFactory;
@@ -112,12 +101,8 @@
 import javax.management.remote.JMXAddressable;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
-import javax.rmi.CORBA.Stub;
-import javax.rmi.PortableRemoteObject;
 import javax.rmi.ssl.SslRMIClientSocketFactory;
 import javax.security.auth.Subject;
-import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
 import sun.rmi.server.UnicastRef2;
 import sun.rmi.transport.LiveRef;
 
@@ -224,6 +209,7 @@
      *
      * @return a String representation of this object.
      **/
+    @Override
     public String toString() {
         final StringBuilder b = new StringBuilder(this.getClass().getName());
         b.append(":");
@@ -330,8 +316,6 @@
             //
             connectionId = getConnectionId();
 
-            eventServiceEnabled = EnvHelp.eventServiceEnabled(env);
-
             Notification connectedNotif =
                     new JMXConnectionNotification(JMXConnectionNotification.OPENED,
                     this,
@@ -341,8 +325,6 @@
                     null);
             sendNotification(connectedNotif);
 
-            // whether or not event service
-
             if (tracing) logger.trace("connect",idstr + " done...");
         } catch (IOException e) {
             if (tracing)
@@ -400,38 +382,10 @@
         }
 
         rmbsc = new RemoteMBeanServerConnection(delegationSubject);
-        if (eventServiceEnabled) {
-            EventClientDelegateMBean ecd = JMX.newMBeanProxy(
-                    rmbsc, EventClientDelegateMBean.OBJECT_NAME,
-                    EventClientDelegateMBean.class);
-            EventClient ec = new EventClient(ecd, null, defaultExecutor(), null,
-                    EventClient.DEFAULT_REQUESTED_LEASE_TIME);
-
-            rmbsc = EventConnection.Factory.make(rmbsc, ec);
-            ec.addEventClientListener(
-                    lostNotifListener, null, null);
-        }
         rmbscMap.put(delegationSubject, rmbsc);
         return rmbsc;
     }
 
-    private static Executor defaultExecutor() {
-        PerThreadGroupPool.Create<ThreadPoolExecutor> create =
-                new PerThreadGroupPool.Create<ThreadPoolExecutor>() {
-            public ThreadPoolExecutor createThreadPool(ThreadGroup group) {
-                ThreadFactory daemonThreadFactory = new DaemonThreadFactory(
-                        "JMX RMIConnector listener dispatch %d");
-                ThreadPoolExecutor executor = new ThreadPoolExecutor(
-                        1, 10, 1, TimeUnit.SECONDS,
-                        new LinkedBlockingQueue<Runnable>(),
-                        daemonThreadFactory);
-                executor.allowCoreThreadTimeOut(true);
-                return executor;
-            }
-        };
-        return listenerDispatchThreadPool.getThreadPoolExecutor(create);
-    }
-
     public void
             addConnectionNotificationListener(NotificationListener listener,
             NotificationFilter filter,
@@ -511,17 +465,6 @@
             communicatorAdmin.terminate();
         }
 
-        // close all EventClient
-        for (MBeanServerConnection rmbsc : rmbscMap.values()) {
-            if (rmbsc instanceof EventConnection) {
-                try {
-                    ((EventConnection)rmbsc).getEventClient().close();
-                } catch (Exception e) {
-                    // OK
-                }
-            }
-        }
-
         if (rmiNotifClient != null) {
             try {
                 rmiNotifClient.terminate();
@@ -660,8 +603,6 @@
     private class RemoteMBeanServerConnection implements MBeanServerConnection {
         private Subject delegationSubject;
 
-        public EventClient eventClient = null;
-
         public RemoteMBeanServerConnection() {
             this(null);
         }
@@ -1504,6 +1445,7 @@
             super(period);
         }
 
+        @Override
         public void gotIOException(IOException ioe) throws IOException {
             if (ioe instanceof NoSuchObjectException) {
                 // need to restart
@@ -1747,12 +1689,12 @@
     static RMIServer connectStub(RMIServer rmiServer,
                                  Map<String, ?> environment)
         throws IOException {
-        if (rmiServer instanceof javax.rmi.CORBA.Stub) {
-            javax.rmi.CORBA.Stub stub = (javax.rmi.CORBA.Stub) rmiServer;
+        if (IIOPHelper.isStub(rmiServer)) {
             try {
-                stub._orb();
-            } catch (BAD_OPERATION x) {
-                stub.connect(resolveOrb(environment));
+                IIOPHelper.getOrb(rmiServer);
+            } catch (UnsupportedOperationException x) {
+                // BAD_OPERATION
+                IIOPHelper.connect(rmiServer, resolveOrb(environment));
             }
         }
         return rmiServer;
@@ -1779,22 +1721,22 @@
      *      does not point to an {@link org.omg.CORBA.ORB ORB}.
      * @exception IOException if the ORB initialization failed.
      **/
-    static ORB resolveOrb(Map<String, ?> environment)
+    static Object resolveOrb(Map<String, ?> environment)
         throws IOException {
         if (environment != null) {
             final Object orb = environment.get(EnvHelp.DEFAULT_ORB);
-            if (orb != null && !(orb instanceof  ORB))
+            if (orb != null && !(IIOPHelper.isOrb(orb)))
                 throw new IllegalArgumentException(EnvHelp.DEFAULT_ORB +
                         " must be an instance of org.omg.CORBA.ORB.");
-            if (orb != null) return (ORB)orb;
+            if (orb != null) return orb;
         }
-        final ORB orb =
+        final Object orb =
                 (RMIConnector.orb==null)?null:RMIConnector.orb.get();
         if (orb != null) return orb;
 
-        final ORB newOrb =
-                ORB.init((String[])null, (Properties)null);
-        RMIConnector.orb = new WeakReference<ORB>(newOrb);
+        final Object newOrb =
+                IIOPHelper.createOrb((String[])null, (Properties)null);
+        RMIConnector.orb = new WeakReference<Object>(newOrb);
         return newOrb;
     }
 
@@ -1865,26 +1807,6 @@
         terminated = false;
 
         connectionBroadcaster = new NotificationBroadcasterSupport();
-
-        lostNotifListener =
-                new NotificationListener() {
-            public void handleNotification(Notification n, Object hb) {
-                if (n != null && EventClient.NOTIFS_LOST.equals(n.getType())) {
-                    Long lost = (Long)n.getUserData();
-                    final String msg =
-                            "May have lost up to " + lost +
-                            " notification" + (lost.longValue() == 1 ? "" : "s");
-                    sendNotification(new JMXConnectionNotification(
-                            JMXConnectionNotification.NOTIFS_LOST,
-                            RMIConnector.this,
-                            connectionId,
-                            clientNotifCounter++,
-                            msg,
-                            lost));
-
-                }
-            }
-        };
     }
 
     //--------------------------------------------------------------------
@@ -1952,9 +1874,11 @@
             return findRMIServerJNDI(path.substring(6,end), environment, isIiop);
         else if (path.startsWith("/stub/"))
             return findRMIServerJRMP(path.substring(6,end), environment, isIiop);
-        else if (path.startsWith("/ior/"))
+        else if (path.startsWith("/ior/")) {
+            if (!IIOPHelper.isAvailable())
+                throw new IOException("iiop protocol not available");
             return findRMIServerIIOP(path.substring(5,end), environment, isIiop);
-        else {
+        } else {
             final String msg = "URL path must begin with /jndi/ or /stub/ " +
                     "or /ior/: " + path;
             throw new MalformedURLException(msg);
@@ -1996,8 +1920,7 @@
 
     private static RMIServer narrowIIOPServer(Object objref) {
         try {
-            return (RMIServer)
-            PortableRemoteObject.narrow(objref, RMIServer.class);
+            return IIOPHelper.narrow(objref, RMIServer.class);
         } catch (ClassCastException e) {
             if (logger.traceOn())
                 logger.trace("narrowIIOPServer","Failed to narrow objref=" +
@@ -2009,10 +1932,9 @@
 
     private RMIServer findRMIServerIIOP(String ior, Map<String, ?> env, boolean isIiop) {
         // could forbid "rmi:" URL here -- but do we need to?
-        final ORB orb = (ORB)
-        env.get(EnvHelp.DEFAULT_ORB);
-        final Object stub = orb.string_to_object(ior);
-        return (RMIServer) PortableRemoteObject.narrow(stub, RMIServer.class);
+        final Object orb = env.get(EnvHelp.DEFAULT_ORB);
+        final Object stub = IIOPHelper.stringToObject(orb, ior);
+        return IIOPHelper.narrow(stub, RMIServer.class);
     }
 
     private RMIServer findRMIServerJRMP(String base64, Map<String, ?> env, boolean isIiop)
@@ -2038,7 +1960,7 @@
         } catch (ClassNotFoundException e) {
             throw new MalformedURLException("Class not found: " + e);
         }
-        return (RMIServer) PortableRemoteObject.narrow(stub, RMIServer.class);
+        return (RMIServer)stub;
     }
 
     private static final class ObjectInputStreamWithLoader
@@ -2279,9 +2201,9 @@
        again, using reflection.
 
        The strings below encode the following two Java classes,
-       compiled using J2SE 1.4.2 with javac -g:none.
+       compiled using javac -g:none.
 
-        package com.sun.jmx.remote.internal;
+        package com.sun.jmx.remote.protocol.iiop;
 
         import org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub;
 
@@ -2302,12 +2224,13 @@
             }
 
             public void _releaseReply(InputStream in) {
-                PInputStream pis = (PInputStream) in;
-                super._releaseReply(pis.getProxiedInputStream());
+                if (in != null)
+                    in = ((PInputStream)in).getProxiedInputStream();
+                super._releaseReply(in);
             }
         }
 
-        package com.sun.jmx.remote.internal;
+        package com.sun.jmx.remote.protocol.iiop;
 
         public class PInputStream extends ProxyInputStream {
             public PInputStream(org.omg.CORBA.portable.InputStream in) {
@@ -2326,49 +2249,52 @@
 
      */
     private static final String iiopConnectionStubClassName =
-            "org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub";
+        "org.omg.stub.javax.management.remote.rmi._RMIConnection_Stub";
     private static final String proxyStubClassName =
-            "com.sun.jmx.remote.internal.ProxyStub";
+        "com.sun.jmx.remote.protocol.iiop.ProxyStub";
+    private static final String ProxyInputStreamClassName =
+        "com.sun.jmx.remote.protocol.iiop.ProxyInputStream";
     private static final String pInputStreamClassName =
-        "com.sun.jmx.remote.internal.PInputStream";
+        "com.sun.jmx.remote.protocol.iiop.PInputStream";
     private static final Class<?> proxyStubClass;
     static {
         final String proxyStubByteCodeString =
-                "\312\376\272\276\0\0\0.\0)\12\0\14\0\26\7\0\27\12\0\14\0\30\12"+
-                "\0\2\0\31\7\0\32\12\0\5\0\33\12\0\5\0\34\12\0\5\0\35\12\0\2\0"+
-                "\36\12\0\14\0\37\7\0\40\7\0!\1\0\6<init>\1\0\3()V\1\0\4Code\1"+
-                "\0\7_invoke\1\0K(Lorg/omg/CORBA/portable/OutputStream;)Lorg/o"+
-                "mg/CORBA/portable/InputStream;\1\0\12Exceptions\7\0\"\1\0\15_"+
-                "releaseReply\1\0'(Lorg/omg/CORBA/portable/InputStream;)V\14\0"+
-                "\15\0\16\1\0(com/sun/jmx/remote/internal/PInputStream\14\0\20"+
-                "\0\21\14\0\15\0\25\1\0+org/omg/CORBA/portable/ApplicationExce"+
-                "ption\14\0#\0$\14\0%\0&\14\0\15\0'\14\0(\0$\14\0\24\0\25\1\0%"+
-                "com/sun/jmx/remote/internal/ProxyStub\1\0<org/omg/stub/javax/"+
-                "management/remote/rmi/_RMIConnection_Stub\1\0)org/omg/CORBA/p"+
-                "ortable/RemarshalException\1\0\16getInputStream\1\0&()Lorg/om"+
-                "g/CORBA/portable/InputStream;\1\0\5getId\1\0\24()Ljava/lang/S"+
-                "tring;\1\09(Ljava/lang/String;Lorg/omg/CORBA/portable/InputSt"+
-                "ream;)V\1\0\25getProxiedInputStream\0!\0\13\0\14\0\0\0\0\0\3\0"+
-                "\1\0\15\0\16\0\1\0\17\0\0\0\21\0\1\0\1\0\0\0\5*\267\0\1\261\0"+
-                "\0\0\0\0\1\0\20\0\21\0\2\0\17\0\0\0;\0\4\0\4\0\0\0'\273\0\2Y*"+
-                "+\267\0\3\267\0\4\260M\273\0\2Y,\266\0\6\267\0\4N\273\0\5Y,\266"+
-                "\0\7-\267\0\10\277\0\1\0\0\0\14\0\15\0\5\0\0\0\22\0\0\0\6\0\2"+
-                "\0\5\0\23\0\1\0\24\0\25\0\1\0\17\0\0\0\36\0\2\0\2\0\0\0\22+\306"+
-                "\0\13+\300\0\2\266\0\11L*+\267\0\12\261\0\0\0\0\0\0";
+                "\312\376\272\276\0\0\0\63\0+\12\0\14\0\30\7\0\31\12\0\14\0\32\12"+
+                "\0\2\0\33\7\0\34\12\0\5\0\35\12\0\5\0\36\12\0\5\0\37\12\0\2\0 "+
+                "\12\0\14\0!\7\0\"\7\0#\1\0\6<init>\1\0\3()V\1\0\4Code\1\0\7_in"+
+                "voke\1\0K(Lorg/omg/CORBA/portable/OutputStream;)Lorg/omg/CORBA"+
+                "/portable/InputStream;\1\0\15StackMapTable\7\0\34\1\0\12Except"+
+                "ions\7\0$\1\0\15_releaseReply\1\0'(Lorg/omg/CORBA/portable/Inp"+
+                "utStream;)V\14\0\15\0\16\1\0-com/sun/jmx/remote/protocol/iiop/"+
+                "PInputStream\14\0\20\0\21\14\0\15\0\27\1\0+org/omg/CORBA/porta"+
+                "ble/ApplicationException\14\0%\0&\14\0'\0(\14\0\15\0)\14\0*\0&"+
+                "\14\0\26\0\27\1\0*com/sun/jmx/remote/protocol/iiop/ProxyStub\1"+
+                "\0<org/omg/stub/javax/management/remote/rmi/_RMIConnection_Stu"+
+                "b\1\0)org/omg/CORBA/portable/RemarshalException\1\0\16getInput"+
+                "Stream\1\0&()Lorg/omg/CORBA/portable/InputStream;\1\0\5getId\1"+
+                "\0\24()Ljava/lang/String;\1\09(Ljava/lang/String;Lorg/omg/CORB"+
+                "A/portable/InputStream;)V\1\0\25getProxiedInputStream\0!\0\13\0"+
+                "\14\0\0\0\0\0\3\0\1\0\15\0\16\0\1\0\17\0\0\0\21\0\1\0\1\0\0\0\5"+
+                "*\267\0\1\261\0\0\0\0\0\1\0\20\0\21\0\2\0\17\0\0\0G\0\4\0\4\0\0"+
+                "\0'\273\0\2Y*+\267\0\3\267\0\4\260M\273\0\2Y,\266\0\6\267\0\4N"+
+                "\273\0\5Y,\266\0\7-\267\0\10\277\0\1\0\0\0\14\0\15\0\5\0\1\0\22"+
+                "\0\0\0\6\0\1M\7\0\23\0\24\0\0\0\6\0\2\0\5\0\25\0\1\0\26\0\27\0"+
+                "\1\0\17\0\0\0'\0\2\0\2\0\0\0\22+\306\0\13+\300\0\2\266\0\11L*+"+
+                "\267\0\12\261\0\0\0\1\0\22\0\0\0\3\0\1\14\0\0";
         final String pInputStreamByteCodeString =
-                "\312\376\272\276\0\0\0.\0\36\12\0\7\0\17\11\0\6\0\20\12\0\21\0"+
-                "\22\12\0\6\0\23\12\0\24\0\25\7\0\26\7\0\27\1\0\6<init>\1\0'(L"+
-                "org/omg/CORBA/portable/InputStream;)V\1\0\4Code\1\0\10read_an"+
-                "y\1\0\25()Lorg/omg/CORBA/Any;\1\0\12read_value\1\0)(Ljava/lan"+
-                "g/Class;)Ljava/io/Serializable;\14\0\10\0\11\14\0\30\0\31\7\0"+
-                "\32\14\0\13\0\14\14\0\33\0\34\7\0\35\14\0\15\0\16\1\0(com/sun"+
-                "/jmx/remote/internal/PInputStream\1\0,com/sun/jmx/remote/inte"+
-                "rnal/ProxyInputStream\1\0\2in\1\0$Lorg/omg/CORBA/portable/Inp"+
-                "utStream;\1\0\"org/omg/CORBA/portable/InputStream\1\0\6narrow"+
-                "\1\0*()Lorg/omg/CORBA_2_3/portable/InputStream;\1\0&org/omg/C"+
-                "ORBA_2_3/portable/InputStream\0!\0\6\0\7\0\0\0\0\0\3\0\1\0\10"+
-                "\0\11\0\1\0\12\0\0\0\22\0\2\0\2\0\0\0\6*+\267\0\1\261\0\0\0\0"+
-                "\0\1\0\13\0\14\0\1\0\12\0\0\0\24\0\1\0\1\0\0\0\10*\264\0\2\266"+
+                "\312\376\272\276\0\0\0\63\0\36\12\0\7\0\17\11\0\6\0\20\12\0\21"+
+                "\0\22\12\0\6\0\23\12\0\24\0\25\7\0\26\7\0\27\1\0\6<init>\1\0'("+
+                "Lorg/omg/CORBA/portable/InputStream;)V\1\0\4Code\1\0\10read_an"+
+                "y\1\0\25()Lorg/omg/CORBA/Any;\1\0\12read_value\1\0)(Ljava/lang"+
+                "/Class;)Ljava/io/Serializable;\14\0\10\0\11\14\0\30\0\31\7\0\32"+
+                "\14\0\13\0\14\14\0\33\0\34\7\0\35\14\0\15\0\16\1\0-com/sun/jmx"+
+                "/remote/protocol/iiop/PInputStream\1\0\61com/sun/jmx/remote/pr"+
+                "otocol/iiop/ProxyInputStream\1\0\2in\1\0$Lorg/omg/CORBA/portab"+
+                "le/InputStream;\1\0\"org/omg/CORBA/portable/InputStream\1\0\6n"+
+                "arrow\1\0*()Lorg/omg/CORBA_2_3/portable/InputStream;\1\0&org/o"+
+                "mg/CORBA_2_3/portable/InputStream\0!\0\6\0\7\0\0\0\0\0\3\0\1\0"+
+                "\10\0\11\0\1\0\12\0\0\0\22\0\2\0\2\0\0\0\6*+\267\0\1\261\0\0\0"+
+                "\0\0\1\0\13\0\14\0\1\0\12\0\0\0\24\0\1\0\1\0\0\0\10*\264\0\2\266"+
                 "\0\3\260\0\0\0\0\0\1\0\15\0\16\0\1\0\12\0\0\0\25\0\2\0\2\0\0\0"+
                 "\11*\266\0\4+\266\0\5\260\0\0\0\0\0\0";
         final byte[] proxyStubByteCode =
@@ -2379,12 +2305,12 @@
         final byte[][] byteCodes = {proxyStubByteCode, pInputStreamByteCode};
         final String[] otherClassNames = {
             iiopConnectionStubClassName,
-            ProxyInputStream.class.getName(),
+            ProxyInputStreamClassName,
         };
-        PrivilegedExceptionAction<Class<?>> action =
+        if (IIOPHelper.isAvailable()) {
+            PrivilegedExceptionAction<Class<?>> action =
                 new PrivilegedExceptionAction<Class<?>>() {
-            public Class<?> run() throws Exception {
-
+              public Class<?> run() throws Exception {
                 Class thisClass = RMIConnector.class;
                 ClassLoader thisLoader = thisClass.getClassLoader();
                 ProtectionDomain thisProtectionDomain =
@@ -2396,24 +2322,27 @@
                         thisLoader,
                         thisProtectionDomain);
                 return cl.loadClass(proxyStubClassName);
+              }
+            };
+            Class<?> stubClass;
+            try {
+                stubClass = AccessController.doPrivileged(action);
+            } catch (Exception e) {
+                logger.error("<clinit>",
+                        "Unexpected exception making shadow IIOP stub class: "+e);
+                logger.debug("<clinit>",e);
+                stubClass = null;
             }
-        };
-        Class<?> stubClass;
-        try {
-            stubClass = AccessController.doPrivileged(action);
-        } catch (Exception e) {
-            logger.error("<clinit>",
-                    "Unexpected exception making shadow IIOP stub class: "+e);
-            logger.debug("<clinit>",e);
-            stubClass = null;
+            proxyStubClass = stubClass;
+        } else {
+            proxyStubClass = null;
         }
-        proxyStubClass = stubClass;
     }
 
-    private static RMIConnection shadowIiopStub(Stub stub)
+    private static RMIConnection shadowIiopStub(Object stub)
     throws InstantiationException, IllegalAccessException {
-        Stub proxyStub = (Stub) proxyStubClass.newInstance();
-        proxyStub._set_delegate(stub._get_delegate());
+        Object proxyStub = proxyStubClass.newInstance();
+        IIOPHelper.setDelegate(proxyStub, IIOPHelper.getDelegate(stub));
         return (RMIConnection) proxyStub;
     }
 
@@ -2427,7 +2356,7 @@
             if (c.getClass() == rmiConnectionImplStubClass)
                 return shadowJrmpStub((RemoteObject) c);
             if (c.getClass().getName().equals(iiopConnectionStubClassName))
-                return shadowIiopStub((Stub) c);
+                return shadowIiopStub(c);
             logger.trace("getConnection",
                     "Did not wrap " + c.getClass() + " to foil " +
                     "stack search for classes: class loading semantics " +
@@ -2609,16 +2538,11 @@
 
     private transient ClientCommunicatorAdmin communicatorAdmin;
 
-    private boolean eventServiceEnabled;
-//    private transient EventRelay eventRelay;
-
-    private transient NotificationListener lostNotifListener;
-
     /**
      * A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to
      * connect unconnected stubs.
      **/
-    private static volatile WeakReference<ORB> orb = null;
+    private static volatile WeakReference<Object> orb = null;
 
     // TRACES & DEBUG
     //---------------
@@ -2632,7 +2556,4 @@
     private static String strings(final String[] strs) {
         return objects(strs);
     }
-
-    private static final PerThreadGroupPool<ThreadPoolExecutor> listenerDispatchThreadPool =
-            PerThreadGroupPool.make();
 }
--- a/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -27,6 +27,7 @@
 
 
 import com.sun.jmx.remote.security.MBeanServerFileAccessController;
+import com.sun.jmx.remote.internal.IIOPHelper;
 import com.sun.jmx.remote.util.ClassLogger;
 import com.sun.jmx.remote.util.EnvHelp;
 
@@ -230,8 +231,6 @@
 
         this.address = url;
         this.rmiServerImpl = rmiServerImpl;
-
-        installStandardForwarders(this.attributes);
     }
 
     /**
@@ -383,7 +382,7 @@
         try {
             if (tracing) logger.trace("start", "setting default class loader");
             defaultClassLoader = EnvHelp.resolveServerClassLoader(
-                    attributes, getSystemMBeanServerForwarder());
+                    attributes, getMBeanServer());
         } catch (InstanceNotFoundException infc) {
             IllegalArgumentException x = new
                 IllegalArgumentException("ClassLoader not found: "+infc);
@@ -398,7 +397,7 @@
         else
             rmiServer = newServer();
 
-        rmiServer.setMBeanServer(getSystemMBeanServerForwarder());
+        rmiServer.setMBeanServer(getMBeanServer());
         rmiServer.setDefaultClassLoader(defaultClassLoader);
         rmiServer.setRMIConnectorServer(this);
         rmiServer.export();
@@ -592,34 +591,12 @@
         return Collections.unmodifiableMap(map);
     }
 
-    /**
-     * {@inheritDoc}
-     * @return true, since this connector server does support a system chain
-     * of forwarders.
-     */
     @Override
-    public boolean supportsSystemMBeanServerForwarder() {
-        return true;
-    }
-
-    /**
-     * {@inheritDoc}
-     * <P>The {@code RMIConnectorServer} class does support closing a specified
-     * client connection.
-     * @throws IllegalStateException if the server is not started or is closed.
-     * @throws IllegalArgumentException if {@code connectionId} is null or is
-     * not the id of any open connection.
-     * @since 1.7
-     */
-    @Override
-    public void closeConnection(String connectionId)
-            throws IOException {
-        if (isActive()) {
-            rmiServerImpl.closeConnection(connectionId);
-        } else {
-            throw new IllegalStateException(
-                    "The server is not started or is closed.");
-        }
+    public synchronized
+        void setMBeanServerForwarder(MBeanServerForwarder mbsf) {
+        super.setMBeanServerForwarder(mbsf);
+        if (rmiServerImpl != null)
+            rmiServerImpl.setMBeanServer(getMBeanServer());
     }
 
     /* We repeat the definitions of connection{Opened,Closed,Failed}
@@ -698,7 +675,7 @@
         final int port;
 
         if (address == null) {
-            if (rmiServer instanceof javax.rmi.CORBA.Stub)
+            if (IIOPHelper.isStub(rmiServer))
                 protocol = "iiop";
             else
                 protocol = "rmi";
@@ -736,7 +713,7 @@
      **/
     static String encodeStub(
             RMIServer rmiServer, Map<String, ?> env) throws IOException {
-        if (rmiServer instanceof javax.rmi.CORBA.Stub)
+        if (IIOPHelper.isStub(rmiServer))
             return "/ior/" + encodeIIOPStub(rmiServer, env);
         else
             return "/stub/" + encodeJRMPStub(rmiServer, env);
@@ -757,10 +734,9 @@
             RMIServer rmiServer, Map<String, ?> env)
             throws IOException {
         try {
-            javax.rmi.CORBA.Stub stub =
-                (javax.rmi.CORBA.Stub) rmiServer;
-            return stub._orb().object_to_string(stub);
-        } catch (org.omg.CORBA.BAD_OPERATION x) {
+            Object orb = IIOPHelper.getOrb(rmiServer);
+            return IIOPHelper.objectToString(orb, rmiServer);
+        } catch (RuntimeException x) {
             throw newIOException(x.getMessage(), x);
         }
     }
--- a/src/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/rmi/RMIIIOPServerImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,9 +33,10 @@
 import java.security.PrivilegedExceptionAction;
 import java.util.Map;
 import java.util.Collections;
-import javax.rmi.PortableRemoteObject;
 import javax.security.auth.Subject;
 
+import com.sun.jmx.remote.internal.IIOPHelper;
+
 /**
  * <p>An {@link RMIServerImpl} that is exported through IIOP and that
  * creates client connections as RMI objects exported through IIOP.
@@ -65,7 +66,7 @@
     }
 
     protected void export() throws IOException {
-        PortableRemoteObject.exportObject(this);
+        IIOPHelper.exportObject(this);
     }
 
     protected String getProtocol() {
@@ -83,7 +84,7 @@
     public Remote toStub() throws IOException {
         // javax.rmi.CORBA.Stub stub =
         //    (javax.rmi.CORBA.Stub) PortableRemoteObject.toStub(this);
-        final Remote stub = PortableRemoteObject.toStub(this);
+        final Remote stub = IIOPHelper.toStub(this);
         // java.lang.System.out.println("NON CONNECTED STUB " + stub);
         // org.omg.CORBA.ORB orb =
         //    org.omg.CORBA.ORB.init((String[])null, (Properties)null);
@@ -117,12 +118,12 @@
         RMIConnection client =
             new RMIConnectionImpl(this, connectionId, getDefaultClassLoader(),
                                   subject, env);
-        PortableRemoteObject.exportObject(client);
+        IIOPHelper.exportObject(client);
         return client;
     }
 
     protected void closeClient(RMIConnection client) throws IOException {
-        PortableRemoteObject.unexportObject(client);
+        IIOPHelper.unexportObject(client);
     }
 
     /**
@@ -134,7 +135,7 @@
      * server failed.
      */
     protected void closeServer() throws IOException {
-        PortableRemoteObject.unexportObject(this);
+        IIOPHelper.unexportObject(this);
     }
 
     @Override
--- a/src/share/classes/javax/management/remote/rmi/RMIServerImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/management/remote/rmi/RMIServerImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -271,52 +271,6 @@
     }
 
     /**
-     * Closes a client connection.
-     * @param connectionId the id of the client connection to be closed.
-     * @throws IllegalArgumentException if {@code connectionId} is null or is
-     * not the id of any open connection.
-     * @throws java.io.IOException if an I/O error appears when closing the
-     * connection.
-     *
-     * @since 1.7
-     */
-    public void closeConnection(String connectionId)
-            throws IOException {
-        final boolean debug = logger.debugOn();
-
-        if (debug) logger.trace("closeConnection","cconnectionId="+connectionId);
-
-        if (connectionId == null)
-            throw new IllegalArgumentException("Null connectionId.");
-
-        RMIConnection client = null;
-        synchronized (clientList) {
-            dropDeadReferences();
-            for (Iterator<WeakReference<RMIConnection>> it = clientList.iterator();
-                 it.hasNext(); ) {
-                client = it.next().get();
-                if (client != null && connectionId.equals(client.getConnectionId())) {
-                    it.remove();
-                    break;
-                }
-            }
-        }
-
-        if (client == null) {
-            throw new IllegalArgumentException("Unknown id: "+connectionId);
-        }
-
-        if (debug) logger.trace("closeConnection", "closing client connection.");
-        closeClient(client);
-
-        if (debug) logger.trace("closeConnection", "sending notif");
-        connServer.connectionClosed(connectionId,
-                                    "Client connection closed", null);
-
-        if (debug) logger.trace("closeConnection","done");
-    }
-
-    /**
      * <p>Creates a new client connection.  This method is called by
      * the public method {@link #newClient(Object)}.</p>
      *
--- a/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/print/attribute/standard/PrinterStateReasons.java	Wed Nov 25 11:08:25 2009 -0800
@@ -65,7 +65,7 @@
  * PrinterStateReason PrinterStateReason} objects to an existing
  * PrinterStateReasons object and remove them again. However, like class
  *  {@link java.util.HashMap java.util.HashMap}, class PrinterStateReasons is
- * bot multiple thread safe. If a PrinterStateReasons object will be used by
+ * not multiple thread safe. If a PrinterStateReasons object will be used by
  * multiple threads, be sure to synchronize its operations (e.g., using a
  * synchronized map view obtained from class {@link java.util.Collections
  * java.util.Collections}).
--- a/src/share/classes/javax/swing/JComponent.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JComponent.java	Wed Nov 25 11:08:25 2009 -0800
@@ -795,7 +795,6 @@
      * @see java.awt.Container#paint
      */
     protected void paintChildren(Graphics g) {
-        boolean isJComponent;
         Graphics sg = g;
 
         synchronized(getTreeLock()) {
@@ -826,12 +825,21 @@
                 }
             }
             boolean printing = getFlag(IS_PRINTING);
+            final Window window = SwingUtilities.getWindowAncestor(this);
+            final boolean isWindowOpaque = window == null || window.isOpaque();
             for (; i >= 0 ; i--) {
                 Component comp = getComponent(i);
-                isJComponent = (comp instanceof JComponent);
-                if (comp != null &&
-                    (isJComponent || isLightweightComponent(comp)) &&
-                    (comp.isVisible() == true)) {
+                if (comp == null) {
+                    continue;
+                }
+
+                final boolean isJComponent = comp instanceof JComponent;
+
+                // Enable painting of heavyweights in non-opaque windows.
+                // See 6884960
+                if ((!isWindowOpaque || isJComponent ||
+                            isLightweightComponent(comp)) && comp.isVisible())
+                {
                     Rectangle cr;
 
                     cr = comp.getBounds(tmpRect);
@@ -887,6 +895,8 @@
                                     }
                                 }
                             } else {
+                                // The component is either lightweight, or
+                                // heavyweight in a non-opaque window
                                 if (!printing) {
                                     comp.paint(cg);
                                 }
@@ -4868,7 +4878,9 @@
      * @see #revalidate
      * @see java.awt.Component#invalidate
      * @see java.awt.Container#validate
-     */
+     * @see java.awt.Container#isValidateRoot
+     */
+    @Override
     public boolean isValidateRoot() {
         return false;
     }
--- a/src/share/classes/javax/swing/JEditorPane.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JEditorPane.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1330,7 +1330,7 @@
      */
     public Dimension getPreferredSize() {
         Dimension d = super.getPreferredSize();
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             TextUI ui = getUI();
             int prefWidth = d.width;
@@ -1452,7 +1452,7 @@
      * match its own, false otherwise
      */
     public boolean getScrollableTracksViewportWidth() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             TextUI ui = getUI();
             int w = port.getWidth();
@@ -1474,7 +1474,7 @@
      *          false otherwise
      */
     public boolean getScrollableTracksViewportHeight() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             TextUI ui = getUI();
             int h = port.getHeight();
--- a/src/share/classes/javax/swing/JList.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JList.java	Wed Nov 25 11:08:25 2009 -0800
@@ -2722,7 +2722,7 @@
                                       getVisibleRowCount() <= 0) {
             return true;
         }
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             return port.getWidth() > getPreferredSize().width;
         }
@@ -2748,7 +2748,7 @@
                      getVisibleRowCount() <= 0) {
             return true;
         }
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             return port.getHeight() > getPreferredSize().height;
         }
--- a/src/share/classes/javax/swing/JRootPane.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JRootPane.java	Wed Nov 25 11:08:25 2009 -0800
@@ -725,8 +725,10 @@
      * because both classes override <code>isValidateRoot</code> to return true.
      *
      * @see JComponent#isValidateRoot
+     * @see java.awt.Container#isValidateRoot
      * @return true
      */
+    @Override
     public boolean isValidateRoot() {
         return true;
     }
--- a/src/share/classes/javax/swing/JScrollPane.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JScrollPane.java	Wed Nov 25 11:08:25 2009 -0800
@@ -453,10 +453,12 @@
      * @see java.awt.Container#validate
      * @see JComponent#revalidate
      * @see JComponent#isValidateRoot
+     * @see java.awt.Container#isValidateRoot
      *
      * @beaninfo
      *    hidden: true
      */
+    @Override
     public boolean isValidateRoot() {
         return true;
     }
--- a/src/share/classes/javax/swing/JSplitPane.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JSplitPane.java	Wed Nov 25 11:08:25 2009 -0800
@@ -947,10 +947,12 @@
      *
      * @return true
      * @see JComponent#revalidate
+     * @see java.awt.Container#isValidateRoot
      *
      * @beaninfo
      *    hidden: true
      */
+    @Override
     public boolean isValidateRoot() {
         return true;
     }
--- a/src/share/classes/javax/swing/JTable.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JTable.java	Wed Nov 25 11:08:25 2009 -0800
@@ -57,6 +57,7 @@
 import sun.swing.SwingUtilities2.Section;
 import static sun.swing.SwingUtilities2.Section.*;
 import sun.swing.PrintingStatus;
+import sun.swing.SwingLazyValue;
 
 /**
  * The <code>JTable</code> is used to display and edit regular two-dimensional tables
@@ -718,7 +719,7 @@
      * @see #addNotify
      */
     protected void configureEnclosingScrollPane() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             Container gp = port.getParent();
             if (gp instanceof JScrollPane) {
@@ -727,7 +728,8 @@
                 // example, the rowHeaderView of the scrollPane -
                 // an implementor of fixed columns might do this.
                 JViewport viewport = scrollPane.getViewport();
-                if (viewport == null || viewport.getView() != this) {
+                if (viewport == null ||
+                        SwingUtilities.getUnwrappedView(viewport) != this) {
                     return;
                 }
                 scrollPane.setColumnHeaderView(getTableHeader());
@@ -750,7 +752,7 @@
      * from configureEnclosingScrollPane() and updateUI() in a safe manor.
      */
     private void configureEnclosingScrollPaneUI() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             Container gp = port.getParent();
             if (gp instanceof JScrollPane) {
@@ -759,7 +761,8 @@
                 // example, the rowHeaderView of the scrollPane -
                 // an implementor of fixed columns might do this.
                 JViewport viewport = scrollPane.getViewport();
-                if (viewport == null || viewport.getView() != this) {
+                if (viewport == null ||
+                        SwingUtilities.getUnwrappedView(viewport) != this) {
                     return;
                 }
                 //  scrollPane.getViewport().setBackingStoreEnabled(true);
@@ -819,7 +822,7 @@
      * @since 1.3
      */
     protected void unconfigureEnclosingScrollPane() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             Container gp = port.getParent();
             if (gp instanceof JScrollPane) {
@@ -828,7 +831,8 @@
                 // example, the rowHeaderView of the scrollPane -
                 // an implementor of fixed columns might do this.
                 JViewport viewport = scrollPane.getViewport();
-                if (viewport == null || viewport.getView() != this) {
+                if (viewport == null ||
+                        SwingUtilities.getUnwrappedView(viewport) != this) {
                     return;
                 }
                 scrollPane.setColumnHeaderView(null);
@@ -5215,7 +5219,7 @@
      * @see #getFillsViewportHeight
      */
     public boolean getScrollableTracksViewportHeight() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         return getFillsViewportHeight()
                && port != null
                && port.getHeight() > getPreferredSize().height;
@@ -5316,7 +5320,7 @@
     }
 
     private void setLazyValue(Hashtable h, Class c, String s) {
-        h.put(c, new UIDefaults.ProxyLazyValue(s));
+        h.put(c, new SwingLazyValue(s));
     }
 
     private void setLazyRenderer(Class c, String s) {
--- a/src/share/classes/javax/swing/JTextField.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JTextField.java	Wed Nov 25 11:08:25 2009 -0800
@@ -288,9 +288,11 @@
      *
      * @see JComponent#revalidate
      * @see JComponent#isValidateRoot
+     * @see java.awt.Container#isValidateRoot
      */
+    @Override
     public boolean isValidateRoot() {
-        return SwingUtilities2.getViewport(this) == null;
+        return SwingUtilities.getParentViewport(this) == null;
     }
 
 
--- a/src/share/classes/javax/swing/JTree.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JTree.java	Wed Nov 25 11:08:25 2009 -0800
@@ -3498,7 +3498,7 @@
      * @see Scrollable#getScrollableTracksViewportWidth
      */
     public boolean getScrollableTracksViewportWidth() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             return port.getWidth() > getPreferredSize().width;
         }
@@ -3515,7 +3515,7 @@
      * @see Scrollable#getScrollableTracksViewportHeight
      */
     public boolean getScrollableTracksViewportHeight() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             return port.getHeight() > getPreferredSize().height;
         }
--- a/src/share/classes/javax/swing/JViewport.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/JViewport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -469,49 +469,12 @@
      * is the synchronous version of a <code>revalidate</code>.
      */
     private void validateView() {
-        Component validateRoot = null;
+        Component validateRoot = SwingUtilities.getValidateRoot(this, false);
 
-        /* Find the first JComponent ancestor of this component whose
-         * isValidateRoot() method returns true.
-         */
-        for(Component c = this; c != null; c = c.getParent()) {
-            if ((c instanceof CellRendererPane) || (c.getPeer() == null)) {
-                return;
-            }
-            if ((c instanceof JComponent) &&
-                (((JComponent)c).isValidateRoot())) {
-                validateRoot = c;
-                break;
-            }
-        }
-
-        // If no validateRoot, nothing to validate from.
         if (validateRoot == null) {
             return;
         }
 
-        // Make sure all ancestors are visible.
-        Component root = null;
-
-        for(Component c = validateRoot; c != null; c = c.getParent()) {
-            // We don't check isVisible here, otherwise if the component
-            // is contained in something like a JTabbedPane when the
-            // component is made visible again it won't have scrolled
-            // to the correct location.
-            if (c.getPeer() == null) {
-                return;
-            }
-            if ((c instanceof Window) || (c instanceof Applet)) {
-                root = c;
-                break;
-            }
-        }
-
-        // Make sure there is a Window ancestor.
-        if (root == null) {
-            return;
-        }
-
         // Validate the root.
         validateRoot.validate();
 
--- a/src/share/classes/javax/swing/RepaintManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/RepaintManager.java	Wed Nov 25 11:08:25 2009 -0800
@@ -310,47 +310,13 @@
             delegate.addInvalidComponent(invalidComponent);
             return;
         }
-        Component validateRoot = null;
+        Component validateRoot =
+            SwingUtilities.getValidateRoot(invalidComponent, true);
 
-        /* Find the first JComponent ancestor of this component whose
-         * isValidateRoot() method returns true.
-         */
-        for(Component c = invalidComponent; c != null; c = c.getParent()) {
-            if ((c instanceof CellRendererPane) || (c.getPeer() == null)) {
-                return;
-            }
-            if ((c instanceof JComponent) && (((JComponent)c).isValidateRoot())) {
-                validateRoot = c;
-                break;
-            }
-        }
-
-        /* There's no validateRoot to apply validate to, so we're done.
-         */
         if (validateRoot == null) {
             return;
         }
 
-        /* If the validateRoot and all of its ancestors aren't visible
-         * then we don't do anything.  While we're walking up the tree
-         * we find the root Window or Applet.
-         */
-        Component root = null;
-
-        for(Component c = validateRoot; c != null; c = c.getParent()) {
-            if (!c.isVisible() || (c.getPeer() == null)) {
-                return;
-            }
-            if ((c instanceof Window) || (c instanceof Applet)) {
-                root = c;
-                break;
-            }
-        }
-
-        if (root == null) {
-            return;
-        }
-
         /* Lazily create the invalidateComponents vector and add the
          * validateRoot if it's not there already.  If this validateRoot
          * is already in the vector, we're done.
--- a/src/share/classes/javax/swing/SwingUtilities.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/SwingUtilities.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1967,4 +1967,114 @@
             SwingUtilities.updateComponentTreeUI(component);
         }
     }
+
+    /**
+     * Looks for the first ancestor of the {@code component}
+     * which is not an instance of {@link JLayer}.
+     * If this ancestor is an instance of {@code JViewport},
+     * this {@code JViewport} is returned, otherwise returns {@code null}.
+     * The following way of obtaining the parent {@code JViewport}
+     * is not recommended any more:
+     * <pre>
+     * JViewport port = null;
+     * Container parent = component.getParent();
+     * // not recommended any more
+     * if(parent instanceof JViewport) {
+     *     port = (JViewport) parent;
+     * }
+     * </pre>
+     * Here is the way to go:
+     * <pre>
+     * // the correct way:
+     * JViewport port = SwingUtilities.getParentViewport(component);
+     * </pre>
+     * @param component {@code Component} to get the parent {@code JViewport} of.
+     * @return the {@code JViewport} instance for the {@code component}
+     * or {@code null}
+     * @throws NullPointerException if {@code component} is {@code null}
+     *
+     * @since 1.7
+     */
+    public static JViewport getParentViewport(Component component) {
+        do {
+            component = component.getParent();
+            if (component instanceof JViewport) {
+                return (JViewport) component;
+            }
+        } while(component instanceof JLayer);
+        return null;
+    }
+
+    /**
+     * Returns the first {@code JViewport}'s descendant
+     * which is not an instance of {@code JLayer} or {@code null}.
+     *
+     * If the {@code viewport}'s view component is not a {@code JLayer},
+     * this method is equal to {@link JViewport#getView()}
+     * otherwise {@link JLayer#getView()} will be recursively tested
+     *
+     * @return the first {@code JViewport}'s descendant
+     * which is not an instance of {@code JLayer} or {@code null}.
+     *
+     * @throws NullPointerException if {@code viewport} is {@code null}
+     * @see JViewport#getView()
+     * @see JLayer
+     */
+    static Component getUnwrappedView(JViewport viewport) {
+        Component view = viewport.getView();
+        while (view instanceof JLayer) {
+            view = ((JLayer)view).getView();
+        }
+        return view;
+    }
+
+   /**
+     * Retrieves the validate root of a given container.
+     *
+     * If the container is contained within a {@code CellRendererPane}, this
+     * method returns {@code null} due to the synthetic nature of the {@code
+     * CellRendererPane}.
+     * <p>
+     * The component hierarchy must be displayable up to the toplevel component
+     * (either a {@code Frame} or an {@code Applet} object.) Otherwise this
+     * method returns {@code null}.
+     * <p>
+     * If the {@code visibleOnly} argument is {@code true}, the found validate
+     * root and all its parents up to the toplevel component must also be
+     * visible. Otherwise this method returns {@code null}.
+     *
+     * @return the validate root of the given container or null
+     * @see java.awt.Component#isDisplayable()
+     * @see java.awt.Component#isVisible()
+     * @since 1.7
+     */
+    static Container getValidateRoot(Container c, boolean visibleOnly) {
+        Container root = null;
+
+        for (; c != null; c = c.getParent())
+        {
+            if (!c.isDisplayable() || c instanceof CellRendererPane) {
+                return null;
+            }
+            if (c.isValidateRoot()) {
+                root = c;
+                break;
+            }
+        }
+
+        if (root == null) {
+            return null;
+        }
+
+        for (; c != null; c = c.getParent()) {
+            if (!c.isDisplayable() || (visibleOnly && !c.isVisible())) {
+                return null;
+            }
+            if (c instanceof Window || c instanceof Applet) {
+                return root;
+            }
+        }
+
+        return null;
+    }
 }
--- a/src/share/classes/javax/swing/ToolTipManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/ToolTipManager.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -27,10 +27,7 @@
 package javax.swing;
 
 import java.awt.event.*;
-import java.applet.*;
 import java.awt.*;
-import java.io.Serializable;
-import sun.swing.UIAction;
 
 /**
  * Manages all the <code>ToolTips</code> in the system.
@@ -60,7 +57,7 @@
     JComponent insideComponent;
     MouseEvent mouseEvent;
     boolean showImmediately;
-    final static ToolTipManager sharedInstance = new ToolTipManager();
+    private static final Object TOOL_TIP_MANAGER_KEY = new Object();
     transient Popup tipWindow;
     /** The Window tip is being displayed in. This will be non-null if
      * the Window tip is in differs from that of insideComponent's Window.
@@ -345,7 +342,13 @@
      * @return a shared <code>ToolTipManager</code> object
      */
     public static ToolTipManager sharedInstance() {
-        return sharedInstance;
+        Object value = SwingUtilities.appContextGet(TOOL_TIP_MANAGER_KEY);
+        if (value instanceof ToolTipManager) {
+            return (ToolTipManager) value;
+        }
+        ToolTipManager manager = new ToolTipManager();
+        SwingUtilities.appContextPut(TOOL_TIP_MANAGER_KEY, manager);
+        return manager;
     }
 
     // add keylistener here to trigger tip for access
--- a/src/share/classes/javax/swing/UIManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/UIManager.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -197,6 +197,8 @@
         Vector<LookAndFeel> auxLookAndFeels = null;
         SwingPropertyChangeSupport changeSupport;
 
+        LookAndFeelInfo[] installedLAFs;
+
         UIDefaults getLookAndFeelDefaults() { return tables[0]; }
         void setLookAndFeelDefaults(UIDefaults x) { tables[0] = x; }
 
@@ -227,18 +229,6 @@
      */
     private static final Object classLock = new Object();
 
-
-    /* Cache the last referenced LAFState to improve performance
-     * when accessing it.  The cache is based on last thread rather
-     * than last AppContext because of the cost of looking up the
-     * AppContext each time.  Since most Swing UI work is on the
-     * EventDispatchThread, this hits often enough to justify the
-     * overhead.  (4193032)
-     */
-    private static Thread currentLAFStateThread = null;
-    private static LAFState currentLAFState = null;
-
-
     /**
      * Return the <code>LAFState</code> object, lazily create one if necessary.
      * All access to the <code>LAFState</code> fields is done via this method,
@@ -248,13 +238,6 @@
      * </pre>
      */
     private static LAFState getLAFState() {
-        // First check whether we're running on the same thread as
-        // the last request.
-        Thread thisThread = Thread.currentThread();
-        if (thisThread == currentLAFStateThread) {
-            return currentLAFState;
-        }
-
         LAFState rv = (LAFState)SwingUtilities.appContextGet(
                 SwingUtilities2.LAF_STATE_KEY);
         if (rv == null) {
@@ -268,10 +251,6 @@
                 }
             }
         }
-
-        currentLAFStateThread = thisThread;
-        currentLAFState = rv;
-
         return rv;
     }
 
@@ -431,7 +410,10 @@
      */
     public static LookAndFeelInfo[] getInstalledLookAndFeels() {
         maybeInitialize();
-        LookAndFeelInfo[] ilafs = installedLAFs;
+        LookAndFeelInfo[] ilafs = getLAFState().installedLAFs;
+        if (ilafs == null) {
+            ilafs = installedLAFs;
+        }
         LookAndFeelInfo[] rv = new LookAndFeelInfo[ilafs.length];
         System.arraycopy(ilafs, 0, rv, 0, ilafs.length);
         return rv;
@@ -453,9 +435,10 @@
     public static void setInstalledLookAndFeels(LookAndFeelInfo[] infos)
         throws SecurityException
     {
+        maybeInitialize();
         LookAndFeelInfo[] newInfos = new LookAndFeelInfo[infos.length];
         System.arraycopy(infos, 0, newInfos, 0, infos.length);
-        installedLAFs = newInfos;
+        getLAFState().installedLAFs = newInfos;
     }
 
 
@@ -1307,10 +1290,11 @@
             }
         }
 
-        installedLAFs = new LookAndFeelInfo[ilafs.size()];
+        LookAndFeelInfo[] installedLAFs = new LookAndFeelInfo[ilafs.size()];
         for(int i = 0; i < ilafs.size(); i++) {
             installedLAFs[i] = ilafs.elementAt(i);
         }
+        getLAFState().installedLAFs = installedLAFs;
     }
 
 
--- a/src/share/classes/javax/swing/filechooser/FileSystemView.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/filechooser/FileSystemView.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,7 +33,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.text.MessageFormat;
-import java.util.Vector;
+import java.util.List;
+import java.util.ArrayList;
 import java.lang.ref.WeakReference;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeEvent;
@@ -173,22 +174,27 @@
      * @since 1.4
      */
     public String getSystemDisplayName(File f) {
-        String name = null;
-        if (f != null) {
-            name = f.getName();
-            if (!name.equals("..") && !name.equals(".") &&
-                (useSystemExtensionHiding ||
-                 !isFileSystem(f) ||
-                 isFileSystemRoot(f)) &&
-                ((f instanceof ShellFolder) ||
-                 f.exists())) {
+        if (f == null) {
+            return null;
+        }
+
+        String name = f.getName();
 
+        if (!name.equals("..") && !name.equals(".") &&
+                (useSystemExtensionHiding || !isFileSystem(f) || isFileSystemRoot(f)) &&
+                (f instanceof ShellFolder || f.exists())) {
+
+            try {
                 name = getShellFolder(f).getDisplayName();
-                if (name == null || name.length() == 0) {
-                    name = f.getPath(); // e.g. "/"
-                }
+            } catch (FileNotFoundException e) {
+                return null;
+            }
+
+            if (name == null || name.length() == 0) {
+                name = f.getPath(); // e.g. "/"
             }
         }
+
         return name;
     }
 
@@ -222,16 +228,24 @@
      * @since 1.4
      */
     public Icon getSystemIcon(File f) {
-        if (f != null) {
-            ShellFolder sf = getShellFolder(f);
-            Image img = sf.getIcon(false);
-            if (img != null) {
-                return new ImageIcon(img, sf.getFolderType());
-            } else {
-                return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon");
-            }
+        if (f == null) {
+            return null;
+        }
+
+        ShellFolder sf;
+
+        try {
+            sf = getShellFolder(f);
+        } catch (FileNotFoundException e) {
+            return null;
+        }
+
+        Image img = sf.getIcon(false);
+
+        if (img != null) {
+            return new ImageIcon(img, sf.getFolderType());
         } else {
-            return null;
+            return UIManager.getIcon(f.isDirectory() ? "FileView.directoryIcon" : "FileView.fileIcon");
         }
     }
 
@@ -446,24 +460,28 @@
      * Gets the list of shown (i.e. not hidden) files.
      */
     public File[] getFiles(File dir, boolean useFileHiding) {
-        Vector<File> files = new Vector<File>();
-
+        List<File> files = new ArrayList<File>();
 
         // add all files in dir
-        File[] names;
-            if (!(dir instanceof ShellFolder)) {
+        if (!(dir instanceof ShellFolder)) {
+            try {
                 dir = getShellFolder(dir);
+            } catch (FileNotFoundException e) {
+                return new File[0];
             }
+        }
 
-            names = ((ShellFolder)dir).listFiles(!useFileHiding);
-        File f;
+        File[] names = ((ShellFolder) dir).listFiles(!useFileHiding);
 
-        int nameCount = (names == null) ? 0 : names.length;
-        for (int i = 0; i < nameCount; i++) {
+        if (names == null) {
+            return new File[0];
+        }
+
+        for (File f : names) {
             if (Thread.currentThread().isInterrupted()) {
                 break;
             }
-            f = names[i];
+
             if (!(f instanceof ShellFolder)) {
                 if (isFileSystemRoot(f)) {
                     f = createFileSystemRoot(f);
@@ -481,7 +499,7 @@
                 }
             }
             if (!useFileHiding || !isHiddenFile(f)) {
-                files.addElement(f);
+                files.add(f);
             }
         }
 
@@ -497,42 +515,50 @@
      *   <code>null</code> if <code>dir</code> is <code>null</code>
      */
     public File getParentDirectory(File dir) {
-        if (dir != null && dir.exists()) {
-            ShellFolder sf = getShellFolder(dir);
-            File psf = sf.getParentFile();
-            if (psf != null) {
-                if (isFileSystem(psf)) {
-                    File f = psf;
-                    if (f != null && !f.exists()) {
-                        // This could be a node under "Network Neighborhood".
-                        File ppsf = psf.getParentFile();
-                        if (ppsf == null || !isFileSystem(ppsf)) {
-                            // We're mostly after the exists() override for windows below.
-                            f = createFileSystemRoot(f);
-                        }
-                    }
-                    return f;
-                } else {
-                    return psf;
+        if (dir == null || !dir.exists()) {
+            return null;
+        }
+
+        ShellFolder sf;
+
+        try {
+            sf = getShellFolder(dir);
+        } catch (FileNotFoundException e) {
+            return null;
+        }
+
+        File psf = sf.getParentFile();
+
+        if (psf == null) {
+            return null;
+        }
+
+        if (isFileSystem(psf)) {
+            File f = psf;
+            if (!f.exists()) {
+                // This could be a node under "Network Neighborhood".
+                File ppsf = psf.getParentFile();
+                if (ppsf == null || !isFileSystem(ppsf)) {
+                    // We're mostly after the exists() override for windows below.
+                    f = createFileSystemRoot(f);
                 }
             }
+            return f;
+        } else {
+            return psf;
         }
-        return null;
     }
 
-    ShellFolder getShellFolder(File f) {
-        if (!(f instanceof ShellFolder)
-            && !(f instanceof FileSystemRoot)
-            && isFileSystemRoot(f)) {
-
+    /**
+     * Throws {@code FileNotFoundException} if file not found or current thread was interrupted
+     */
+    ShellFolder getShellFolder(File f) throws FileNotFoundException {
+        if (!(f instanceof ShellFolder) && !(f instanceof FileSystemRoot) && isFileSystemRoot(f)) {
             f = createFileSystemRoot(f);
         }
+
         try {
             return ShellFolder.getShellFolder(f);
-        } catch (FileNotFoundException e) {
-            System.err.println("FileSystemView.getShellFolder: f="+f);
-            e.printStackTrace();
-            return null;
         } catch (InternalError e) {
             System.err.println("FileSystemView.getShellFolder: f="+f);
             e.printStackTrace();
@@ -596,9 +622,9 @@
         // Unix - using OpenWindows' default folder name. Can't find one for Motif/CDE.
         newFolder = createFileObject(containingDir, newFolderString);
         int i = 1;
-        while (newFolder.exists() && (i < 100)) {
+        while (newFolder.exists() && i < 100) {
             newFolder = createFileObject(containingDir, MessageFormat.format(
-                    newFolderNextString, new Object[] { new Integer(i) }));
+                    newFolderNextString, new Integer(i)));
             i++;
         }
 
@@ -612,7 +638,7 @@
     }
 
     public boolean isFileSystemRoot(File dir) {
-        return (dir != null && dir.getAbsolutePath().equals("/"));
+        return dir != null && dir.getAbsolutePath().equals("/");
     }
 
     public boolean isDrive(File dir) {
@@ -654,7 +680,7 @@
 
     public File getChild(File parent, String fileName) {
         if (fileName.startsWith("\\")
-            && !(fileName.startsWith("\\\\"))
+            && !fileName.startsWith("\\\\")
             && isFileSystem(parent)) {
 
             //Path is relative to the root of parent's drive
@@ -677,9 +703,13 @@
      * The Windows implementation gets information from the ShellFolder class.
      */
     public String getSystemTypeDescription(File f) {
-        if (f != null) {
+        if (f == null) {
+            return null;
+        }
+
+        try {
             return getShellFolder(f).getFolderType();
-        } else {
+        } catch (FileNotFoundException e) {
             return null;
         }
     }
@@ -701,9 +731,9 @@
         // Using NT's default folder name
         File newFolder = createFileObject(containingDir, newFolderString);
         int i = 2;
-        while (newFolder.exists() && (i < 100)) {
+        while (newFolder.exists() && i < 100) {
             newFolder = createFileObject(containingDir, MessageFormat.format(
-                newFolderNextString, new Object[] { new Integer(i) }));
+                newFolderNextString, new Integer(i)));
             i++;
         }
 
@@ -727,7 +757,7 @@
             }
         });
 
-        return (path != null && (path.equals("A:\\") || path.equals("B:\\")));
+        return path != null && (path.equals("A:\\") || path.equals("B:\\"));
     }
 
     /**
--- a/src/share/classes/javax/swing/plaf/LayerUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/LayerUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -71,33 +71,410 @@
      * Subclasses should override this method and use
      * the specified {@code Graphics} object to
      * render the content of the component.
+     * <p/>
+     * If {@code g} is not an instance of {@code Graphics2D},
+     * this method is no-op.
      *
      * @param g the {@code Graphics} context in which to paint;
      * @param c the component being painted;
-     * it can be safely cast to the {@code JLayer<V>}
+     * it can be safely cast to {@code JLayer<? extends V>}
+     *
+     * @see #configureGraphics(Graphics2D, JLayer)
+     * @see #paintLayer(Graphics2D, JLayer)
      */
-    @Override
     public void paint(Graphics g, JComponent c) {
-        c.paint(g);
+        if (g instanceof Graphics2D) {
+            Graphics2D g2 = (Graphics2D) g.create();
+            JLayer<? extends V> l = (JLayer<? extends V>) c;
+            configureGraphics(g2, l);
+            paintLayer(g2, l);
+            g2.dispose();
+        }
+    }
+
+    /**
+     * This method is called by the {@link #paint} method prior to
+     * {@link #paintLayer} to configure the {@code Graphics2D} object.
+     * The default implementation is empty.
+     *
+     * @param g2 the {@code Graphics2D} object to configure
+     * @param l the {@code JLayer} being painted
+     *
+     * @see #paintLayer(Graphics2D, JLayer)
+     */
+    protected void configureGraphics(Graphics2D g2, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Called by the {@link #paint} method,
+     * subclasses should override this method
+     * to perform any custom painting operations.
+     * <p/>
+     * The default implementation paints the passed {@code JLayer} as is.
+     *
+     * @param g2 the {@code Graphics2D} context in which to paint
+     * @param l the {@code JLayer} being painted
+     *
+     * @see #configureGraphics(Graphics2D, JLayer)
+     */
+    protected void paintLayer(Graphics2D g2, JLayer<? extends V> l) {
+        l.paint(g2);
     }
 
     /**
      * Dispatches {@code AWTEvent}s for {@code JLayer}
-     * and <b>all it subcomponents</b> to this {@code LayerUI} instance.
-     * <p>
-     * To enable the {@code AWTEvent} of the particular type,
-     * you call {@link javax.swing.JLayer#setLayerEventMask}
+     * and <b>all its subcomponents</b> to this {@code LayerUI} instance.
+     * <p/>
+     * To enable the {@code AWTEvent}s of a particular type,
+     * you call {@link JLayer#setLayerEventMask}
      * in {@link #installUI(javax.swing.JComponent)}
      * and set the layer event mask to {@code 0}
-     * in {@link #uninstallUI(javax.swing.JComponent)} after that
+     * in {@link #uninstallUI(javax.swing.JComponent)} after that.
+     * By default this  method calls the appropriate
+     * {@code process&lt;event&nbsp;type&gt;Event}
+     * method for the given class of event.
      *
      * @param e the event to be dispatched
      * @param l the layer this LayerUI is set to
      *
      * @see JLayer#setLayerEventMask(long)
-     * @see javax.swing.JLayer#getLayerEventMask()
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     * @see #processComponentEvent
+     * @see #processFocusEvent
+     * @see #processKeyEvent
+     * @see #processMouseEvent
+     * @see #processMouseMotionEvent
+     * @see #processInputMethodEvent
+     * @see #processHierarchyEvent
+     * @see #processMouseWheelEvent
      */
     public void eventDispatched(AWTEvent e, JLayer<? extends V> l){
+        if (e instanceof FocusEvent) {
+            processFocusEvent((FocusEvent)e, l);
+
+        } else if (e instanceof MouseEvent) {
+            switch(e.getID()) {
+              case MouseEvent.MOUSE_PRESSED:
+              case MouseEvent.MOUSE_RELEASED:
+              case MouseEvent.MOUSE_CLICKED:
+              case MouseEvent.MOUSE_ENTERED:
+              case MouseEvent.MOUSE_EXITED:
+                  processMouseEvent((MouseEvent)e, l);
+                  break;
+              case MouseEvent.MOUSE_MOVED:
+              case MouseEvent.MOUSE_DRAGGED:
+                  processMouseMotionEvent((MouseEvent)e, l);
+                  break;
+              case MouseEvent.MOUSE_WHEEL:
+                  processMouseWheelEvent((MouseWheelEvent)e, l);
+                  break;
+            }
+        } else if (e instanceof KeyEvent) {
+            processKeyEvent((KeyEvent)e, l);
+        } else if (e instanceof ComponentEvent) {
+            processComponentEvent((ComponentEvent)e, l);
+        } else if (e instanceof InputMethodEvent) {
+            processInputMethodEvent((InputMethodEvent)e, l);
+        } else if (e instanceof HierarchyEvent) {
+            switch (e.getID()) {
+              case HierarchyEvent.HIERARCHY_CHANGED:
+                  processHierarchyEvent((HierarchyEvent)e, l);
+                  break;
+              case HierarchyEvent.ANCESTOR_MOVED:
+              case HierarchyEvent.ANCESTOR_RESIZED:
+                  processHierarchyBoundsEvent((HierarchyEvent)e, l);
+                  break;
+            }
+        }
+    }
+
+    /**
+     * Processes component events occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless component events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Component events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.COMPONENT_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code ComponentEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processComponentEvent(ComponentEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes focus events occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless focus events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Focus events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.FOCUS_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code FocusEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processFocusEvent(FocusEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes key events occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless key events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Key events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.KEY_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code KeyEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processKeyEvent(KeyEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes mouse events occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless mouse events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Mouse events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.MOUSE_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code MouseEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processMouseEvent(MouseEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes mouse motion event occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless mouse motion events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Mouse motion events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.MOUSE_MOTION_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code MouseEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processMouseMotionEvent(MouseEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes mouse wheel event occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless mouse wheel events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Mouse wheel events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.MOUSE_WHEEL_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code MouseEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processMouseWheelEvent(MouseWheelEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes input event occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless input events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Input events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.INPUT_METHOD_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code InputMethodEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processInputMethodEvent(InputMethodEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes hierarchy event occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless hierarchy events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Hierarchy events are enabled in the overridden {@link #installUI} method
+     * and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.HIERARCHY_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code HierarchyEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processHierarchyEvent(HierarchyEvent e, JLayer<? extends V> l) {
+    }
+
+    /**
+     * Processes hierarchy bounds event occurring on the {@link JLayer}
+     * or any of its subcomponents.
+     * <p/>
+     * This method is not called unless hierarchy bounds events are
+     * enabled for the {@code JLayer} objects, this {@code LayerUI} is set to.
+     * Hierarchy bounds events are enabled in the overridden {@link #installUI}
+     * method and should be disabled in the {@link #uninstallUI} method after that.
+     * <pre>
+     * public void installUI(JComponent c) {
+     *    super.installUI(c);
+     *    JLayer l = (JLayer) c;
+     *    l.setLayerEventMask(AWTEvent.HIERARCHY_BOUNDS_EVENT_MASK);
+     * }
+     *
+     * public void unistallUI(JComponent c) {
+     *     super.uninstallUI(c);
+     *     JLayer l = (JLayer) c;
+     *     l.setLayerEventMask(0);
+     * }
+     * </pre>
+     *
+     * @param e the {@code HierarchyEvent} to be processed
+     * @param l the layer this {@code LayerUI} instance is set to
+     *
+     * @see JLayer#setLayerEventMask(long)
+     * @see #installUI(javax.swing.JComponent)
+     * @see #uninstallUI(javax.swing.JComponent)
+     */
+    protected void processHierarchyBoundsEvent(HierarchyEvent e, JLayer<? extends V> l) {
     }
 
     /**
@@ -251,13 +628,28 @@
     }
 
     /**
+     * Repaints all {@code JLayer} instances this {@code LayerUI} is set to.
+     * Call this method when the state of this {@code LayerUI} is changed
+     * and the visual appearance of its {@code JLayer} objects needs to be updated.
+     *
+     * @see Component#repaint()
+     */
+    protected void repaintLayer() {
+        firePropertyChange("dirty", null, null);
+    }
+
+    /**
      * Notifies the {@code LayerUI} when any of its property are changed
-     * and enables updating every {@code JLayer} this {@code LayerUI} instance is set to.
+     * and enables updating every {@code JLayer}
+     * this {@code LayerUI} instance is set to.
      *
      * @param evt the PropertyChangeEvent generated by this {@code LayerUI}
      * @param l the {@code JLayer} this LayerUI is set to
      */
     public void applyPropertyChange(PropertyChangeEvent evt, JLayer<? extends V> l) {
+        if ("dirty".equals(evt.getPropertyName())) {
+            l.repaint();
+        }
     }
 
     /**
--- a/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/basic/BasicButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
 package javax.swing.plaf.basic;
 
 import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
+
 import java.awt.*;
 import java.awt.event.*;
 import java.io.Serializable;
@@ -44,9 +46,6 @@
  * @author Jeff Dinkins
  */
 public class BasicButtonUI extends ButtonUI{
-    // Shared UI object
-    private final static BasicButtonUI buttonUI = new BasicButtonUI();
-
     // Visual constants
     // NOTE: This is not used or set any where. Were we allowed to remove
     // fields, this would be removed.
@@ -61,10 +60,19 @@
 
     private final static String propertyPrefix = "Button" + ".";
 
+    private static final Object BASIC_BUTTON_UI_KEY = new Object();
+
     // ********************************
     //          Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        BasicButtonUI buttonUI =
+                (BasicButtonUI) appContext.get(BASIC_BUTTON_UI_KEY);
+        if (buttonUI == null) {
+            buttonUI = new BasicButtonUI();
+            appContext.put(BASIC_BUTTON_UI_KEY, buttonUI);
+        }
         return buttonUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/basic/BasicCheckBoxUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/basic/BasicCheckBoxUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package javax.swing.plaf.basic;
 
+import sun.awt.AppContext;
+
 import javax.swing.*;
 
 import java.awt.*;
@@ -49,7 +51,7 @@
  */
 public class BasicCheckBoxUI extends BasicRadioButtonUI {
 
-    private final static BasicCheckBoxUI checkboxUI = new BasicCheckBoxUI();
+    private static final Object BASIC_CHECK_BOX_UI_KEY = new Object();
 
     private final static String propertyPrefix = "CheckBox" + ".";
 
@@ -57,6 +59,13 @@
     //            Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent b) {
+        AppContext appContext = AppContext.getAppContext();
+        BasicCheckBoxUI checkboxUI =
+                (BasicCheckBoxUI) appContext.get(BASIC_CHECK_BOX_UI_KEY);
+        if (checkboxUI == null) {
+            checkboxUI = new BasicCheckBoxUI();
+            appContext.put(BASIC_CHECK_BOX_UI_KEY, checkboxUI);
+        }
         return checkboxUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/basic/BasicDirectoryModel.java	Wed Nov 25 11:08:25 2009 -0800
@@ -486,7 +486,7 @@
                 }
                 if (remSize > 0 && addSize == 0) {
                     fireIntervalRemoved(BasicDirectoryModel.this, remStart, remStart + remSize - 1);
-                } else if (addSize > 0 && remSize == 0 && fileCache.size() > addSize) {
+                } else if (addSize > 0 && remSize == 0 && addStart + addSize <= fileCache.size()) {
                     fireIntervalAdded(BasicDirectoryModel.this, addStart, addStart + addSize - 1);
                 } else {
                     fireContentsChanged();
--- a/src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -28,6 +28,8 @@
 import sun.swing.SwingUtilities2;
 import sun.swing.DefaultLookup;
 import sun.swing.UIAction;
+import sun.awt.AppContext;
+
 import javax.swing.*;
 import javax.swing.plaf.*;
 import javax.swing.text.View;
@@ -63,7 +65,7 @@
     * name in defaults table under the key "LabelUI".
     */
     protected static BasicLabelUI labelUI = new BasicLabelUI();
-    private final static BasicLabelUI SAFE_BASIC_LABEL_UI = new BasicLabelUI();
+    private static final Object BASIC_LABEL_UI_KEY = new Object();
 
     private Rectangle paintIconR = new Rectangle();
     private Rectangle paintTextR = new Rectangle();
@@ -394,10 +396,16 @@
 
     public static ComponentUI createUI(JComponent c) {
         if (System.getSecurityManager() != null) {
-            return SAFE_BASIC_LABEL_UI;
-        } else {
-            return labelUI;
+            AppContext appContext = AppContext.getAppContext();
+            BasicLabelUI safeBasicLabelUI =
+                    (BasicLabelUI) appContext.get(BASIC_LABEL_UI_KEY);
+            if (safeBasicLabelUI == null) {
+                safeBasicLabelUI = new BasicLabelUI();
+                appContext.put(BASIC_LABEL_UI_KEY, safeBasicLabelUI);
+            }
+            return safeBasicLabelUI;
         }
+        return labelUI;
     }
 
     public void propertyChange(PropertyChangeEvent e) {
--- a/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/basic/BasicRadioButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,6 +32,7 @@
 import javax.swing.plaf.*;
 import javax.swing.text.View;
 import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
 
 
 /**
@@ -41,7 +42,7 @@
  */
 public class BasicRadioButtonUI extends BasicToggleButtonUI
 {
-    private final static BasicRadioButtonUI radioButtonUI = new BasicRadioButtonUI();
+    private static final Object BASIC_RADIO_BUTTON_UI_KEY = new Object();
 
     protected Icon icon;
 
@@ -53,6 +54,13 @@
     //        Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent b) {
+        AppContext appContext = AppContext.getAppContext();
+        BasicRadioButtonUI radioButtonUI =
+                (BasicRadioButtonUI) appContext.get(BASIC_RADIO_BUTTON_UI_KEY);
+        if (radioButtonUI == null) {
+            radioButtonUI = new BasicRadioButtonUI();
+            appContext.put(BASIC_RADIO_BUTTON_UI_KEY, radioButtonUI);
+        }
         return radioButtonUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -31,14 +31,12 @@
 import sun.swing.UIAction;
 import javax.swing.*;
 import javax.swing.border.Border;
-import javax.swing.event.*;
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.peer.ComponentPeer;
 import java.awt.peer.LightweightPeer;
 import java.beans.*;
 import java.util.*;
-import javax.swing.plaf.ActionMapUIResource;
 import javax.swing.plaf.SplitPaneUI;
 import javax.swing.plaf.ComponentUI;
 import javax.swing.plaf.UIResource;
@@ -106,13 +104,13 @@
      * Keys to use for forward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set<KeyStroke> managingFocusForwardTraversalKeys;
+    private Set<KeyStroke> managingFocusForwardTraversalKeys;
 
     /**
      * Keys to use for backward focus traversal when the JComponent is
      * managing focus.
      */
-    private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
+    private Set<KeyStroke> managingFocusBackwardTraversalKeys;
 
 
     /**
@@ -675,7 +673,7 @@
      * @return increment via keyboard methods.
      */
     int getKeyboardMoveIncrement() {
-        return KEYBOARD_DIVIDER_MOVE_OFFSET;
+        return 3;
     }
 
     /**
--- a/src/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/basic/BasicToggleButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package javax.swing.plaf.basic;
 
+import sun.awt.AppContext;
+
 import java.awt.*;
 import java.awt.event.*;
 
@@ -43,7 +45,7 @@
  */
 public class BasicToggleButtonUI extends BasicButtonUI {
 
-    private final static BasicToggleButtonUI toggleButtonUI = new BasicToggleButtonUI();
+    private static final Object BASIC_TOGGLE_BUTTON_UI_KEY = new Object();
 
     private final static String propertyPrefix = "ToggleButton" + ".";
 
@@ -51,6 +53,13 @@
     //          Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent b) {
+        AppContext appContext = AppContext.getAppContext();
+        BasicToggleButtonUI toggleButtonUI =
+                (BasicToggleButtonUI) appContext.get(BASIC_TOGGLE_BUTTON_UI_KEY);
+        if (toggleButtonUI == null) {
+            toggleButtonUI = new BasicToggleButtonUI();
+            appContext.put(BASIC_TOGGLE_BUTTON_UI_KEY, toggleButtonUI);
+        }
         return toggleButtonUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalBumps.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalBumps.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1998-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
@@ -28,8 +28,9 @@
 import java.awt.*;
 import java.awt.image.*;
 import javax.swing.*;
-import java.io.*;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import sun.awt.AppContext;
 
 /**
  * Implements the bumps used throughout the Metal Look and Feel.
@@ -49,19 +50,9 @@
     protected Color shadowColor;
     protected Color backColor;
 
-    protected static Vector<BumpBuffer> buffers = new Vector<BumpBuffer>();
+    private static final Object METAL_BUMPS = new Object();
     protected BumpBuffer buffer;
 
-    public MetalBumps( Dimension bumpArea ) {
-        this( bumpArea.width, bumpArea.height );
-    }
-
-    public MetalBumps( int width, int height ) {
-        this(width, height, MetalLookAndFeel.getPrimaryControlHighlight(),
-             MetalLookAndFeel.getPrimaryControlDarkShadow(),
-             MetalLookAndFeel.getPrimaryControlShadow());
-    }
-
     /**
      * Creates MetalBumps of the specified size with the specified colors.
      * If <code>newBackColor</code> is null, the background will be
@@ -73,26 +64,22 @@
         setBumpColors( newTopColor, newShadowColor, newBackColor );
     }
 
-    private BumpBuffer getBuffer(GraphicsConfiguration gc, Color aTopColor,
-                                 Color aShadowColor, Color aBackColor) {
-        if (buffer != null && buffer.hasSameConfiguration(
-                              gc, aTopColor, aShadowColor, aBackColor)) {
-            return buffer;
+    private static BumpBuffer createBuffer(GraphicsConfiguration gc,
+                                           Color topColor, Color shadowColor, Color backColor) {
+        AppContext context = AppContext.getAppContext();
+        List<BumpBuffer> buffers = (List<BumpBuffer>) context.get(METAL_BUMPS);
+        if (buffers == null) {
+            buffers = new ArrayList<BumpBuffer>();
+            context.put(METAL_BUMPS, buffers);
         }
-        BumpBuffer result = null;
-
-        for (BumpBuffer aBuffer : buffers) {
-            if ( aBuffer.hasSameConfiguration(gc, aTopColor, aShadowColor,
-                                              aBackColor)) {
-                result = aBuffer;
-                break;
+        for (BumpBuffer buffer : buffers) {
+            if (buffer.hasSameConfiguration(gc, topColor, shadowColor, backColor)) {
+                return buffer;
             }
         }
-        if (result == null) {
-            result = new BumpBuffer(gc, topColor, shadowColor, backColor);
-            buffers.addElement(result);
-        }
-        return result;
+        BumpBuffer buffer = new BumpBuffer(gc, topColor, shadowColor, backColor);
+        buffers.add(buffer);
+        return buffer;
     }
 
     public void setBumpArea( Dimension bumpArea ) {
@@ -119,10 +106,12 @@
         GraphicsConfiguration gc = (g instanceof Graphics2D) ?
                 ((Graphics2D) g).getDeviceConfiguration() : null;
 
-        buffer = getBuffer(gc, topColor, shadowColor, backColor);
+        if ((buffer == null) || !buffer.hasSameConfiguration(gc, topColor, shadowColor, backColor)) {
+            buffer = createBuffer(gc, topColor, shadowColor, backColor);
+        }
 
-        int bufferWidth = buffer.getImageSize().width;
-        int bufferHeight = buffer.getImageSize().height;
+        int bufferWidth = BumpBuffer.IMAGE_SIZE;
+        int bufferHeight = BumpBuffer.IMAGE_SIZE;
         int iconWidth = getIconWidth();
         int iconHeight = getIconHeight();
         int x2 = x + iconWidth;
@@ -155,7 +144,6 @@
 class BumpBuffer {
 
     static final int IMAGE_SIZE = 64;
-    static Dimension imageSize = new Dimension( IMAGE_SIZE, IMAGE_SIZE );
 
     transient Image image;
     Color topColor;
@@ -197,10 +185,6 @@
         return image;
     }
 
-    public Dimension getImageSize() {
-        return imageSize;
-    }
-
     /**
      * Paints the bumps into the current image.
      */
--- a/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
 package javax.swing.plaf.metal;
 
 import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
+
 import javax.swing.*;
 import javax.swing.border.*;
 import javax.swing.plaf.basic.*;
@@ -49,19 +51,25 @@
  * @author Tom Santos
  */
 public class MetalButtonUI extends BasicButtonUI {
-
-    private final static MetalButtonUI metalButtonUI = new MetalButtonUI();
-
     // NOTE: These are not really needed, but at this point we can't pull
     // them. Their values are updated purely for historical reasons.
     protected Color focusColor;
     protected Color selectColor;
     protected Color disabledTextColor;
 
+    private static final Object METAL_BUTTON_UI_KEY = new Object();
+
     // ********************************
     //          Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        MetalButtonUI metalButtonUI =
+                (MetalButtonUI) appContext.get(METAL_BUTTON_UI_KEY);
+        if (metalButtonUI == null) {
+            metalButtonUI = new MetalButtonUI();
+            appContext.put(METAL_BUTTON_UI_KEY, metalButtonUI);
+        }
         return metalButtonUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalCheckBoxUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
 
 package javax.swing.plaf.metal;
 
+import sun.awt.AppContext;
+
 import javax.swing.*;
 import javax.swing.plaf.basic.BasicCheckBoxUI;
 
@@ -55,7 +57,7 @@
     // of BasicCheckBoxUI because we want to pick up all the
     // painting changes made in MetalRadioButtonUI.
 
-    private final static MetalCheckBoxUI checkboxUI = new MetalCheckBoxUI();
+    private static final Object METAL_CHECK_BOX_UI_KEY = new Object();
 
     private final static String propertyPrefix = "CheckBox" + ".";
 
@@ -65,6 +67,13 @@
     //         Create PlAF
     // ********************************
     public static ComponentUI createUI(JComponent b) {
+        AppContext appContext = AppContext.getAppContext();
+        MetalCheckBoxUI checkboxUI =
+                (MetalCheckBoxUI) appContext.get(METAL_CHECK_BOX_UI_KEY);
+        if (checkboxUI == null) {
+            checkboxUI = new MetalCheckBoxUI();
+            appContext.put(METAL_CHECK_BOX_UI_KEY, checkboxUI);
+        }
         return checkboxUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalInternalFrameUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1998-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
@@ -31,10 +31,8 @@
 import javax.swing.event.*;
 import javax.swing.border.*;
 import javax.swing.plaf.basic.*;
-import java.util.EventListener;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeEvent;
-import java.beans.PropertyVetoException;
 import javax.swing.plaf.*;
 
 /**
@@ -51,7 +49,7 @@
   private static final Border handyEmptyBorder = new EmptyBorder(0,0,0,0);
 
   protected static String IS_PALETTE   = "JInternalFrame.isPalette";
-
+  private static String IS_PALETTE_KEY = "JInternalFrame.isPalette";
   private static String FRAME_TYPE     = "JInternalFrame.frameType";
   private static String NORMAL_FRAME   = "normal";
   private static String PALETTE_FRAME  = "palette";
@@ -68,7 +66,7 @@
   public void installUI(JComponent c) {
     super.installUI(c);
 
-    Object paletteProp = c.getClientProperty( IS_PALETTE );
+    Object paletteProp = c.getClientProperty(IS_PALETTE_KEY);
     if ( paletteProp != null ) {
         setPalette( ((Boolean)paletteProp).booleanValue() );
     }
@@ -187,7 +185,7 @@
                   ui.setFrameType( (String) e.getNewValue() );
               }
           }
-          else if ( name.equals( IS_PALETTE ) )
+          else if ( name.equals(IS_PALETTE_KEY) )
           {
               if ( e.getNewValue() != null )
               {
--- a/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalLabelUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
 package javax.swing.plaf.metal;
 
 import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
+
 import javax.swing.*;
 import javax.swing.plaf.*;
 import javax.swing.plaf.basic.*;
@@ -51,15 +53,21 @@
     * name in defaults table under the key "LabelUI".
     */
     protected static MetalLabelUI metalLabelUI = new MetalLabelUI();
-    private final static MetalLabelUI SAFE_METAL_LABEL_UI = new MetalLabelUI();
 
+    private static final Object METAL_LABEL_UI_KEY = new Object();
 
     public static ComponentUI createUI(JComponent c) {
         if (System.getSecurityManager() != null) {
-            return SAFE_METAL_LABEL_UI;
-        } else {
-            return metalLabelUI;
+            AppContext appContext = AppContext.getAppContext();
+            MetalLabelUI safeMetalLabelUI =
+                    (MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY);
+            if (safeMetalLabelUI == null) {
+                safeMetalLabelUI = new MetalLabelUI();
+                appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI);
+            }
+            return safeMetalLabelUI;
         }
+        return metalLabelUI;
     }
 
     /**
--- a/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalRadioButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
 package javax.swing.plaf.metal;
 
 import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
+
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
@@ -53,7 +55,7 @@
  */
 public class MetalRadioButtonUI extends BasicRadioButtonUI {
 
-    private static final MetalRadioButtonUI metalRadioButtonUI = new MetalRadioButtonUI();
+    private static final Object METAL_RADIO_BUTTON_UI_KEY = new Object();
 
     protected Color focusColor;
     protected Color selectColor;
@@ -65,6 +67,13 @@
     //        Create PlAF
     // ********************************
     public static ComponentUI createUI(JComponent c) {
+        AppContext appContext = AppContext.getAppContext();
+        MetalRadioButtonUI metalRadioButtonUI =
+                (MetalRadioButtonUI) appContext.get(METAL_RADIO_BUTTON_UI_KEY);
+        if (metalRadioButtonUI == null) {
+            metalRadioButtonUI = new MetalRadioButtonUI();
+            appContext.put(METAL_RADIO_BUTTON_UI_KEY, metalRadioButtonUI);
+        }
         return metalRadioButtonUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalSliderUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1998-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1998-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
@@ -54,12 +54,13 @@
 
     protected final int TICK_BUFFER = 4;
     protected boolean filledSlider = false;
-    // NOTE: these next three variables are currently unused.
+    // NOTE: these next five variables are currently unused.
     protected static Color thumbColor;
     protected static Color highlightColor;
     protected static Color darkShadowColor;
     protected static int trackWidth;
     protected static int tickLength;
+    private int safeLength;
 
    /**
     * A default horizontal thumb <code>Icon</code>. This field might not be
@@ -107,7 +108,7 @@
 
     public void installUI( JComponent c ) {
         trackWidth = ((Integer)UIManager.get( "Slider.trackWidth" )).intValue();
-        tickLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue();
+        tickLength = safeLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue();
         horizThumbIcon = SAFE_HORIZ_THUMB_ICON =
                 UIManager.getIcon( "Slider.horizontalThumbIcon" );
         vertThumbIcon = SAFE_VERT_THUMB_ICON =
@@ -477,8 +478,8 @@
      * determine the tick area rectangle.
      */
     public int getTickLength() {
-        return slider.getOrientation() == JSlider.HORIZONTAL ? tickLength + TICK_BUFFER + 1 :
-        tickLength + TICK_BUFFER + 3;
+        return slider.getOrientation() == JSlider.HORIZONTAL ? safeLength + TICK_BUFFER + 1 :
+        safeLength + TICK_BUFFER + 3;
     }
 
     /**
@@ -523,22 +524,22 @@
 
     protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
         g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
-        g.drawLine( x, TICK_BUFFER, x, TICK_BUFFER + (tickLength / 2) );
+        g.drawLine( x, TICK_BUFFER, x, TICK_BUFFER + (safeLength / 2) );
     }
 
     protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
         g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
-        g.drawLine( x, TICK_BUFFER , x, TICK_BUFFER + (tickLength - 1) );
+        g.drawLine( x, TICK_BUFFER , x, TICK_BUFFER + (safeLength - 1) );
     }
 
     protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
         g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
 
         if (MetalUtils.isLeftToRight(slider)) {
-            g.drawLine( TICK_BUFFER, y, TICK_BUFFER + (tickLength / 2), y );
+            g.drawLine( TICK_BUFFER, y, TICK_BUFFER + (safeLength / 2), y );
         }
         else {
-            g.drawLine( 0, y, tickLength/2, y );
+            g.drawLine( 0, y, safeLength/2, y );
         }
     }
 
@@ -546,10 +547,10 @@
         g.setColor( slider.isEnabled() ? slider.getForeground() : MetalLookAndFeel.getControlShadow() );
 
         if (MetalUtils.isLeftToRight(slider)) {
-            g.drawLine( TICK_BUFFER, y, TICK_BUFFER + tickLength, y );
+            g.drawLine( TICK_BUFFER, y, TICK_BUFFER + safeLength, y );
         }
         else {
-            g.drawLine( 0, y, tickLength, y );
+            g.drawLine( 0, y, safeLength, y );
         }
     }
 }
--- a/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/MetalToggleButtonUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
 package javax.swing.plaf.metal;
 
 import sun.swing.SwingUtilities2;
+import sun.awt.AppContext;
+
 import java.awt.*;
 import java.awt.event.*;
 import java.lang.ref.*;
@@ -55,7 +57,7 @@
  */
 public class MetalToggleButtonUI extends BasicToggleButtonUI {
 
-    private static final MetalToggleButtonUI metalToggleButtonUI = new MetalToggleButtonUI();
+    private static final Object METAL_TOGGLE_BUTTON_UI_KEY = new Object();
 
     protected Color focusColor;
     protected Color selectColor;
@@ -67,6 +69,13 @@
     //        Create PLAF
     // ********************************
     public static ComponentUI createUI(JComponent b) {
+        AppContext appContext = AppContext.getAppContext();
+        MetalToggleButtonUI metalToggleButtonUI =
+                (MetalToggleButtonUI) appContext.get(METAL_TOGGLE_BUTTON_UI_KEY);
+        if (metalToggleButtonUI == null) {
+            metalToggleButtonUI = new MetalToggleButtonUI();
+            appContext.put(METAL_TOGGLE_BUTTON_UI_KEY, metalToggleButtonUI);
+        }
         return metalToggleButtonUI;
     }
 
--- a/src/share/classes/javax/swing/plaf/metal/OceanTheme.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/metal/OceanTheme.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,6 +32,7 @@
 import javax.swing.plaf.*;
 import sun.swing.SwingUtilities2;
 import sun.swing.PrintColorUIResource;
+import sun.swing.SwingLazyValue;
 
 /**
  * The default theme for the {@code MetalLookAndFeel}.
@@ -128,7 +129,7 @@
      * @throws NullPointerException if {@code table} is {@code null}
      */
     public void addCustomEntriesToTable(UIDefaults table) {
-        Object focusBorder = new UIDefaults.ProxyLazyValue(
+        Object focusBorder = new SwingLazyValue(
                       "javax.swing.plaf.BorderUIResource$LineBorderUIResource",
                       new Object[] {getPrimary1()});
         // .30 0 DDE8F3 white secondary2
--- a/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/plaf/synth/SynthTableUI.java	Wed Nov 25 11:08:25 2009 -0800
@@ -638,7 +638,7 @@
             if ((b == null || b instanceof UIResource
                     || component instanceof SynthBooleanTableCellRenderer)
                     && !table.isCellSelected(row, column)) {
-                if (alternateColor != null && row % 2 == 0) {
+                if (alternateColor != null && row % 2 != 0) {
                     component.setBackground(alternateColor);
                 }
             }
--- a/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/table/DefaultTableCellRenderer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -214,8 +214,9 @@
                                     : table.getBackground();
             if (background == null || background instanceof javax.swing.plaf.UIResource) {
                 Color alternateColor = DefaultLookup.getColor(this, ui, "Table.alternateRowColor");
-                if (alternateColor != null && row % 2 == 0)
+                if (alternateColor != null && row % 2 != 0) {
                     background = alternateColor;
+                }
             }
             super.setForeground(unselectedForeground != null
                                     ? unselectedForeground
--- a/src/share/classes/javax/swing/text/JTextComponent.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/javax/swing/text/JTextComponent.java	Wed Nov 25 11:08:25 2009 -0800
@@ -2069,7 +2069,7 @@
      *   width to match its own
      */
     public boolean getScrollableTracksViewportWidth() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             return port.getWidth() > getPreferredSize().width;
         }
@@ -2090,7 +2090,7 @@
      *   to match its own
      */
     public boolean getScrollableTracksViewportHeight() {
-        JViewport port = SwingUtilities2.getViewport(this);
+        JViewport port = SwingUtilities.getParentViewport(this);
         if (port != null) {
             return (port.getHeight() > getPreferredSize().height);
         }
--- a/src/share/classes/sun/applet/AppletClassLoader.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/applet/AppletClassLoader.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1995-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1995-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -51,6 +51,7 @@
 import java.security.PermissionCollection;
 import sun.awt.AppContext;
 import sun.awt.SunToolkit;
+import sun.misc.IOUtils;
 import sun.net.www.ParseUtil;
 import sun.security.util.SecurityConstants;
 
@@ -331,36 +332,7 @@
 
         byte[] b;
         try {
-            if (len != -1) {
-                // Read exactly len bytes from the input stream
-                b = new byte[len];
-                while (len > 0) {
-                    int n = in.read(b, b.length - len, len);
-                    if (n == -1) {
-                        throw new IOException("unexpected EOF");
-                    }
-                    len -= n;
-                }
-            } else {
-                // Read until end of stream is reached - use 8K buffer
-                // to speed up performance [stanleyh]
-                b = new byte[8192];
-                int total = 0;
-                while ((len = in.read(b, total, b.length - total)) != -1) {
-                    total += len;
-                    if (total >= b.length) {
-                        byte[] tmp = new byte[total * 2];
-                        System.arraycopy(b, 0, tmp, 0, total);
-                        b = tmp;
-                    }
-                }
-                // Trim array to correct size, if necessary
-                if (total != b.length) {
-                    byte[] tmp = new byte[total];
-                    System.arraycopy(b, 0, tmp, 0, total);
-                    b = tmp;
-                }
-            }
+            b = IOUtils.readFully(in, len, true);
         } finally {
             in.close();
         }
--- a/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/awt/datatransfer/DataTransferer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -63,8 +63,6 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 
-import java.rmi.MarshalledObject;
-
 import java.security.AccessControlContext;
 import java.security.AccessControlException;
 import java.security.AccessController;
@@ -494,6 +492,13 @@
     }
 
     /**
+     * Returns {@code true} if the given type is a java.rmi.Remote.
+     */
+    public static boolean isRemote(Class<?> type) {
+        return RMI.isRemote(type);
+    }
+
+    /**
      * Returns an Iterator which traverses a SortedSet of Strings which are
      * a total order of the standard character sets supported by the JRE. The
      * ordering follows the same principles as DataFlavor.selectBestTextFlavor.
@@ -1360,7 +1365,7 @@
 
         // Source data is an RMI object
         } else if (flavor.isRepresentationClassRemote()) {
-            MarshalledObject mo = new MarshalledObject(obj);
+            Object mo = RMI.newMarshalledObject(obj);
             ObjectOutputStream oos = new ObjectOutputStream(bos);
             oos.writeObject(mo);
             oos.close();
@@ -1671,7 +1676,7 @@
             try {
                 byte[] ba = inputStreamToByteArray(str);
                 ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(ba));
-                Object ret = ((MarshalledObject)(ois.readObject())).get();
+                Object ret = RMI.getMarshalledObject(ois.readObject());
                 ois.close();
                 str.close();
                 return ret;
@@ -2669,8 +2674,12 @@
                                               Integer.valueOf(0));
                 nonTextRepresentationsMap.put(java.io.Serializable.class,
                                               Integer.valueOf(1));
-                nonTextRepresentationsMap.put(java.rmi.Remote.class,
-                                              Integer.valueOf(2));
+
+                Class<?> remoteClass = RMI.remoteClass();
+                if (remoteClass != null) {
+                    nonTextRepresentationsMap.put(remoteClass,
+                                                  Integer.valueOf(2));
+                }
 
                 nonTextRepresentations =
                     Collections.unmodifiableMap(nonTextRepresentationsMap);
@@ -2900,4 +2909,95 @@
             }
         }
     }
+
+    /**
+     * A class that provides access to java.rmi.Remote and java.rmi.MarshalledObject
+     * without creating a static dependency.
+     */
+    private static class RMI {
+        private static final Class<?> remoteClass = getClass("java.rmi.Remote");
+        private static final Class<?> marshallObjectClass =
+            getClass("java.rmi.MarshalledObject");
+        private static final Constructor<?> marshallCtor =
+            getConstructor(marshallObjectClass, Object.class);
+        private static final Method marshallGet =
+            getMethod(marshallObjectClass, "get");
+
+        private static Class<?> getClass(String name) {
+            try {
+                return Class.forName(name, true, null);
+            } catch (ClassNotFoundException e) {
+                return null;
+            }
+        }
+
+        private static Constructor<?> getConstructor(Class<?> c, Class<?>... types) {
+            try {
+                return (c == null) ? null : c.getDeclaredConstructor(types);
+            } catch (NoSuchMethodException x) {
+                throw new AssertionError(x);
+            }
+        }
+
+        private static Method getMethod(Class<?> c, String name, Class<?>... types) {
+            try {
+                return (c == null) ? null : c.getMethod(name, types);
+            } catch (NoSuchMethodException e) {
+                throw new AssertionError(e);
+            }
+        }
+
+        /**
+         * Returns {@code true} if the given class is java.rmi.Remote.
+         */
+        static boolean isRemote(Class<?> c) {
+            return (remoteClass == null) ? null : remoteClass.isAssignableFrom(c);
+        }
+
+        /**
+         * Returns java.rmi.Remote.class if RMI is present; otherwise {@code null}.
+         */
+        static Class<?> remoteClass() {
+            return remoteClass;
+        }
+
+        /**
+         * Returns a new MarshalledObject containing the serialized representation
+         * of the given object.
+         */
+        static Object newMarshalledObject(Object obj) throws IOException {
+            try {
+                return marshallCtor.newInstance(obj);
+            } catch (InstantiationException x) {
+                throw new AssertionError(x);
+            } catch (IllegalAccessException x) {
+                throw new AssertionError(x);
+            } catch (InvocationTargetException  x) {
+                Throwable cause = x.getCause();
+                if (cause instanceof IOException)
+                    throw (IOException)cause;
+                throw new AssertionError(x);
+            }
+        }
+
+        /**
+         * Returns a new copy of the contained marshalled object.
+         */
+        static Object getMarshalledObject(Object obj)
+            throws IOException, ClassNotFoundException
+        {
+            try {
+                return marshallGet.invoke(obj);
+            } catch (IllegalAccessException x) {
+                throw new AssertionError(x);
+            } catch (InvocationTargetException x) {
+                Throwable cause = x.getCause();
+                if (cause instanceof IOException)
+                    throw (IOException)cause;
+                if (cause instanceof ClassNotFoundException)
+                    throw (ClassNotFoundException)cause;
+                throw new AssertionError(x);
+            }
+        }
+    }
 }
--- a/src/share/classes/sun/awt/im/InputMethodManager.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/awt/im/InputMethodManager.java	Wed Nov 25 11:08:25 2009 -0800
@@ -358,7 +358,9 @@
         AppContext requesterAppContext = SunToolkit.targetToAppContext(requester);
         synchronized (lock) {
             SunToolkit.postEvent(requesterAppContext, event);
-            lock.wait();
+            while (!event.isDispatched()) {
+                lock.wait();
+            }
         }
 
         Throwable eventThrowable = event.getThrowable();
--- a/src/share/classes/sun/awt/image/ImageRepresentation.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/awt/image/ImageRepresentation.java	Wed Nov 25 11:08:25 2009 -0800
@@ -336,10 +336,6 @@
     public native void setICMpixels(int x, int y, int w, int h, int[] lut,
                                     byte[] pix, int off, int scansize,
                                     IntegerComponentRaster ict);
-
-    public native void setBytePixels(int x, int y, int w, int h, byte[] pix,
-                                     int off, int scansize,
-                                     ByteComponentRaster bct, int chanOff);
     public native int setDiffICM(int x, int y, int w, int h, int[] lut,
                                  int transPix, int numLut, IndexColorModel icm,
                                  byte[] pix, int off, int scansize,
@@ -450,27 +446,17 @@
                      (biRaster instanceof ByteComponentRaster) &&
                      (biRaster.getNumDataElements() == 1)){
                 ByteComponentRaster bt = (ByteComponentRaster) biRaster;
-                if (w*h > 200) {
-                    if (off == 0 && scansize == w) {
-                        bt.putByteData(x, y, w, h, pix);
-                    }
-                    else {
-                        byte[] bpix = new byte[w];
-                        poff = off;
-                        for (int yoff=y; yoff < y+h; yoff++) {
-                            System.arraycopy(pix, poff, bpix, 0, w);
-                            bt.putByteData(x, yoff, w, 1, bpix);
-                            poff += scansize;
-                        }
-                    }
+                if (off == 0 && scansize == w) {
+                    bt.putByteData(x, y, w, h, pix);
                 }
                 else {
-                    // Only is faster if #pixels
-                    // Note that setBytePixels modifies the raster directly
-                    // so we must mark it as changed afterwards
-                    setBytePixels(x, y, w, h, pix, off, scansize, bt,
-                                  bt.getDataOffset(0));
-                    bt.markDirty();
+                    byte[] bpix = new byte[w];
+                    poff = off;
+                    for (int yoff=y; yoff < y+h; yoff++) {
+                        System.arraycopy(pix, poff, bpix, 0, w);
+                        bt.putByteData(x, yoff, w, 1, bpix);
+                        poff += scansize;
+                    }
                 }
             }
             else {
--- a/src/share/classes/sun/awt/shell/ShellFolder.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/awt/shell/ShellFolder.java	Wed Nov 25 11:08:25 2009 -0800
@@ -201,6 +201,8 @@
 
     private static ShellFolderManager shellFolderManager;
 
+    private static Invoker invoker;
+
     static {
         String managerClassName = (String)Toolkit.getDefaultToolkit().
                                       getDesktopProperty("Shell.shellFolderManager");
@@ -225,6 +227,8 @@
             throw new Error ("Could not access Shell Folder Manager: "
             + managerClass.getName());
         }
+
+        invoker = shellFolderManager.createInvoker();
     }
 
     /**
@@ -486,21 +490,6 @@
         return null;
     }
 
-    private static Invoker invoker;
-
-    /**
-     * Provides the single access point to the {@link Invoker}. It is guaranteed that the value
-     * returned by this method will be always the same.
-     *
-     * @return the singleton instance of {@link Invoker}
-     */
-    public static Invoker getInvoker() {
-        if (invoker == null) {
-            invoker = shellFolderManager.createInvoker();
-        }
-        return invoker;
-    }
-
     /**
      * Invokes the {@code task} which doesn't throw checked exceptions
      * from its {@code call} method. If invokation is interrupted then Thread.currentThread().isInterrupted() will
@@ -522,7 +511,7 @@
     public static <T, E extends Throwable> T invoke(Callable<T> task, Class<E> exceptionClass)
             throws InterruptedException, E {
         try {
-            return getInvoker().invoke(task);
+            return invoker.invoke(task);
         } catch (Exception e) {
             if (e instanceof RuntimeException) {
                 // Rethrow unchecked exceptions
--- a/src/share/classes/sun/dyn/anon/AnonymousClassLoader.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/dyn/anon/AnonymousClassLoader.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,9 +26,9 @@
 package sun.dyn.anon;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import sun.misc.IOUtils;
 
 /**
  * Anonymous class loader.  Will load any valid classfile, producing
@@ -285,13 +285,6 @@
         if (contentLength < 0)
             throw new IOException("invalid content length "+contentLength);
 
-        byte[] classFile = new byte[contentLength];
-        InputStream tcs = connection.getInputStream();
-        for (int fill = 0, nr; fill < classFile.length; fill += nr) {
-            nr = tcs.read(classFile, fill, classFile.length - fill);
-            if (nr < 0)
-                throw new IOException("premature end of file");
-        }
-        return classFile;
+        return IOUtils.readFully(connection.getInputStream(), contentLength, true);
     }
 }
--- a/src/share/classes/sun/font/Font2D.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/font/Font2D.java	Wed Nov 25 11:08:25 2009 -0800
@@ -320,21 +320,6 @@
                     lastFontStrike = new SoftReference(strike);
                     StrikeCache.refStrike(strike);
                     return strike;
-                } else {
-                    /* We have found a cleared reference that has not yet
-                     * been removed by the disposer.
-                     * If we make this reference unreachable by removing it
-                     * from the map,or overwriting it with a new reference to
-                     * a new strike, then it is possible it may never be
-                     * enqueued for disposal. That is the implication of
-                     * the docs for java.lang.ref. So on finding a cleared
-                     * reference, we need to dispose the native resources,
-                     * if they haven't already been freed.
-                     * The reference object needs to have a reference to
-                     * the disposer instance for this to occur.
-                     */
-                  ((StrikeCache.DisposableStrike)strikeRef)
-                      .getDisposer().dispose();
                 }
             }
             /* When we create a new FontStrike instance, we *must*
--- a/src/share/classes/sun/font/FontDesignMetrics.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/font/FontDesignMetrics.java	Wed Nov 25 11:08:25 2009 -0800
@@ -171,7 +171,7 @@
      * out we can clear the keys from the table.
      */
     private static class KeyReference extends SoftReference
-        implements DisposerRecord {
+        implements DisposerRecord, Disposer.PollDisposable {
 
         static ReferenceQueue queue = Disposer.getQueue();
 
--- a/src/share/classes/sun/font/FontStrikeDisposer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/font/FontStrikeDisposer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,7 @@
 
 package sun.font;
 
+import sun.java2d.Disposer;
 import sun.java2d.DisposerRecord;
 
 /*
@@ -49,7 +50,8 @@
  * entries would be removed much more promptly than we need.
  */
 
-class FontStrikeDisposer implements DisposerRecord {
+class FontStrikeDisposer
+    implements DisposerRecord, Disposer.PollDisposable {
 
     Font2D font2D;
     FontStrikeDesc desc;
--- a/src/share/classes/sun/font/StrikeCache.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/font/StrikeCache.java	Wed Nov 25 11:08:25 2009 -0800
@@ -254,9 +254,20 @@
         // because they may be accessed on that thread at the time of the
         // disposal (for example, when the accel. cache is invalidated)
 
-        // REMIND: this look a bit heavyweight, but should be ok
-        // because strike disposal is a relatively infrequent operation,
-        // more worrisome is the necessity of getting a GC here.
+        // Whilst this is a bit heavyweight, in most applications
+        // strike disposal is a relatively infrequent operation, so it
+        // doesn't matter. But in some tests that use vast numbers
+        // of strikes, the switching back and forth is measurable.
+        // So the "pollRemove" call is added to batch up the work.
+        // If we are polling we know we've already been called back
+        // and can directly dispose the record.
+        // Also worrisome is the necessity of getting a GC here.
+
+        if (Disposer.pollingQueue) {
+            doDispose(disposer);
+            return;
+        }
+
         RenderQueue rq = null;
         GraphicsEnvironment ge =
             GraphicsEnvironment.getLocalGraphicsEnvironment();
@@ -277,6 +288,7 @@
                 rq.flushAndInvokeNow(new Runnable() {
                     public void run() {
                         doDispose(disposer);
+                        Disposer.pollRemove();
                     }
                 });
             } finally {
--- a/src/share/classes/sun/java2d/Disposer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/Disposer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -29,6 +29,7 @@
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.PhantomReference;
 import java.lang.ref.WeakReference;
+import java.util.ArrayList;
 import java.util.Hashtable;
 
 /**
@@ -146,6 +147,7 @@
                 rec.dispose();
                 obj = null;
                 rec = null;
+                clearDeferredRecords();
             } catch (Exception e) {
                 System.out.println("Exception while removing reference: " + e);
                 e.printStackTrace();
@@ -153,6 +155,85 @@
         }
     }
 
+    /*
+     * This is a marker interface that, if implemented, means it
+     * doesn't acquire any special locks, and is safe to
+     * be disposed in the poll loop on whatever thread
+     * which happens to be the Toolkit thread, is in use.
+     */
+    public static interface PollDisposable {
+    };
+
+    private static ArrayList<DisposerRecord> deferredRecords = null;
+
+    private static void clearDeferredRecords() {
+        if (deferredRecords == null || deferredRecords.isEmpty()) {
+            return;
+        }
+        for (int i=0;i<deferredRecords.size(); i++) {
+            try {
+                DisposerRecord rec = deferredRecords.get(i);
+                rec.dispose();
+            } catch (Exception e) {
+                System.out.println("Exception while disposing deferred rec.");
+                e.printStackTrace();
+            }
+        }
+        deferredRecords.clear();
+    }
+
+    /*
+     * Set to indicate the queue is presently being polled.
+     */
+    public static volatile boolean pollingQueue = false;
+
+    /*
+     * The pollRemove() method is called back from a dispose method
+     * that is running on the toolkit thread and wants to
+     * dispose any pending refs that are safe to be disposed
+     * on that thread.
+     */
+    public static void pollRemove() {
+
+        /* This should never be called recursively, so this check
+         * is just a safeguard against the unexpected.
+         */
+        if (pollingQueue) {
+            return;
+        }
+        Object obj;
+        pollingQueue = true;
+        int freed = 0;
+        int deferred = 0;
+        try {
+            while ((obj = queue.poll()) != null
+                   && freed < 10000 && deferred < 100) {
+                freed++;
+                ((Reference)obj).clear();
+                DisposerRecord rec = (DisposerRecord)records.remove(obj);
+                if (rec instanceof PollDisposable) {
+                    rec.dispose();
+                    obj = null;
+                    rec = null;
+                } else {
+                    if (rec == null) { // shouldn't happen, but just in case.
+                        continue;
+                    }
+                    deferred++;
+                    if (deferredRecords == null) {
+                      deferredRecords = new ArrayList<DisposerRecord>(5);
+                    }
+                    deferredRecords.add(rec);
+                }
+            }
+        } catch (Exception e) {
+            System.out.println("Exception while removing reference: " + e);
+            e.printStackTrace();
+        } finally {
+            pollingQueue = false;
+        }
+    }
+
     private static native void initIDs();
 
     /*
--- a/src/share/classes/sun/java2d/SunGraphics2D.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/SunGraphics2D.java	Wed Nov 25 11:08:25 2009 -0800
@@ -257,7 +257,6 @@
             font = defaultFont;
         }
 
-        loops = sd.getRenderLoops(this);
         setDevClip(sd.getBounds());
         invalidatePipe();
     }
@@ -367,6 +366,7 @@
         shapepipe = invalidpipe;
         textpipe = invalidpipe;
         imagepipe = invalidpipe;
+        loops = null;
     }
 
     public void validatePipe() {
--- a/src/share/classes/sun/java2d/SurfaceData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/SurfaceData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -69,6 +69,7 @@
 import sun.java2d.pipe.DrawImage;
 import sun.awt.SunHints;
 import sun.awt.image.SurfaceManager;
+import sun.java2d.pipe.LoopBasedPipe;
 
 /**
  * This class provides various pieces of information relevant to a
@@ -506,7 +507,6 @@
                     sg2d.textpipe = solidTextRenderer;
                 }
                 sg2d.shapepipe = colorPrimitives;
-                sg2d.loops = getRenderLoops(sg2d);
                 // assert(sg2d.surfaceData == this);
             }
         } else if (sg2d.compositeState == sg2d.COMP_CUSTOM) {
@@ -603,8 +603,17 @@
 
             sg2d.textpipe = getTextPipe(sg2d, false /* AA==OFF */);
             sg2d.shapepipe = colorPrimitives;
+            // assert(sg2d.surfaceData == this);
+        }
+
+        // check for loops
+        if (sg2d.textpipe  instanceof LoopBasedPipe ||
+            sg2d.shapepipe instanceof LoopBasedPipe ||
+            sg2d.fillpipe  instanceof LoopBasedPipe ||
+            sg2d.drawpipe  instanceof LoopBasedPipe ||
+            sg2d.imagepipe instanceof LoopBasedPipe)
+        {
             sg2d.loops = getRenderLoops(sg2d);
-            // assert(sg2d.surfaceData == this);
         }
     }
 
--- a/src/share/classes/sun/java2d/pipe/AATextRenderer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/pipe/AATextRenderer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -34,8 +34,9 @@
  * a solid source colour to an opaque destination.
  */
 
-public class AATextRenderer extends GlyphListLoopPipe {
-
+public class AATextRenderer extends GlyphListLoopPipe
+    implements LoopBasedPipe
+{
    protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
        sg2d.loops.drawGlyphListAALoop.DrawGlyphListAA(sg2d, sg2d.surfaceData,
                                                       gl);
--- a/src/share/classes/sun/java2d/pipe/GlyphListLoopPipe.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/pipe/GlyphListLoopPipe.java	Wed Nov 25 11:08:25 2009 -0800
@@ -36,8 +36,9 @@
  * the installed loop may not match the glyphvector.
  */
 
-public abstract class GlyphListLoopPipe extends GlyphListPipe {
-
+public abstract class GlyphListLoopPipe extends GlyphListPipe
+    implements LoopBasedPipe
+{
     protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl,
                                  int aaHint) {
         switch (aaHint) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/java2d/pipe/LoopBasedPipe.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,37 @@
+/*
+ * 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 sun.java2d.pipe;
+
+/**
+ * This is a marker interface used by Pipes that need RenderLoops.
+ * RenderLoops are validated in SurfaceData when a pipe is recognised to
+ * implement this interface.
+ *
+ * @author Mario Torre <neugens@aicas.com>
+ */
+public interface LoopBasedPipe {
+
+}
--- a/src/share/classes/sun/java2d/pipe/LoopPipe.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/pipe/LoopPipe.java	Wed Nov 25 11:08:25 2009 -0800
@@ -46,7 +46,8 @@
 public class LoopPipe
     implements PixelDrawPipe,
                PixelFillPipe,
-               ShapeDrawPipe
+               ShapeDrawPipe,
+               LoopBasedPipe
 {
     final static RenderingEngine RenderEngine = RenderingEngine.getInstance();
 
--- a/src/share/classes/sun/java2d/pipe/SolidTextRenderer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/pipe/SolidTextRenderer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -35,8 +35,9 @@
  * a solid source colour to an opaque destination.
  */
 
-public class SolidTextRenderer extends GlyphListLoopPipe {
-
+public class SolidTextRenderer extends GlyphListLoopPipe
+    implements LoopBasedPipe
+{
     protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
         sg2d.loops.drawGlyphListLoop.DrawGlyphList(sg2d, sg2d.surfaceData, gl);
     }
--- a/src/share/classes/sun/java2d/pipe/SpanShapeRenderer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/pipe/SpanShapeRenderer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -65,7 +65,9 @@
         }
     }
 
-    public static class Simple extends SpanShapeRenderer {
+    public static class Simple extends SpanShapeRenderer
+        implements  LoopBasedPipe
+    {
         public Object startSequence(SunGraphics2D sg, Shape s,
                                     Rectangle devR, int[] bbox) {
             return sg;
--- a/src/share/classes/sun/java2d/pisces/Renderer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/java2d/pisces/Renderer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -775,10 +775,12 @@
 
     // Free sorting arrays if larger than maximum size
     private void crossingListFinished() {
-        if (crossings.length > DEFAULT_CROSSINGS_SIZE) {
+        if (crossings != null && crossings.length > DEFAULT_CROSSINGS_SIZE) {
             crossings = new int[DEFAULT_CROSSINGS_SIZE];
         }
-        if (crossingIndices.length > DEFAULT_INDICES_SIZE) {
+        if (crossingIndices != null &&
+            crossingIndices.length > DEFAULT_INDICES_SIZE)
+        {
             crossingIndices = new int[DEFAULT_INDICES_SIZE];
         }
     }
--- a/src/share/classes/sun/management/AgentConfigurationError.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/AgentConfigurationError.java	Wed Nov 25 11:08:25 2009 -0800
@@ -146,4 +146,6 @@
     public String[] getParams() {
         return params;
     }
+
+    private static final long serialVersionUID = 1211605593516195475L;
 }
--- a/src/share/classes/sun/management/ClassLoadingImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/ClassLoadingImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -71,6 +71,6 @@
     native static void setVerboseClass(boolean value);
 
     public ObjectName getObjectName() {
-        return ObjectName.valueOf(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
+        return Util.newObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME);
     }
 }
--- a/src/share/classes/sun/management/CompilationImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/CompilationImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -70,7 +70,7 @@
     }
 
     public ObjectName getObjectName() {
-        return ObjectName.valueOf(ManagementFactory.COMPILATION_MXBEAN_NAME);
+        return Util.newObjectName(ManagementFactory.COMPILATION_MXBEAN_NAME);
     }
 
 
--- a/src/share/classes/sun/management/Flag.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/Flag.java	Wed Nov 25 11:08:25 2009 -0800
@@ -45,7 +45,7 @@
     Flag(String name, Object value, boolean writeable,
          boolean external, Origin origin) {
         this.name = name;
-        this.value = value;
+        this.value = value == null ? "" : value ;
         this.origin = origin;
         this.writeable = writeable;
         this.external = external;
@@ -64,8 +64,7 @@
     }
 
     VMOption getVMOption() {
-        String val = value == null ? "" : value.toString();
-        return new VMOption(name, val, writeable, origin);
+        return new VMOption(name, value.toString(), writeable, origin);
     }
 
     static Flag getFlag(String name) {
--- a/src/share/classes/sun/management/GcInfoCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/GcInfoCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -248,4 +248,5 @@
         return baseGcInfoCompositeType;
     }
 
+    private static final long serialVersionUID = -5716428894085882742L;
 }
--- a/src/share/classes/sun/management/HotSpotDiagnostic.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/HotSpotDiagnostic.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,9 +25,9 @@
 
 package sun.management;
 
-import java.util.*;
 import java.io.IOException;
-import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
 import javax.management.ObjectName;
 
 import com.sun.management.HotSpotDiagnosticMXBean;
@@ -117,6 +117,6 @@
     }
 
     public ObjectName getObjectName() {
-        return ObjectName.valueOf("com.sun.management:type=HotSpotDiagnostic");
+        return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
     }
 }
--- a/src/share/classes/sun/management/HotspotInternal.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/HotspotInternal.java	Wed Nov 25 11:08:25 2009 -0800
@@ -41,7 +41,7 @@
 
     private final static String HOTSPOT_INTERNAL_MBEAN_NAME =
         "sun.management:type=HotspotInternal";
-    private static ObjectName objName = ObjectName.valueOf(HOTSPOT_INTERNAL_MBEAN_NAME);
+    private static ObjectName objName = Util.newObjectName(HOTSPOT_INTERNAL_MBEAN_NAME);
     private MBeanServer server = null;
 
     /**
--- a/src/share/classes/sun/management/LazyCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/LazyCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -192,4 +192,6 @@
 
         return isTypeMatched(type1.getRowType(), type2.getRowType());
     }
+
+    private static final long serialVersionUID = -2190411934472666714L;
 }
--- a/src/share/classes/sun/management/ManagementFactoryHelper.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/ManagementFactoryHelper.java	Wed Nov 25 11:08:25 2009 -0800
@@ -40,7 +40,11 @@
 import java.security.PrivilegedExceptionAction;
 import sun.security.action.LoadLibraryAction;
 
+import java.util.logging.PlatformLoggingMXBean;
+import sun.util.logging.LoggingSupport;
+
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 import com.sun.management.OSMBeanFactory;
 import com.sun.management.HotSpotDiagnosticMXBean;
@@ -135,6 +139,54 @@
         return result;
     }
 
+    public static List<PlatformLoggingMXBean> getLoggingMXBean() {
+        if (LoggingSupport.isAvailable()) {
+            return Collections.singletonList(createPlatformLoggingMXBean());
+        } else {
+            return Collections.emptyList();
+        }
+    }
+
+    private final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging";
+    private static PlatformLoggingMXBean createPlatformLoggingMXBean() {
+        return new PlatformLoggingMXBean() {
+            private volatile ObjectName objname;  // created lazily
+            @Override
+            public ObjectName getObjectName() {
+                ObjectName result = objname;
+                if (result == null) {
+                    synchronized (this) {
+                        if (objname == null) {
+                            result = Util.newObjectName(LOGGING_MXBEAN_NAME);
+                            objname = result;
+                        }
+                    }
+                }
+                return result;
+            }
+
+            @Override
+            public java.util.List<String> getLoggerNames() {
+                return LoggingSupport.getLoggerNames();
+            }
+
+            @Override
+            public String getLoggerLevel(String loggerName) {
+                return LoggingSupport.getLoggerLevel(loggerName);
+            }
+
+            @Override
+            public void setLoggerLevel(String loggerName, String levelName) {
+                LoggingSupport.setLoggerLevel(loggerName, levelName);
+            }
+
+            @Override
+            public String getParentLoggerName(String loggerName) {
+                return LoggingSupport.getParentLoggerName(loggerName);
+            }
+        };
+    }
+
     public static List<BufferPoolMXBean> getBufferPoolMXBeans() {
         List<BufferPoolMXBean> pools = new ArrayList<BufferPoolMXBean>(2);
         pools.add(createBufferPoolMXBean(sun.misc.SharedSecrets.getJavaNioAccess()
@@ -160,7 +212,7 @@
                 if (result == null) {
                     synchronized (this) {
                         if (objname == null) {
-                            result = ObjectName.valueOf(BUFFER_POOL_MXBEAN_NAME +
+                            result = Util.newObjectName(BUFFER_POOL_MXBEAN_NAME +
                                 ",name=" + pool.getName());
                             objname = result;
                         }
@@ -257,7 +309,7 @@
      */
     private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) {
         try {
-            final ObjectName objName = ObjectName.valueOf(mbeanName);
+            final ObjectName objName = Util.newObjectName(mbeanName);
 
             // inner class requires these fields to be final
             final MBeanServer mbs0 = mbs;
@@ -317,7 +369,7 @@
 
     private static void unregisterMBean(MBeanServer mbs, String mbeanName) {
         try {
-            final ObjectName objName = ObjectName.valueOf(mbeanName);
+            final ObjectName objName = Util.newObjectName(mbeanName);
 
             // inner class requires these fields to be final
             final MBeanServer mbs0 = mbs;
--- a/src/share/classes/sun/management/MappedMXBeanType.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/MappedMXBeanType.java	Wed Nov 25 11:08:25 2009 -0800
@@ -777,6 +777,7 @@
         public boolean isValue(Object o) {
             return false;
         }
+        private static final long serialVersionUID = -3413063475064374490L;
     }
     private static final OpenType inProgress;
     static {
--- a/src/share/classes/sun/management/MemoryImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/MemoryImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -34,15 +34,7 @@
 import javax.management.ObjectName;
 import javax.management.MBeanNotificationInfo;
 import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ListenerNotFoundException;
 import javax.management.openmbean.CompositeData;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.ListIterator;
-import java.util.Collections;
 
 /**
  * Implementation class for the memory subsystem.
@@ -177,7 +169,7 @@
     }
 
     public ObjectName getObjectName() {
-        return ObjectName.valueOf(ManagementFactory.MEMORY_MXBEAN_NAME);
+        return Util.newObjectName(ManagementFactory.MEMORY_MXBEAN_NAME);
     }
 
 }
--- a/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/MemoryNotifInfoCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -127,4 +127,5 @@
         }
     }
 
+    private static final long serialVersionUID = -1805123446483771291L;
 }
--- a/src/share/classes/sun/management/MemoryUsageCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/MemoryUsageCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -126,4 +126,6 @@
                 "Unexpected composite type for MemoryUsage");
         }
     }
+
+    private static final long serialVersionUID = -8504291541083874143L;
 }
--- a/src/share/classes/sun/management/MonitorInfoCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/MonitorInfoCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -143,4 +143,6 @@
                 "Unexpected composite type for MonitorInfo");
         }
     }
+
+    private static final long serialVersionUID = -5825215591822908529L;
 }
--- a/src/share/classes/sun/management/OperatingSystemImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/OperatingSystemImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -74,7 +74,7 @@
         }
     }
     public ObjectName getObjectName() {
-        return ObjectName.valueOf(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
+        return Util.newObjectName(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);
     }
 
 }
--- a/src/share/classes/sun/management/RuntimeImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/RuntimeImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -33,12 +33,6 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.Properties;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.OpenDataException;
 import javax.management.ObjectName;
 
 /**
@@ -149,7 +143,7 @@
     }
 
     public ObjectName getObjectName() {
-        return ObjectName.valueOf(ManagementFactory.RUNTIME_MXBEAN_NAME);
+        return Util.newObjectName(ManagementFactory.RUNTIME_MXBEAN_NAME);
     }
 
 }
--- a/src/share/classes/sun/management/StackTraceElementCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/StackTraceElementCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -120,4 +120,6 @@
                 "Unexpected composite type for StackTraceElement");
         }
     }
+
+    private static final long serialVersionUID = -2704607706598396827L;
 }
--- a/src/share/classes/sun/management/ThreadImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/ThreadImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -29,10 +29,6 @@
 import java.lang.management.ManagementFactory;
 
 import java.lang.management.ThreadInfo;
-import java.lang.management.LockInfo;
-import java.lang.management.MonitorInfo;
-import java.util.Map;
-import java.util.HashMap;
 
 import javax.management.ObjectName;
 
@@ -415,7 +411,7 @@
     private static native void resetContentionTimes0(long tid);
 
     public ObjectName getObjectName() {
-        return ObjectName.valueOf(ManagementFactory.THREAD_MXBEAN_NAME);
+        return Util.newObjectName(ManagementFactory.THREAD_MXBEAN_NAME);
     }
 
 }
--- a/src/share/classes/sun/management/ThreadInfoCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/ThreadInfoCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -410,4 +410,6 @@
 
         }
     }
+
+    private static final long serialVersionUID = 2464378539119753175L;
 }
--- a/src/share/classes/sun/management/Util.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/Util.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,26 +25,34 @@
 
 package sun.management;
 
-import java.lang.management.*;
+import java.lang.management.ManagementPermission;
 import java.util.List;
-import java.security.Permission;
 import javax.management.ObjectName;
 import javax.management.MalformedObjectNameException;
 
-import static java.lang.management.ManagementFactory.*;
 
-class Util {
+public class Util {
+    private Util() {}  // there are no instances of this class
+
     static RuntimeException newException(Exception e) {
         throw new RuntimeException(e);
     }
 
     private static final String[] EMPTY_STRING_ARRAY = new String[0];
     static String[] toStringArray(List<String> list) {
-        return (String[]) list.toArray(EMPTY_STRING_ARRAY);
+        return list.toArray(EMPTY_STRING_ARRAY);
     }
 
     public static ObjectName newObjectName(String domainAndType, String name) {
-        return ObjectName.valueOf(domainAndType + ",name=" + name);
+        return newObjectName(domainAndType + ",name=" + name);
+    }
+
+    public static ObjectName newObjectName(String name) {
+        try {
+            return ObjectName.getInstance(name);
+        } catch (MalformedObjectNameException e) {
+            throw new IllegalArgumentException(e);
+        }
     }
 
     private static ManagementPermission monitorPermission =
--- a/src/share/classes/sun/management/VMOptionCompositeData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/VMOptionCompositeData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -128,4 +128,6 @@
                 "Unexpected composite type for VMOption");
         }
     }
+
+    private static final long serialVersionUID = -2395573975093578470L;
 }
--- a/src/share/classes/sun/management/counter/perf/ByteArrayCounterSnapshot.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/ByteArrayCounterSnapshot.java	Wed Nov 25 11:08:25 2009 -0800
@@ -53,4 +53,6 @@
     public byte byteAt(int index) {
         return value[index];
     }
+
+    private static final long serialVersionUID = 1444793459838438979L;
 }
--- a/src/share/classes/sun/management/counter/perf/InstrumentationException.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/InstrumentationException.java	Wed Nov 25 11:08:25 2009 -0800
@@ -42,4 +42,6 @@
      public InstrumentationException(String message) {
          super(message);
      }
+
+     private static final long serialVersionUID = 8060117844393922797L;
 }
--- a/src/share/classes/sun/management/counter/perf/LongArrayCounterSnapshot.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/LongArrayCounterSnapshot.java	Wed Nov 25 11:08:25 2009 -0800
@@ -53,4 +53,6 @@
     public long longAt(int index) {
         return value[index];
     }
+
+    private static final long serialVersionUID = 3585870271405924292L;
 }
--- a/src/share/classes/sun/management/counter/perf/LongCounterSnapshot.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/LongCounterSnapshot.java	Wed Nov 25 11:08:25 2009 -0800
@@ -52,4 +52,6 @@
     public long longValue() {
         return value;
     }
+
+    private static final long serialVersionUID = 2054263861474565758L;
 }
--- a/src/share/classes/sun/management/counter/perf/PerfByteArrayCounter.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/PerfByteArrayCounter.java	Wed Nov 25 11:08:25 2009 -0800
@@ -88,4 +88,6 @@
                                            getVectorLength(),
                                            byteArrayValue());
     }
+
+    private static final long serialVersionUID = 2545474036937279921L;
 }
--- a/src/share/classes/sun/management/counter/perf/PerfLongArrayCounter.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/PerfLongArrayCounter.java	Wed Nov 25 11:08:25 2009 -0800
@@ -80,4 +80,6 @@
                                             getVectorLength(),
                                             longArrayValue());
     }
+
+    private static final long serialVersionUID = -2733617913045487126L;
 }
--- a/src/share/classes/sun/management/counter/perf/PerfLongCounter.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/PerfLongCounter.java	Wed Nov 25 11:08:25 2009 -0800
@@ -62,4 +62,6 @@
                                        getFlags(),
                                        longValue());
     }
+
+    private static final long serialVersionUID = 857711729279242948L;
 }
--- a/src/share/classes/sun/management/counter/perf/PerfStringCounter.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/PerfStringCounter.java	Wed Nov 25 11:08:25 2009 -0800
@@ -86,4 +86,5 @@
                                          stringValue());
     }
 
+    private static final long serialVersionUID = 6802913433363692452L;
 }
--- a/src/share/classes/sun/management/counter/perf/StringCounterSnapshot.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/counter/perf/StringCounterSnapshot.java	Wed Nov 25 11:08:25 2009 -0800
@@ -49,4 +49,6 @@
     public String stringValue() {
         return value;
     }
+
+    private static final long serialVersionUID = 1132921539085572034L;
 }
--- a/src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/management/jmxremote/SingleEntryRegistry.java	Wed Nov 25 11:08:25 2009 -0800
@@ -86,4 +86,6 @@
 
     private final String name;
     private final Remote object;
+
+    private static final long serialVersionUID = -4897238949499730950L;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/misc/IOUtils.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+/**
+ * IOUtils: A collection of IO-related public static methods.
+ */
+
+package sun.misc;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+public class IOUtils {
+
+    /**
+     * Read up to <code>length</code> of bytes from <code>in</code>
+     * until EOF is detected.
+     * @param in input stream, must not be null
+     * @param length number of bytes to read, -1 or Integer.MAX_VALUE means
+     *        read as much as possible
+     * @param readAll if true, an EOFException will be thrown if not enough
+     *        bytes are read. Ignored when length is -1 or Integer.MAX_VALUE
+     * @return bytes read
+     * @throws IOException Any IO error or a premature EOF is detected
+     */
+    public static byte[] readFully(InputStream is, int length, boolean readAll)
+            throws IOException {
+        byte[] output = {};
+        if (length == -1) length = Integer.MAX_VALUE;
+        int pos = 0;
+        while (pos < length) {
+            int bytesToRead;
+            if (pos >= output.length) { // Only expand when there's no room
+                bytesToRead = Math.min(length - pos, output.length + 1024);
+                if (output.length < pos + bytesToRead) {
+                    output = Arrays.copyOf(output, pos + bytesToRead);
+                }
+            } else {
+                bytesToRead = output.length - pos;
+            }
+            int cc = is.read(output, pos, bytesToRead);
+            if (cc < 0) {
+                if (readAll && length != Integer.MAX_VALUE) {
+                    throw new EOFException("Detect premature EOF");
+                } else {
+                    if (output.length != pos) {
+                        output = Arrays.copyOf(output, pos);
+                    }
+                    break;
+                }
+            }
+            pos += cc;
+        }
+        return output;
+    }
+}
--- a/src/share/classes/sun/misc/Resource.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/misc/Resource.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1998-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1998-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
@@ -25,14 +25,15 @@
 
 package sun.misc;
 
+import java.io.EOFException;
 import java.net.URL;
 import java.io.IOException;
 import java.io.InterruptedIOException;
 import java.io.InputStream;
 import java.security.CodeSigner;
 import java.util.jar.Manifest;
-import java.util.jar.Attributes;
 import java.nio.ByteBuffer;
+import java.util.Arrays;
 import sun.nio.ByteBuffered;
 
 /**
@@ -105,49 +106,37 @@
         }
 
         try {
-            if (len != -1) {
-                // Read exactly len bytes from the input stream
-                b = new byte[len];
-                while (len > 0) {
-                    int n = 0;
-                    try {
-                        n = in.read(b, b.length - len, len);
-                    } catch (InterruptedIOException iioe) {
-                        Thread.interrupted();
-                        isInterrupted = true;
+            b = new byte[0];
+            if (len == -1) len = Integer.MAX_VALUE;
+            int pos = 0;
+            while (pos < len) {
+                int bytesToRead;
+                if (pos >= b.length) { // Only expand when there's no room
+                    bytesToRead = Math.min(len - pos, b.length + 1024);
+                    if (b.length < pos + bytesToRead) {
+                        b = Arrays.copyOf(b, pos + bytesToRead);
                     }
-                    if (n == -1) {
-                        throw new IOException("unexpected EOF");
-                    }
-                    len -= n;
+                } else {
+                    bytesToRead = b.length - pos;
                 }
-            } else {
-                // Read until end of stream is reached
-                b = new byte[1024];
-                int total = 0;
-                for (;;) {
-                    len = 0;
-                    try {
-                        len = in.read(b, total, b.length - total);
-                        if (len == -1)
-                            break;
-                    } catch (InterruptedIOException iioe) {
-                        Thread.interrupted();
-                        isInterrupted = true;
-                    }
-                    total += len;
-                    if (total >= b.length) {
-                        byte[] tmp = new byte[total * 2];
-                        System.arraycopy(b, 0, tmp, 0, total);
-                        b = tmp;
+                int cc = 0;
+                try {
+                    cc = in.read(b, pos, bytesToRead);
+                } catch (InterruptedIOException iioe) {
+                    Thread.interrupted();
+                    isInterrupted = true;
+                }
+                if (cc < 0) {
+                    if (len != Integer.MAX_VALUE) {
+                        throw new EOFException("Detect premature EOF");
+                    } else {
+                        if (b.length != pos) {
+                            b = Arrays.copyOf(b, pos);
+                        }
+                        break;
                     }
                 }
-                // Trim array to correct size, if necessary
-                if (total != b.length) {
-                    byte[] tmp = new byte[total];
-                    System.arraycopy(b, 0, tmp, 0, total);
-                    b = tmp;
-                }
+                pos += cc;
             }
         } finally {
             try {
--- a/src/share/classes/sun/net/ftp/FtpClient.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/ftp/FtpClient.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1994-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * 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
@@ -22,794 +22,922 @@
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
  */
-
 package sun.net.ftp;
 
-import java.util.StringTokenizer;
-import java.util.regex.*;
+import java.net.*;
 import java.io.*;
-import java.net.*;
-import sun.net.TransferProtocolClient;
-import sun.net.TelnetInputStream;
-import sun.net.TelnetOutputStream;
-import sun.misc.RegexpPool;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
+import java.util.Date;
+import java.util.List;
+import java.util.Iterator;
 
 /**
- * This class implements the FTP client.
+ * A class that implements the FTP protocol according to
+ * RFCs <A href="http://www.ietf.org/rfc/rfc0959.txt">959</A>,
+ * <A href="http://www.ietf.org/rfc/rfc2228.txt">2228</A>,
+ * <A href="http://www.ietf.org/rfc/rfc2389.txt">2389</A>,
+ * <A href="http://www.ietf.org/rfc/rfc2428.txt">2428</A>,
+ * <A href="http://www.ietf.org/rfc/rfc3659.txt">3659</A>,
+ * <A href="http://www.ietf.org/rfc/rfc4217.txt">4217</A>.
+ * Which includes support for FTP over SSL/TLS (aka ftps).
  *
- * @author      Jonathan Payne
+ * {@code FtpClient} provides all the functionalities of a typical FTP
+ * client, like storing or retrieving files, listing or creating directories.
+ * A typical usage would consist of connecting the client to the server,
+ * log in, issue a few commands then logout.
+ * Here is a code example:
+ * <pre>
+ * FtpClient cl = FtpClient.create();
+ * cl.connect("ftp.gnu.org").login("anonymous", "john.doe@mydomain.com".toCharArray())).changeDirectory("pub/gnu");
+ * Iterator&lt;FtpDirEntry&gt; dir = cl.listFiles();
+ *     while (dir.hasNext()) {
+ *         FtpDirEntry f = dir.next();
+ *         System.err.println(f.getName());
+ *     }
+ *     cl.close();
+ * }
+ * </pre>
+ * <p><b>Error reporting:</b> There are, mostly, two families of errors that
+ * can occur during an FTP session. The first kind are the network related issues
+ * like a connection reset, and they are usually fatal to the session, meaning,
+ * in all likelyhood the connection to the server has been lost and the session
+ * should be restarted from scratch. These errors are reported by throwing an
+ * {@link IOException}. The second kind are the errors reported by the FTP server,
+ * like when trying to download a non-existing file for example. These errors
+ * are usually non fatal to the session, meaning more commands can be sent to the
+ * server. In these cases, a {@link FtpProtocolException} is thrown.</p>
+ * <p>
+ * It should be noted that this is not a thread-safe API, as it wouldn't make
+ * too much sense, due to the very sequential nature of FTP, to provide a
+ * client able to be manipulated from multiple threads.
+ *
+ * @since 1.7
  */
-
-public class FtpClient extends TransferProtocolClient {
-    public static final int FTP_PORT = 21;
-
-    static int  FTP_SUCCESS = 1;
-    static int  FTP_TRY_AGAIN = 2;
-    static int  FTP_ERROR = 3;
-
-    /** remember the ftp server name because we may need it */
-    private String      serverName = null;
-
-    /** socket for data transfer */
-    private boolean     replyPending = false;
-    private boolean     binaryMode = false;
-    private boolean     loggedIn = false;
-
-    /** regexp pool of hosts for which we should connect directly, not Proxy
-     *  these are intialized from a property.
-     */
-    private static RegexpPool nonProxyHostsPool = null;
+public abstract class FtpClient implements java.io.Closeable {
 
-    /** The string soucre of nonProxyHostsPool
-     */
-    private static String nonProxyHostsSource = null;
+    private static final int FTP_PORT = 21;
 
-    /** last command issued */
-    String              command;
+    public static enum TransferType {
 
-    /** The last reply code from the ftp daemon. */
-    int                 lastReplyCode;
+        ASCII, BINARY, EBCDIC
+    };
 
-    /** Welcome message from the server, if any. */
-    public String       welcomeMsg;
-
-
-    /* these methods are used to determine whether ftp urls are sent to */
-    /* an http server instead of using a direct connection to the */
-    /* host. They aren't used directly here. */
     /**
-     * @return if the networking layer should send ftp connections through
-     *          a proxy
+     * Returns the default FTP port number.
+     *
+     * @return the port number.
      */
-    public static boolean getUseFtpProxy() {
-        // if the ftp.proxyHost is set, use it!
-        return (getFtpProxyHost() != null);
+    public static final int defaultPort() {
+        return FTP_PORT;
     }
 
     /**
-     * @return the host to use, or null if none has been specified
+     * Creates an instance of FtpClient. The client is not connected to any
+     * server yet.
+     *
      */
-    public static String getFtpProxyHost() {
-        return java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<String>() {
-            public String run() {
-                String result = System.getProperty("ftp.proxyHost");
-                if (result == null) {
-                    result = System.getProperty("ftpProxyHost");
-                }
-                if (result == null) {
-                    // as a last resort we use the general one if ftp.useProxy
-                    // is true
-                    if (Boolean.getBoolean("ftp.useProxy")) {
-                    result = System.getProperty("proxyHost");
-                    }
-                }
-                return result;
-            }
-        });
+    protected FtpClient() {
+    }
+
+    /**
+     * Creates an instance of {@code FtpClient}. The client is not connected to any
+     * server yet.
+     *
+     * @return the created {@code FtpClient}
+     */
+    public static FtpClient create() {
+        FtpClientProvider provider = FtpClientProvider.provider();
+        return provider.createFtpClient();
     }
 
     /**
-     * @return the proxy port to use.  Will default reasonably if not set.
+     * Creates an instance of FtpClient and connects it to the specified
+     * address.
+     *
+     * @param dest the {@code InetSocketAddress} to connect to.
+     * @return The created {@code FtpClient}
+     * @throws IOException if the connection fails
+     * @see #connect(java.net.SocketAddress)
      */
-    public static int getFtpProxyPort() {
-        final int result[] = {80};
-        java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<Void>() {
-                public Void run() {
-
-                String tmp = System.getProperty("ftp.proxyPort");
-                if (tmp == null) {
-                    // for compatibility with 1.0.2
-                    tmp = System.getProperty("ftpProxyPort");
-                }
-                if (tmp == null) {
-                    // as a last resort we use the general one if ftp.useProxy
-                    // is true
-                    if (Boolean.getBoolean("ftp.useProxy")) {
-                        tmp = System.getProperty("proxyPort");
-                    }
-                }
-                if (tmp != null) {
-                    result[0] = Integer.parseInt(tmp);
-                }
-                return null;
-            }
-        });
-        return result[0];
-    }
-
-    public static boolean matchNonProxyHosts(String host) {
-        synchronized (FtpClient.class) {
-            String rawList = java.security.AccessController.doPrivileged(
-                    new sun.security.action.GetPropertyAction("ftp.nonProxyHosts"));
-            if (rawList == null) {
-                nonProxyHostsPool = null;
-            } else {
-                if (!rawList.equals(nonProxyHostsSource)) {
-                    RegexpPool pool = new RegexpPool();
-                    StringTokenizer st = new StringTokenizer(rawList, "|", false);
-                    try {
-                        while (st.hasMoreTokens()) {
-                            pool.add(st.nextToken().toLowerCase(), Boolean.TRUE);
-                        }
-                    } catch (sun.misc.REException ex) {
-                        System.err.println("Error in http.nonProxyHosts system property: " + ex);
-                    }
-                    nonProxyHostsPool = pool;
-                }
-            }
-            nonProxyHostsSource = rawList;
+    public static FtpClient create(InetSocketAddress dest) throws FtpProtocolException, IOException {
+        FtpClient client = create();
+        if (dest != null) {
+            client.connect(dest);
         }
-
-        if (nonProxyHostsPool == null) {
-            return false;
-        }
-
-        if (nonProxyHostsPool.match(host) != null) {
-            return true;
-        } else {
-            return false;
-        }
+        return client;
     }
 
     /**
-     * issue the QUIT command to the FTP server and close the connection.
+     * Creates an instance of {@code FtpClient} and connects it to the
+     * specified host on the default FTP port.
      *
-     * @exception       FtpProtocolException if an error occured
+     * @param dest the {@code String} containing the name of the host
+     *        to connect to.
+     * @return The created {@code FtpClient}
+     * @throws IOException if the connection fails.
+     * @throws FtpProtocolException if the server rejected the connection
      */
-    public void closeServer() throws IOException {
-        if (serverIsOpen()) {
-            issueCommand("QUIT");
-            super.closeServer();
-        }
+    public static FtpClient create(String dest) throws FtpProtocolException, IOException {
+        return create(new InetSocketAddress(dest, FTP_PORT));
     }
 
     /**
-     * Send a command to the FTP server.
+     * Enables, or disables, the use of the <I>passive</I> mode. In that mode,
+     * data connections are established by having the client connect to the server.
+     * This is the recommended default mode as it will work best through
+     * firewalls and NATs. If set to {@code false} the mode is said to be
+     * <I>active</I> which means the server will connect back to the client
+     * after a PORT command to establish a data connection.
      *
-     * @param   cmd     String containing the command
-     * @return          reply code
+     * <p><b>Note:</b> Since the passive mode might not be supported by all
+     * FTP servers, enabling it means the client will try to use it. If the
+     * server rejects it, then the client will attempt to fall back to using
+     * the <I>active</I> mode by issuing a {@code PORT} command instead.</p>
+     *
+     * @param passive {@code true} to force passive mode.
+     * @return This FtpClient
+     * @see #isPassiveModeEnabled()
+     */
+    public abstract FtpClient enablePassiveMode(boolean passive);
+
+    /**
+     * Tests whether passive mode is enabled.
      *
-     * @exception       FtpProtocolException if an error occured
+     * @return {@code true} if the passive mode has been enabled.
+     * @see #enablePassiveMode(boolean)
+     */
+    public abstract boolean isPassiveModeEnabled();
+
+    /**
+     * Sets the default timeout value to use when connecting to the server,
+     *
+     * @param timeout the timeout value, in milliseconds, to use for the connect
+     *        operation. A value of zero or less, means use the default timeout.
+     *
+     * @return This FtpClient
      */
-    protected int issueCommand(String cmd) throws IOException {
-        command = cmd;
+    public abstract FtpClient setConnectTimeout(int timeout);
 
-        int reply;
+    /**
+     * Returns the current default connection timeout value.
+     *
+     * @return the value, in milliseconds, of the current connect timeout.
+     * @see #setConnectTimeout(int)
+     */
+    public abstract int getConnectTimeout();
+
+    /**
+     * Sets the timeout value to use when reading from the server,
+     *
+     * @param timeout the timeout value, in milliseconds, to use for the read
+     *        operation. A value of zero or less, means use the default timeout.
+     * @return This FtpClient
+     */
+    public abstract FtpClient setReadTimeout(int timeout);
 
-        while (replyPending) {
-            replyPending = false;
-            if (readReply() == FTP_ERROR)
-                throw new FtpProtocolException("Error reading FTP pending reply\n");
-        }
-        do {
-            sendServer(cmd + "\r\n");
-            reply = readReply();
-        } while (reply == FTP_TRY_AGAIN);
-        return reply;
-    }
+    /**
+     * Returns the current read timeout value.
+     *
+     * @return the value, in milliseconds, of the current read timeout.
+     * @see #setReadTimeout(int)
+     */
+    public abstract int getReadTimeout();
+
+    /**
+     * Set the {@code Proxy} to be used for the next connection.
+     * If the client is already connected, it doesn't affect the current
+     * connection. However it is not recommended to change this during a session.
+     *
+     * @param p the {@code Proxy} to use, or {@code null} for no proxy.
+     * @return This FtpClient
+     */
+    public abstract FtpClient setProxy(Proxy p);
+
+    /**
+     * Get the proxy of this FtpClient
+     *
+     * @return the {@code Proxy}, this client is using, or {@code null}
+     * if none is used.
+     * @see #setProxy(Proxy)
+     */
+    public abstract Proxy getProxy();
+
+    /**
+     * Tests whether this client is connected or not to a server.
+     *
+     * @return {@code true} if the client is connected.
+     */
+    public abstract boolean isConnected();
+
+    /**
+     * Connects the {@code FtpClient} to the specified destination server.
+     *
+     * @param dest the address of the destination server
+     * @return this FtpClient
+     * @throws IOException if connection failed.
+     * @throws SecurityException if there is a SecurityManager installed and it
+     * denied the authorization to connect to the destination.
+     * @throws FtpProtocolException
+     */
+    public abstract FtpClient connect(SocketAddress dest) throws FtpProtocolException, IOException;
+
+    /**
+     * Connects the FtpClient to the specified destination server.
+     *
+     * @param dest the address of the destination server
+     * @param timeout the value, in milliseconds, to use as a connection timeout
+     * @return this FtpClient
+     * @throws IOException if connection failed.
+     * @throws SecurityException if there is a SecurityManager installed and it
+     * denied the authorization to connect to the destination.
+     * @throws FtpProtocolException
+     */
+    public abstract FtpClient connect(SocketAddress dest, int timeout) throws FtpProtocolException, IOException;
+
+    /**
+     * Retrieves the address of the FTP server this client is connected to.
+     *
+     * @return the {@link SocketAddress} of the server, or {@code null} if this
+     * client is not connected yet.
+     */
+    public abstract SocketAddress getServerAddress();
 
     /**
-     * Send a command to the FTP server and check for success.
+     * Attempts to log on the server with the specified user name and password.
+     *
+     * @param user The user name
+     * @param password The password for that user
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission
+     * @throws FtpProtocolException if the login was refused by the server
+     */
+    public abstract FtpClient login(String user, char[] password) throws FtpProtocolException, IOException;
+
+    /**
+     * Attempts to log on the server with the specified user name, password and
+     * account name.
      *
-     * @param   cmd     String containing the command
+     * @param user The user name
+     * @param password The password for that user.
+     * @param account The account name for that user.
+     * @return this FtpClient
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the login was refused by the server
+     */
+    public abstract FtpClient login(String user, char[] password, String account) throws FtpProtocolException, IOException;
+
+    /**
+     * Closes the current connection. Logs out the current user, if any, by
+     * issuing the QUIT command to the server.
+     * This is in effect terminates the current
+     * session and the connection to the server will be closed.
+     * <p>After a close, the client can then be connected to another server
+     * to start an entirely different session.</P>
      *
-     * @exception       FtpProtocolException if an error occured
+     * @throws IOException if an error occurs during transmission
+     */
+    public abstract void close() throws IOException;
+
+    /**
+     * Checks whether the client is logged in to the server or not.
+     *
+     * @return {@code true} if the client has already completed a login.
+     */
+    public abstract boolean isLoggedIn();
+
+    /**
+     * Changes to a specific directory on a remote FTP server
+     *
+     * @param  remoteDirectory path of the directory to CD to.
+     * @return this FtpClient
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was refused by the server
      */
-    protected void issueCommandCheck(String cmd) throws IOException {
-        if (issueCommand(cmd) != FTP_SUCCESS)
-            throw new FtpProtocolException(cmd + ":" + getResponseString());
-    }
+    public abstract FtpClient changeDirectory(String remoteDirectory) throws FtpProtocolException, IOException;
+
+    /**
+     * Changes to the parent directory, sending the CDUP command to the server.
+     *
+     * @return this FtpClient
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was refused by the server
+     */
+    public abstract FtpClient changeToParentDirectory() throws FtpProtocolException, IOException;
+
+    /**
+     * Retrieve the server current working directory using the PWD command.
+     *
+     * @return a {@code String} containing the current working directory
+     * @throws IOException if an error occurs during transmission
+     * @throws FtpProtocolException if the command was refused by the server,
+     */
+    public abstract String getWorkingDirectory() throws FtpProtocolException, IOException;
 
     /**
-     * Read the reply from the FTP server.
+     * Sets the restart offset to the specified value.  That value will be
+     * sent through a {@code REST} command to server before the next file
+     * transfer and has the effect of resuming a file transfer from the
+     * specified point. After the transfer the restart offset is set back to
+     * zero.
      *
-     * @return          FTP_SUCCESS or FTP_ERROR depending on success
-     * @exception       FtpProtocolException if an error occured
+     * @param offset the offset in the remote file at which to start the next
+     *        transfer. This must be a value greater than or equal to zero.
+     * @return this FtpClient
+     * @throws IllegalArgumentException if the offset is negative.
      */
-    protected int readReply() throws IOException {
-        lastReplyCode = readServerResponse();
+    public abstract FtpClient setRestartOffset(long offset);
 
-        switch (lastReplyCode / 100) {
-        case 1:
-            replyPending = true;
-            /* falls into ... */
+    /**
+     * Retrieves a file from the ftp server and writes its content to the specified
+     * {@code OutputStream}.
+     * <p>If the restart offset was set, then a {@code REST} command will be
+     * sent before the {@code RETR} in order to restart the tranfer from the specified
+     * offset.</p>
+     * <p>The {@code OutputStream} is not closed by this method at the end
+     * of the transfer. </p>
+     * <p>This method will block until the transfer is complete or an exception
+     * is thrown.</p>
+     *
+     * @param name a {@code String} containing the name of the file to
+     *        retreive from the server.
+     * @param local the {@code OutputStream} the file should be written to.
+     * @return this FtpClient
+     * @throws IOException if the transfer fails.
+     * @throws FtpProtocolException if the command was refused by the server
+     * @see #setRestartOffset(long)
+     */
+    public abstract FtpClient getFile(String name, OutputStream local) throws FtpProtocolException, IOException;
 
-        case 2:
-        case 3:
-            return FTP_SUCCESS;
+    /**
+     * Retrieves a file from the ftp server, using the {@code RETR} command, and
+     * returns the InputStream from the established data connection.
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is done reading from the returned stream.
+     * <p>If the restart offset was set, then a {@code REST} command will be
+     * sent before the {@code RETR} in order to restart the tranfer from the specified
+     * offset.</p>
+     *
+     * @param name the name of the remote file
+     * @return the {@link java.io.InputStream} from the data connection
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was refused by the server
+     * @see #setRestartOffset(long)
+     */
+    public abstract InputStream getFileStream(String name) throws FtpProtocolException, IOException;
 
-        case 5:
-            if (lastReplyCode == 530) {
-                if (!loggedIn) {
-                    throw new FtpLoginException("Not logged in");
-                }
-                return FTP_ERROR;
-            }
-            if (lastReplyCode == 550) {
-                throw new FileNotFoundException(command + ": " + getResponseString());
-            }
-        }
-
-        /* this statement is not reached */
-        return FTP_ERROR;
+    /**
+     * Transfers a file from the client to the server (aka a <I>put</I>)
+     * by sending the STOR command, and returns the {@code OutputStream}
+     * from the established data connection.
+     *
+     * A new file is created at the server site if the file specified does
+     * not already exist.
+     *
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is finished writing to the returned stream.
+     *
+     * @param name the name of the remote file to write.
+     * @return the {@link java.io.OutputStream} from the data connection or
+     *         {@code null} if the command was unsuccessful.
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public OutputStream putFileStream(String name) throws FtpProtocolException, IOException {
+        return putFileStream(name, false);
     }
 
     /**
-     * Tries to open a Data Connection in "PASSIVE" mode by issuing a EPSV or
-     * PASV command then opening a Socket to the specified address & port
+     * Transfers a file from the client to the server (aka a <I>put</I>)
+     * by sending the STOR or STOU command, depending on the
+     * {@code unique} argument, and returns the {@code OutputStream}
+     * from the established data connection.
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is finished writing to the stream.
+     *
+     * A new file is created at the server site if the file specified does
+     * not already exist.
      *
-     * @return          the opened socket
-     * @exception       FtpProtocolException if an error occurs when issuing the
-     *                  PASV command to the ftp server.
+     * If {@code unique} is set to {@code true}, the resultant file
+     * is to be created under a name unique to that directory, meaning
+     * it will not overwrite an existing file, instead the server will
+     * generate a new, unique, file name.
+     * The name of the remote file can be retrieved, after completion of the
+     * transfer, by calling {@link #getLastFileName()}.
+     *
+     * @param name the name of the remote file to write.
+     * @param unique {@code true} if the remote files should be unique,
+     *        in which case the STOU command will be used.
+     * @return the {@link java.io.OutputStream} from the data connection.
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    protected Socket openPassiveDataConnection() throws IOException {
-        String serverAnswer;
-        int port;
-        InetSocketAddress dest = null;
-
-        /**
-         * Here is the idea:
-         *
-         * - First we want to try the new (and IPv6 compatible) EPSV command
-         *   But since we want to be nice with NAT software, we'll issue the
-         *   EPSV ALL cmd first.
-         *   EPSV is documented in RFC2428
-         * - If EPSV fails, then we fall back to the older, yet OK PASV command
-         * - If PASV fails as well, then we throw an exception and the calling method
-         *   will have to try the EPRT or PORT command
-         */
-        if (issueCommand("EPSV ALL") == FTP_SUCCESS) {
-            // We can safely use EPSV commands
-            if (issueCommand("EPSV") == FTP_ERROR)
-                throw new FtpProtocolException("EPSV Failed: " + getResponseString());
-            serverAnswer = getResponseString();
-
-            // The response string from a EPSV command will contain the port number
-            // the format will be :
-            //  229 Entering Extended Passive Mode (|||58210|)
-            //
-            // So we'll use the regular expresions package to parse the output.
+    public abstract OutputStream putFileStream(String name, boolean unique) throws FtpProtocolException, IOException;
 
-            Pattern p = Pattern.compile("^229 .* \\(\\|\\|\\|(\\d+)\\|\\)");
-            Matcher m = p.matcher(serverAnswer);
-            if (! m.find())
-                throw new FtpProtocolException("EPSV failed : " + serverAnswer);
-            // Yay! Let's extract the port number
-            String s = m.group(1);
-            port = Integer.parseInt(s);
-            InetAddress add = serverSocket.getInetAddress();
-            if (add != null) {
-                dest = new InetSocketAddress(add, port);
-            } else {
-                // This means we used an Unresolved address to connect in
-                // the first place. Most likely because the proxy is doing
-                // the name resolution for us, so let's keep using unresolved
-                // address.
-                dest = InetSocketAddress.createUnresolved(serverName, port);
-            }
-        } else {
-            // EPSV ALL failed, so Let's try the regular PASV cmd
-            if (issueCommand("PASV") == FTP_ERROR)
-                throw new FtpProtocolException("PASV failed: " + getResponseString());
-            serverAnswer = getResponseString();
-
-            // Let's parse the response String to get the IP & port to connect to
-            // the String should be in the following format :
-            //
-            // 227 Entering Passive Mode (A1,A2,A3,A4,p1,p2)
-            //
-            // Note that the two parenthesis are optional
-            //
-            // The IP address is A1.A2.A3.A4 and the port is p1 * 256 + p2
-            //
-            // The regular expression is a bit more complex this time, because the
-            // parenthesis are optionals and we have to use 3 groups.
-
-            Pattern p = Pattern.compile("227 .* \\(?(\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)?");
-            Matcher m = p.matcher(serverAnswer);
-            if (! m.find())
-                throw new FtpProtocolException("PASV failed : " + serverAnswer);
-            // Get port number out of group 2 & 3
-            port = Integer.parseInt(m.group(3)) + (Integer.parseInt(m.group(2)) << 8);
-            // IP address is simple
-            String s = m.group(1).replace(',','.');
-            dest = new InetSocketAddress(s, port);
-        }
-        // Got everything, let's open the socket!
-        Socket s;
-        if (proxy != null) {
-            if (proxy.type() == Proxy.Type.SOCKS) {
-                s = AccessController.doPrivileged(
-                    new PrivilegedAction<Socket>() {
-                        public Socket run() {
-                                  return new Socket(proxy);
-                              }});
-            } else
-                s = new Socket(Proxy.NO_PROXY);
-        } else
-            s = new Socket();
-        // Bind the socket to the same address as the control channel. This
-        // is needed in case of multi-homed systems.
-        s.bind(new InetSocketAddress(serverSocket.getLocalAddress(),0));
-        if (connectTimeout >= 0) {
-            s.connect(dest, connectTimeout);
-        } else {
-            if (defaultConnectTimeout > 0) {
-                s.connect(dest, defaultConnectTimeout);
-            } else {
-                s.connect(dest);
-            }
-        }
-        if (readTimeout >= 0)
-            s.setSoTimeout(readTimeout);
-        else
-            if (defaultSoTimeout > 0) {
-                s.setSoTimeout(defaultSoTimeout);
-        }
-        return s;
+    /**
+     * Transfers a file from the client to the server (aka a <I>put</I>)
+     * by sending the STOR or STOU command, depending on the
+     * {@code unique} argument. The content of the {@code InputStream}
+     * passed in argument is written into the remote file, overwriting any
+     * existing data.
+     *
+     * A new file is created at the server site if the file specified does
+     * not already exist.
+     *
+     * If {@code unique} is set to {@code true}, the resultant file
+     * is to be created under a name unique to that directory, meaning
+     * it will not overwrite an existing file, instead the server will
+     * generate a new, unique, file name.
+     * The name of the remote file can be retrieved, after completion of the
+     * transfer, by calling {@link #getLastFileName()}.
+     *
+     * <p>This method will block until the transfer is complete or an exception
+     * is thrown.</p>
+     *
+     * @param name the name of the remote file to write.
+     * @param local the {@code InputStream} that points to the data to
+     *        transfer.
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public FtpClient putFile(String name, InputStream local) throws FtpProtocolException, IOException {
+        return putFile(name, local, false);
     }
 
     /**
-     * Tries to open a Data Connection with the server. It will first try a passive
-     * mode connection, then, if it fails, a more traditional PORT command
+     * Transfers a file from the client to the server (aka a <I>put</I>)
+     * by sending the STOR command. The content of the {@code InputStream}
+     * passed in argument is written into the remote file, overwriting any
+     * existing data.
      *
-     * @param   cmd     the command to execute (RETR, STOR, etc...)
-     * @return          the opened socket
+     * A new file is created at the server site if the file specified does
+     * not already exist.
+     *
+     * <p>This method will block until the transfer is complete or an exception
+     * is thrown.</p>
      *
-     * @exception       FtpProtocolException if an error occurs when issuing the
-     *                  PORT command to the ftp server.
+     * @param name the name of the remote file to write.
+     * @param local the {@code InputStream} that points to the data to
+     *        transfer.
+     * @param unique {@code true} if the remote file should be unique
+     *        (i.e. not already existing), {@code false} otherwise.
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     * @see #getLastFileName()
      */
-    protected Socket openDataConnection(String cmd) throws IOException {
-        ServerSocket portSocket;
-        Socket  clientSocket = null;
-        String      portCmd;
-        InetAddress myAddress;
-        IOException e;
+    public abstract FtpClient putFile(String name, InputStream local, boolean unique) throws FtpProtocolException, IOException;
 
-        // Let's try passive mode first
-        try {
-            clientSocket = openPassiveDataConnection();
-        } catch (IOException ex) {
-            clientSocket = null;
-        }
-        if (clientSocket != null) {
-            // We did get a clientSocket, so the passive mode worked
-            // Let's issue the command (GET, DIR, ...)
-            try {
-                if (issueCommand(cmd) == FTP_ERROR) {
-                    clientSocket.close();
-                    throw new FtpProtocolException(getResponseString());
-                } else
-                    return clientSocket;
-            } catch (IOException ioe) {
-                clientSocket.close();
-                throw ioe;
-            }
-        }
-
-        assert(clientSocket == null);
-
-        // Passive mode failed, let's fall back to the good old "PORT"
+    /**
+     * Sends the APPE command to the server in order to transfer a data stream
+     * passed in argument and append it to the content of the specified remote
+     * file.
+     *
+     * <p>This method will block until the transfer is complete or an exception
+     * is thrown.</p>
+     *
+     * @param name A {@code String} containing the name of the remote file
+     *        to append to.
+     * @param local The {@code InputStream} providing access to the data
+     *        to be appended.
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient appendFile(String name, InputStream local) throws FtpProtocolException, IOException;
 
-        if (proxy != null && proxy.type() == Proxy.Type.SOCKS) {
-            // We're behind a firewall and the passive mode fail,
-            // since we can't accept a connection through SOCKS (yet)
-            // throw an exception
-            throw new FtpProtocolException("Passive mode failed");
-        }
-        // Bind the ServerSocket to the same address as the control channel
-        // This is needed for multi-homed systems
-        portSocket = new ServerSocket(0, 1, serverSocket.getLocalAddress());
-        try {
-            myAddress = portSocket.getInetAddress();
-            if (myAddress.isAnyLocalAddress())
-                myAddress = getLocalAddress();
-            // Let's try the new, IPv6 compatible EPRT command
-            // See RFC2428 for specifics
-            // Some FTP servers (like the one on Solaris) are bugged, they
-            // will accept the EPRT command but then, the subsequent command
-            // (e.g. RETR) will fail, so we have to check BOTH results (the
-            // EPRT cmd then the actual command) to decide wether we should
-            // fall back on the older PORT command.
-            portCmd = "EPRT |" +
-                ((myAddress instanceof Inet6Address) ? "2" : "1") + "|" +
-                myAddress.getHostAddress() +"|" +
-                portSocket.getLocalPort()+"|";
-            if (issueCommand(portCmd) == FTP_ERROR ||
-                issueCommand(cmd) == FTP_ERROR) {
-                // The EPRT command failed, let's fall back to good old PORT
-                portCmd = "PORT ";
-                byte[] addr = myAddress.getAddress();
+    /**
+     * Renames a file on the server.
+     *
+     * @param from the name of the file being renamed
+     * @param to the new name for the file
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient rename(String from, String to) throws FtpProtocolException, IOException;
 
-                /* append host addr */
-                for (int i = 0; i < addr.length; i++) {
-                    portCmd = portCmd + (addr[i] & 0xFF) + ",";
-                }
+    /**
+     * Deletes a file on the server.
+     *
+     * @param name a {@code String} containing the name of the file
+     *        to delete.
+     * @return this FtpClient
+     * @throws IOException if an error occured during the exchange
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient deleteFile(String name) throws FtpProtocolException, IOException;
 
-                /* append port number */
-                portCmd = portCmd + ((portSocket.getLocalPort() >>> 8) & 0xff) + ","
-                    + (portSocket.getLocalPort() & 0xff);
-                if (issueCommand(portCmd) == FTP_ERROR) {
-                    e = new FtpProtocolException("PORT :" + getResponseString());
-                    throw e;
-                }
-                if (issueCommand(cmd) == FTP_ERROR) {
-                    e = new FtpProtocolException(cmd + ":" + getResponseString());
-                    throw e;
-                }
-            }
-            // Either the EPRT or the PORT command was successful
-            // Let's create the client socket
-            if (connectTimeout >= 0) {
-                portSocket.setSoTimeout(connectTimeout);
-            } else {
-                if (defaultConnectTimeout > 0)
-                    portSocket.setSoTimeout(defaultConnectTimeout);
-            }
-            clientSocket = portSocket.accept();
-            if (readTimeout >= 0)
-                clientSocket.setSoTimeout(readTimeout);
-            else {
-                if (defaultSoTimeout > 0)
-                    clientSocket.setSoTimeout(defaultSoTimeout);
-            }
-        } finally {
-            portSocket.close();
-        }
+    /**
+     * Creates a new directory on the server.
+     *
+     * @param name a {@code String} containing the name of the directory
+     *        to create.
+     * @return this FtpClient
+     * @throws IOException if an error occured during the exchange
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient makeDirectory(String name) throws FtpProtocolException, IOException;
 
-        return clientSocket;
-    }
+    /**
+     * Removes a directory on the server.
+     *
+     * @param name a {@code String} containing the name of the directory
+     *        to remove.
+     *
+     * @return this FtpClient
+     * @throws IOException if an error occured during the exchange.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient removeDirectory(String name) throws FtpProtocolException, IOException;
 
-    /* public methods */
+    /**
+     * Sends a No-operation command. It's useful for testing the connection
+     * status or as a <I>keep alive</I> mechanism.
+     *
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient noop() throws FtpProtocolException, IOException;
 
     /**
-     * Open a FTP connection to host <i>host</i>.
+     * Sends the {@code STAT} command to the server.
+     * This can be used while a data connection is open to get a status
+     * on the current transfer, in that case the parameter should be
+     * {@code null}.
+     * If used between file transfers, it may have a pathname as argument
+     * in which case it will work as the LIST command except no data
+     * connection will be created.
+     *
+     * @param name an optional {@code String} containing the pathname
+     *        the STAT command should apply to.
+     * @return the response from the server
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract String getStatus(String name) throws FtpProtocolException, IOException;
+
+    /**
+     * Sends the {@code FEAT} command to the server and returns the list of supported
+     * features in the form of strings.
      *
-     * @param   host    The hostname of the ftp server
+     * The features are the supported commands, like AUTH TLS, PROT or PASV.
+     * See the RFCs for a complete list.
+     *
+     * Note that not all FTP servers support that command, in which case
+     * a {@link FtpProtocolException} will be thrown.
+     *
+     * @return a {@code List} of {@code Strings} describing the
+     *         supported additional features
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command is rejected by the server
+     */
+    public abstract List<String> getFeatures() throws FtpProtocolException, IOException;
+
+    /**
+     * Sends the {@code ABOR} command to the server.
+     * <p>It tells the server to stop the previous command or transfer. No action
+     * will be taken if the previous command has already been completed.</p>
+     * <p>This doesn't abort the current session, more commands can be issued
+     * after an abort.</p>
      *
-     * @exception       FtpProtocolException if connection fails
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public void openServer(String host) throws IOException {
-        openServer(host, FTP_PORT);
+    public abstract FtpClient abort() throws FtpProtocolException, IOException;
+
+    /**
+     * Some methods do not wait until completion before returning, so this
+     * method can be called to wait until completion. This is typically the case
+     * with commands that trigger a transfer like {@link #getFileStream(String)}.
+     * So this method should be called before accessing information related to
+     * such a command.
+     * <p>This method will actually block reading on the command channel for a
+     * notification from the server that the command is finished. Such a
+     * notification often carries extra information concerning the completion
+     * of the pending action (e.g. number of bytes transfered).</p>
+     * <p>Note that this will return immediately if no command or action
+     * is pending</p>
+     * <p>It should be also noted that most methods issuing commands to the ftp
+     * server will call this method if a previous command is pending.
+     * <p>Example of use:
+     * <pre>
+     * InputStream in = cl.getFileStream("file");
+     * ...
+     * cl.completePending();
+     * long size = cl.getLastTransferSize();
+     * </pre>
+     * On the other hand, it's not necessary in a case like:
+     * <pre>
+     * InputStream in = cl.getFileStream("file");
+     * // read content
+     * ...
+     * cl.close();
+     * </pre>
+     * <p>Since {@link #close()} will call completePending() if necessary.</p>
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transfer
+     * @throws FtpProtocolException if the command didn't complete successfully
+     */
+    public abstract FtpClient completePending() throws FtpProtocolException, IOException;
+
+    /**
+     * Reinitializes the USER parameters on the FTP server
+     *
+     * @return this FtpClient
+     * @throws IOException if an error occurs during transmission
+     * @throws FtpProtocolException if the command fails
+     */
+    public abstract FtpClient reInit() throws FtpProtocolException, IOException;
+
+    /**
+     * Changes the transfer type (binary, ascii, ebcdic) and issue the
+     * proper command (e.g. TYPE A) to the server.
+     *
+     * @param type the {@code TransferType} to use.
+     * @return This FtpClient
+     * @throws IOException if an error occurs during transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient setType(TransferType type) throws FtpProtocolException, IOException;
+
+    /**
+     * Changes the current transfer type to binary.
+     * This is a convenience method that is equivalent to
+     * {@code setType(TransferType.BINARY)}
+     *
+     * @return This FtpClient
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     * @see #setType(TransferType)
+     */
+    public FtpClient setBinaryType() throws FtpProtocolException, IOException {
+        setType(TransferType.BINARY);
+        return this;
     }
 
     /**
-     * Open a FTP connection to host <i>host</i> on port <i>port</i>.
-     *
-     * @param   host    the hostname of the ftp server
-     * @param   port    the port to connect to (usually 21)
+     * Changes the current transfer type to ascii.
+     * This is a convenience method that is equivalent to
+     * {@code setType(TransferType.ASCII)}
      *
-     * @exception       FtpProtocolException if connection fails
-     */
-    public void openServer(String host, int port) throws IOException {
-        this.serverName = host;
-        super.openServer(host, port);
-        if (readReply() == FTP_ERROR)
-            throw new FtpProtocolException("Welcome message: " +
-                                           getResponseString());
-    }
-
-
-    /**
-     * login user to a host with username <i>user</i> and password
-     * <i>password</i>
-     *
-     * @param   user            Username to use at login
-     * @param   password        Password to use at login or null of none is needed
-     *
-     * @exception       FtpLoginException if login is unsuccesful
+     * @return This FtpClient
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     * @see #setType(TransferType)
      */
-    public void login(String user, String password) throws IOException {
-        if (!serverIsOpen())
-            throw new FtpLoginException("not connected to host");
-        if (user == null || user.length() == 0)
-            return;
-        if (issueCommand("USER " + user) == FTP_ERROR)
-            throw new FtpLoginException("user " + user + " : " + getResponseString());
-        /*
-         * Checks for "331 User name okay, need password." answer
-         */
-
-        if (lastReplyCode == 331)
-            if ((password == null) || (password.length() == 0) ||
-                (issueCommand("PASS " + password) == FTP_ERROR))
-                throw new FtpLoginException("password: " + getResponseString());
-
-        // keep the welcome message around so we can
-        // put it in the resulting HTML page.
-        String l;
-        StringBuffer sb = new StringBuffer();
-        for (int i = 0; i < serverResponse.size(); i++) {
-            l = (String)serverResponse.elementAt(i);
-            if (l != null) {
-                if (l.length() >= 4 && l.startsWith("230")) {
-                    // get rid of the "230-" prefix
-                    l = l.substring(4);
-                }
-                sb.append(l);
-            }
-        }
-        welcomeMsg = sb.toString();
-        loggedIn = true;
+    public FtpClient setAsciiType() throws FtpProtocolException, IOException {
+        setType(TransferType.ASCII);
+        return this;
     }
 
     /**
-     * GET a file from the FTP server
+     * Issues a {@code LIST} command to the server to get the current directory
+     * listing, and returns the InputStream from the data connection.
+     *
+     * <p>{@link #completePending()} <b>has</b> to be called once the application
+     * is finished reading from the stream.</p>
      *
-     * @param   filename        name of the file to retrieve
-     * @return  the <code>InputStream</code> to read the file from
-     *
-     * @exception       FileNotFoundException if the file can't be opened
+     * @param path the pathname of the directory to list, or {@code null}
+     *        for the current working directory.
+     * @return the {@code InputStream} from the resulting data connection
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     * @see #changeDirectory(String)
+     * @see #listFiles(String)
      */
-    public TelnetInputStream get(String filename) throws IOException {
-        Socket  s;
-
-        try {
-            s = openDataConnection("RETR " + filename);
-        } catch (FileNotFoundException fileException) {
-            /* Well, "/" might not be the file delimitor for this
-               particular ftp server, so let's try a series of
-               "cd" commands to get to the right place. */
-            /* But don't try this if there are no '/' in the path */
-            if (filename.indexOf('/') == -1)
-                throw fileException;
-
-            StringTokenizer t = new StringTokenizer(filename, "/");
-            String          pathElement = null;
+    public abstract InputStream list(String path) throws FtpProtocolException, IOException;
 
-            while (t.hasMoreElements()) {
-                pathElement = t.nextToken();
+    /**
+     * Issues a {@code NLST path} command to server to get the specified directory
+     * content. It differs from {@link #list(String)} method by the fact that
+     * it will only list the file names which would make the parsing of the
+     * somewhat easier.
+     *
+     * <p>{@link #completePending()} <b>has</b> to be called once the application
+     * is finished reading from the stream.</p>
+     *
+     * @param path a {@code String} containing the pathname of the
+     *        directory to list or {@code null} for the current working directory.
+     * @return the {@code InputStream} from the resulting data connection
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract InputStream nameList(String path) throws FtpProtocolException, IOException;
 
-                if (!t.hasMoreElements()) {
-                    /* This is the file component.  Look it up now. */
-                    break;
-                }
-                try {
-                    cd(pathElement);
-                } catch (FtpProtocolException e) {
-                    /* Giving up. */
-                    throw fileException;
-                }
-            }
-            if (pathElement != null) {
-                s = openDataConnection("RETR " + pathElement);
-            } else {
-                throw fileException;
-            }
-        }
-
-        return new TelnetInputStream(s.getInputStream(), binaryMode);
-    }
+    /**
+     * Issues the {@code SIZE [path]} command to the server to get the size of a
+     * specific file on the server.
+     * Note that this command may not be supported by the server. In which
+     * case -1 will be returned.
+     *
+     * @param path a {@code String} containing the pathname of the
+     *        file.
+     * @return a {@code long} containing the size of the file or -1 if
+     *         the server returned an error, which can be checked with
+     *         {@link #getLastReplyCode()}.
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract long getSize(String path) throws FtpProtocolException, IOException;
 
     /**
-     * PUT a file to the FTP server
+     * Issues the {@code MDTM [path]} command to the server to get the modification
+     * time of a specific file on the server.
+     * Note that this command may not be supported by the server, in which
+     * case {@code null} will be returned.
      *
-     * @param   filename        name of the file to store
-     * @return  the <code>OutputStream</code> to write the file to
-     *
+     * @param path a {@code String} containing the pathname of the file.
+     * @return a {@code Date} representing the last modification time
+     *         or {@code null} if the server returned an error, which
+     *         can be checked with {@link #getLastReplyCode()}.
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public TelnetOutputStream put(String filename) throws IOException {
-        Socket s = openDataConnection("STOR " + filename);
-        TelnetOutputStream out = new TelnetOutputStream(s.getOutputStream(), binaryMode);
-        if (!binaryMode)
-            out.setStickyCRLF(true);
-        return out;
-    }
+    public abstract Date getLastModified(String path) throws FtpProtocolException, IOException;
 
     /**
-     * Append to a file on the FTP server
+     * Sets the parser used to handle the directory output to the specified
+     * one. By default the parser is set to one that can handle most FTP
+     * servers output (Unix base mostly). However it may be necessary for
+     * and application to provide its own parser due to some uncommon
+     * output format.
      *
-     * @param   filename        name of the file to append to
-     * @return  the <code>OutputStream</code> to write the file to
-     *
+     * @param p The {@code FtpDirParser} to use.
+     * @return this FtpClient
+     * @see #listFiles(String)
      */
-    public TelnetOutputStream append(String filename) throws IOException {
-        Socket s = openDataConnection("APPE " + filename);
-        TelnetOutputStream out = new TelnetOutputStream(s.getOutputStream(), binaryMode);
-        if (!binaryMode)
-            out.setStickyCRLF(true);
-
-        return out;
-    }
+    public abstract FtpClient setDirParser(FtpDirParser p);
 
     /**
-     * LIST files in the current directory on a remote FTP server
+     * Issues a {@code MLSD} command to the server to get the specified directory
+     * listing and applies the internal parser to create an Iterator of
+     * {@link java.net.FtpDirEntry}. Note that the Iterator returned is also a
+     * {@link java.io.Closeable}.
+     * <p>If the server doesn't support the MLSD command, the LIST command is used
+     * instead and the parser set by {@link #setDirParser(java.net.FtpDirParser) }
+     * is used instead.</p>
      *
-     * @return  the <code>InputStream</code> to read the list from
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is finished iterating through the files.
      *
+     * @param path the pathname of the directory to list or {@code null}
+     *        for the current working directoty.
+     * @return a {@code Iterator} of files or {@code null} if the
+     *         command failed.
+     * @throws IOException if an error occured during the transmission
+     * @see #setDirParser(FtpDirParser)
+     * @see #changeDirectory(String)
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public TelnetInputStream list() throws IOException {
-        Socket s = openDataConnection("LIST");
-
-        return new TelnetInputStream(s.getInputStream(), binaryMode);
-    }
+    public abstract Iterator<FtpDirEntry> listFiles(String path) throws FtpProtocolException, IOException;
 
     /**
-     * List (NLST) file names on a remote FTP server
+     * Attempts to use Kerberos GSSAPI as an authentication mechanism with the
+     * ftp server. This will issue an {@code AUTH GSSAPI} command, and if
+     * it is accepted by the server, will followup with {@code ADAT}
+     * command to exchange the various tokens until authentication is
+     * successful. This conforms to Appendix I of RFC 2228.
      *
-     * @param   path    pathname to the directory to list, null for current
-     *                  directory
-     * @return  the <code>InputStream</code> to read the list from
-     * @exception       <code>FtpProtocolException</code>
+     * @return this FtpClient
+     * @throws IOException if an error occurs during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public TelnetInputStream nameList(String path) throws IOException {
-        Socket s;
-
-        if (path != null)
-            s = openDataConnection("NLST " + path);
-        else
-            s = openDataConnection("NLST");
-        return new TelnetInputStream(s.getInputStream(), binaryMode);
-    }
+    public abstract FtpClient useKerberos() throws FtpProtocolException, IOException;
 
     /**
-     * CD to a specific directory on a remote FTP server
+     * Returns the Welcome string the server sent during initial connection.
      *
-     * @param   remoteDirectory path of the directory to CD to
-     *
-     * @exception       <code>FtpProtocolException</code>
+     * @return a {@code String} containing the message the server
+     *         returned during connection or {@code null}.
      */
-    public void cd(String remoteDirectory) throws IOException {
-        if (remoteDirectory == null ||
-            "".equals(remoteDirectory))
-            return;
-        issueCommandCheck("CWD " + remoteDirectory);
-    }
+    public abstract String getWelcomeMsg();
 
     /**
-     * CD to the parent directory on a remote FTP server
+     * Returns the last reply code sent by the server.
      *
+     * @return the lastReplyCode or {@code null} if none were received yet.
      */
-    public void cdUp() throws IOException {
-        issueCommandCheck("CDUP");
-    }
+    public abstract FtpReplyCode getLastReplyCode();
 
     /**
-     * Print working directory of remote FTP server
+     * Returns the last response string sent by the server.
      *
-     * @exception FtpProtocolException if the command fails
+     * @return the message string, which can be quite long, last returned
+     *         by the server, or {@code null} if no response were received yet.
      */
-    public String pwd() throws IOException {
-        String answ;
+    public abstract String getLastResponseString();
 
-        issueCommandCheck("PWD");
-        /*
-         * answer will be of the following format :
-         *
-         * 257 "/" is current directory.
-         */
-        answ = getResponseString();
-        if (!answ.startsWith("257"))
-            throw new FtpProtocolException("PWD failed. " + answ);
-        return answ.substring(5, answ.lastIndexOf('"'));
-    }
+    /**
+     * Returns, when available, the size of the latest started transfer.
+     * This is retreived by parsing the response string received as an initial
+     * response to a {@code RETR} or similar request.
+     *
+     * @return the size of the latest transfer or -1 if either there was no
+     *         transfer or the information was unavailable.
+     */
+    public abstract long getLastTransferSize();
 
     /**
-     * Set transfer type to 'I'
+     * Returns, when available, the remote name of the last transfered file.
+     * This is mainly useful for "put" operation when the unique flag was
+     * set since it allows to recover the unique file name created on the
+     * server which may be different from the one submitted with the command.
      *
-     * @exception FtpProtocolException if the command fails
+     * @return the name the latest transfered file remote name, or
+     *         {@code null} if that information is unavailable.
      */
-    public void binary() throws IOException {
-        issueCommandCheck("TYPE I");
-        binaryMode = true;
-    }
+    public abstract String getLastFileName();
 
     /**
-     * Set transfer type to 'A'
+     * Attempts to switch to a secure, encrypted connection. This is done by
+     * sending the {@code AUTH TLS} command.
+     * <p>See <a href="http://www.ietf.org/rfc/rfc4217.txt">RFC 4217</a></p>
+     * If successful this will establish a secure command channel with the
+     * server, it will also make it so that all other transfers (e.g. a RETR
+     * command) will be done over an encrypted channel as well unless a
+     * {@link #reInit()} command or a {@link #endSecureSession()} command is issued.
+     * <p>This method should be called after a successful {@link #connect(java.net.InetSocketAddress) }
+     * but before calling {@link #login(java.lang.String, char[]) }.</p>
      *
-     * @exception FtpProtocolException if the command fails
+     * @return this FtpCLient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     * @see #endSecureSession()
      */
-    public void ascii() throws IOException {
-        issueCommandCheck("TYPE A");
-        binaryMode = false;
-    }
-
-    /**
-     * Rename a file on the ftp server
-     *
-     * @exception FtpProtocolException if the command fails
-     */
-    public void rename(String from, String to) throws IOException {
-        issueCommandCheck("RNFR " + from);
-        issueCommandCheck("RNTO " + to);
-    }
+    public abstract FtpClient startSecureSession() throws FtpProtocolException, IOException;
 
     /**
-     * Get the "System string" from the FTP server
+     * Sends a {@code CCC} command followed by a {@code PROT C}
+     * command to the server terminating an encrypted session and reverting
+     * back to a non encrypted transmission.
      *
-     * @exception       FtpProtocolException if it fails
+     * @return this FtpClient
+     * @throws IOException if an error occured during transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
+     * @see #startSecureSession()
      */
-    public String system() throws IOException {
-        String answ;
-        issueCommandCheck("SYST");
-        answ = getResponseString();
-        if (!answ.startsWith("215"))
-            throw new FtpProtocolException("SYST failed." + answ);
-        return answ.substring(4); // Skip "215 "
-    }
+    public abstract FtpClient endSecureSession() throws FtpProtocolException, IOException;
 
     /**
-     * Send a No-operation command. It's usefull for testing the connection status
+     * Sends the "Allocate" ({@code ALLO}) command to the server telling it to
+     * pre-allocate the specified number of bytes for the next transfer.
      *
-     * @exception FtpProtocolException if the command fails
+     * @param size The number of bytes to allocate.
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public void noop() throws IOException {
-        issueCommandCheck("NOOP");
-    }
+    public abstract FtpClient allocate(long size) throws FtpProtocolException, IOException;
 
     /**
-     * Reinitialize the USER parameters on the FTp server
+     * Sends the "Structure Mount" ({@code SMNT}) command to the server. This let the
+     * user mount a different file system data structure without altering his
+     * login or accounting information.
      *
-     * @exception FtpProtocolException if the command fails
+     * @param struct a {@code String} containing the name of the
+     *        structure to mount.
+     * @return this FtpClient
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public void reInit() throws IOException {
-        issueCommandCheck("REIN");
-        loggedIn = false;
-    }
+    public abstract FtpClient structureMount(String struct) throws FtpProtocolException, IOException;
 
     /**
-     * New FTP client connected to host <i>host</i>.
-     *
-     * @param   host    Hostname of the FTP server
+     * Sends a System ({@code SYST}) command to the server and returns the String
+     * sent back by the server describing the operating system at the
+     * server.
      *
-     * @exception FtpProtocolException if the connection fails
+     * @return a {@code String} describing the OS, or {@code null}
+     *         if the operation was not successful.
+     * @throws IOException if an error occured during the transmission.
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public FtpClient(String host) throws IOException {
-        super();
-        openServer(host, FTP_PORT);
-    }
+    public abstract String getSystem() throws FtpProtocolException, IOException;
 
     /**
-     * New FTP client connected to host <i>host</i>, port <i>port</i>.
+     * Sends the {@code HELP} command to the server, with an optional command, like
+     * SITE, and returns the text sent back by the server.
      *
-     * @param   host    Hostname of the FTP server
-     * @param   port    port number to connect to (usually 21)
-     *
-     * @exception FtpProtocolException if the connection fails
+     * @param cmd the command for which the help is requested or
+     *        {@code null} for the general help
+     * @return a {@code String} containing the text sent back by the
+     *         server, or {@code null} if the command failed.
+     * @throws IOException if an error occured during transmission
+     * @throws FtpProtocolException if the command was rejected by the server
      */
-    public FtpClient(String host, int port) throws IOException {
-        super();
-        openServer(host, port);
-    }
-
-    /** Create an uninitialized FTP client. */
-    public FtpClient() {}
+    public abstract String getHelp(String cmd) throws FtpProtocolException, IOException;
 
-    public FtpClient(Proxy p) {
-        proxy = p;
-    }
-
-    protected void finalize() throws IOException {
-        /**
-         * Do not call the "normal" closeServer() as we want finalization
-         * to be as efficient as possible
-         */
-        if (serverIsOpen())
-            super.closeServer();
-    }
-
+    /**
+     * Sends the {@code SITE} command to the server. This is used by the server
+     * to provide services specific to his system that are essential
+     * to file transfer.
+     *
+     * @param cmd the command to be sent.
+     * @return this FtpClient
+     * @throws IOException if an error occured during transmission
+     * @throws FtpProtocolException if the command was rejected by the server
+     */
+    public abstract FtpClient siteCmd(String cmd) throws FtpProtocolException, IOException;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/ftp/FtpClientProvider.java	Wed Nov 25 11:08:25 2009 -0800
@@ -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 sun.net.ftp;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ServiceConfigurationError;
+//import sun.misc.Service;
+
+/**
+ * Service provider class for FtpClient.
+ * Sub-classes of FtpClientProvider provide an implementation of {@link FtpClient}
+ * and associated classes. Applications do not normally use this class directly.
+ * See {@link #provider() } for how providers are found and loaded.
+ *
+ * @since 1.7
+ */
+public abstract class FtpClientProvider {
+
+    /**
+     * Creates a FtpClient from this provider.
+     *
+     * @return The created {@link FtpClient}.
+     */
+    public abstract FtpClient createFtpClient();
+    private static final Object lock = new Object();
+    private static FtpClientProvider provider = null;
+
+    /**
+     * Initializes a new instance of this class.
+     *
+     * @throws SecurityException if a security manager is installed and it denies
+     *         {@link RuntimePermission}<tt>("ftpClientProvider")</tt>
+     */
+    protected FtpClientProvider() {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+            sm.checkPermission(new RuntimePermission("ftpClientProvider"));
+        }
+    }
+
+    private static boolean loadProviderFromProperty() {
+        String cm = System.getProperty("sun.net.ftpClientProvider");
+        if (cm == null) {
+            return false;
+        }
+        try {
+            Class c = Class.forName(cm, true, null);
+            provider = (FtpClientProvider) c.newInstance();
+            return true;
+        } catch (ClassNotFoundException x) {
+            throw new ServiceConfigurationError(x.toString());
+        } catch (IllegalAccessException x) {
+            throw new ServiceConfigurationError(x.toString());
+        } catch (InstantiationException x) {
+            throw new ServiceConfigurationError(x.toString());
+        } catch (SecurityException x) {
+            throw new ServiceConfigurationError(x.toString());
+        }
+    }
+
+    private static boolean loadProviderAsService() {
+        //        Iterator i = Service.providers(FtpClientProvider.class,
+        //                ClassLoader.getSystemClassLoader());
+        //        while (i.hasNext()) {
+        //            try {
+        //                provider = (FtpClientProvider) i.next();
+        //                return true;
+        //            } catch (ServiceConfigurationError sce) {
+        //                if (sce.getCause() instanceof SecurityException) {
+        //                    // Ignore, try next provider, if any
+        //                    continue;
+        //                }
+        //                throw sce;
+        //            }
+        //        }
+        return false;
+    }
+
+    /**
+     * Returns the system wide default FtpClientProvider for this invocation of
+     * the Java virtual machine.
+     *
+     * <p> The first invocation of this method locates the default provider
+     * object as follows: </p>
+     *
+     * <ol>
+     *
+     *   <li><p> If the system property
+     *   <tt>java.net.FtpClientProvider</tt> is defined then it is
+     *   taken to be the fully-qualified name of a concrete provider class.
+     *   The class is loaded and instantiated; if this process fails then an
+     *   unspecified unchecked error or exception is thrown.  </p></li>
+     *
+     *   <li><p> If a provider class has been installed in a jar file that is
+     *   visible to the system class loader, and that jar file contains a
+     *   provider-configuration file named
+     *   <tt>java.net.FtpClientProvider</tt> in the resource
+     *   directory <tt>META-INF/services</tt>, then the first class name
+     *   specified in that file is taken.  The class is loaded and
+     *   instantiated; if this process fails then an unspecified unchecked error or exception is
+     *   thrown.  </p></li>
+     *
+     *   <li><p> Finally, if no provider has been specified by any of the above
+     *   means then the system-default provider class is instantiated and the
+     *   result is returned.  </p></li>
+     *
+     * </ol>
+     *
+     * <p> Subsequent invocations of this method return the provider that was
+     * returned by the first invocation.  </p>
+     *
+     * @return  The system-wide default FtpClientProvider
+     */
+    public static FtpClientProvider provider() {
+        synchronized (lock) {
+            if (provider != null) {
+                return provider;
+            }
+            return (FtpClientProvider) AccessController.doPrivileged(
+                    new PrivilegedAction<Object>() {
+
+                        public Object run() {
+                            if (loadProviderFromProperty()) {
+                                return provider;
+                            }
+                            if (loadProviderAsService()) {
+                                return provider;
+                            }
+                            provider = new sun.net.ftp.impl.DefaultFtpClientProvider();
+                            return provider;
+                        }
+                    });
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/ftp/FtpDirEntry.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,331 @@
+/*
+ * 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 sun.net.ftp;
+
+import java.util.Date;
+import java.util.HashMap;
+
+/**
+ * A {@code FtpDirEntry} is a class agregating all the information that the FTP client
+ * can gather from the server by doing a {@code LST} (or {@code NLST}) command and
+ * parsing the output. It will typically contain the name, type, size, last modification
+ * time, owner and group of the file, although some of these could be unavailable
+ * due to specific FTP server limitations.
+ *
+ * @see sun.net.ftp.FtpDirParser
+ * @since 1.7
+ */
+public class FtpDirEntry {
+
+    public enum Type {
+
+        FILE, DIR, PDIR, CDIR, LINK
+    };
+
+    public enum Permission {
+
+        USER(0), GROUP(1), OTHERS(2);
+        int value;
+
+        Permission(int v) {
+            value = v;
+        }
+    };
+    private final String name;
+    private String user = null;
+    private String group = null;
+    private long size = -1;
+    private java.util.Date created = null;
+    private java.util.Date lastModified = null;
+    private Type type = Type.FILE;
+    private boolean[][] permissions = null;
+    private HashMap<String, String> facts = new HashMap<String, String>();
+
+    private FtpDirEntry() {
+        name = null;
+    }
+
+    /**
+     * Creates an FtpDirEntry instance with only the name being set.
+     *
+     * @param name The name of the file
+     */
+    public FtpDirEntry(String name) {
+        this.name = name;
+    }
+
+    /**
+     * Returns the name of the remote file.
+     *
+     * @return a {@code String} containing the name of the remote file.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * Returns the user name of the owner of the file as returned by the FTP
+     * server, if provided. This could be a name or a user id (number).
+     *
+     * @return a {@code String} containing the user name or
+     *         {@code null} if that information is not available.
+     */
+    public String getUser() {
+        return user;
+    }
+
+    /**
+     * Sets the user name of the owner of the file. Intended mostly to be
+     * used from inside a {@link java.net.FtpDirParser} implementation.
+     *
+     * @param user The user name of the owner of the file, or {@code null}
+     * if that information is not available.
+     * @return this FtpDirEntry
+     */
+    public FtpDirEntry setUser(String user) {
+        this.user = user;
+        return this;
+    }
+
+    /**
+     * Returns the group name of the file as returned by the FTP
+     * server, if provided. This could be a name or a group id (number).
+     *
+     * @return a {@code String} containing the group name or
+     *         {@code null} if that information is not available.
+     */
+    public String getGroup() {
+        return group;
+    }
+
+    /**
+     * Sets the name of the group to which the file belong. Intended mostly to be
+     * used from inside a {@link java.net.FtpDirParser} implementation.
+     *
+     * @param group The name of the group to which the file belong, or {@code null}
+     * if that information is not available.
+     * @return this FtpDirEntry
+     */
+    public FtpDirEntry setGroup(String group) {
+        this.group = group;
+        return this;
+    }
+
+    /**
+     * Returns the size of the remote file as it was returned by the FTP
+     * server, if provided.
+     *
+     * @return the size of the file or -1 if that information is not available.
+     */
+    public long getSize() {
+        return size;
+    }
+
+    /**
+     * Sets the size of that file. Intended mostly to be used from inside an
+     * {@link java.net.FtpDirParser} implementation.
+     *
+     * @param size The size, in bytes, of that file. or -1 if unknown.
+     * @return this FtpDirEntry
+     */
+    public FtpDirEntry setSize(long size) {
+        this.size = size;
+        return this;
+    }
+
+    /**
+     * Returns the type of the remote file as it was returned by the FTP
+     * server, if provided.
+     * It returns a FtpDirEntry.Type enum and the values can be:
+     * - FtpDirEntry.Type.FILE for a normal file
+     * - FtpDirEntry.Type.DIR for a directory
+     * - FtpDirEntry.Type.LINK for a symbolic link
+     *
+     * @return a {@code FtpDirEntry.Type} describing the type of the file
+     *         or {@code null} if that information is not available.
+     */
+    public Type getType() {
+        return type;
+    }
+
+    /**
+     * Sets the type of the file. Intended mostly to be used from inside an
+     * {@link java.net.FtpDirParser} implementation.
+     *
+     * @param type the type of this file or {@code null} if that information
+     * is not available.
+     * @return this FtpDirEntry
+     */
+    public FtpDirEntry setType(Type type) {
+        this.type = type;
+        return this;
+    }
+
+    /**
+     * Returns the last modification time of the remote file as it was returned
+     * by the FTP server, if provided, {@code null} otherwise.
+     *
+     * @return a <code>Date</code> representing the last time the file was
+     *         modified on the server, or {@code null} if that
+     *         information is not available.
+     */
+    public java.util.Date getLastModified() {
+        return this.lastModified;
+    }
+
+    /**
+     * Sets the last modification time of the file. Intended mostly to be used
+     * from inside an {@link java.net.FtpDirParser} implementation.
+     *
+     * @param lastModified The Date representing the last modification time, or
+     * {@code null} if that information is not available.
+     * @return this FtpDirEntry
+     */
+    public FtpDirEntry setLastModified(Date lastModified) {
+        this.lastModified = lastModified;
+        return this;
+    }
+
+    /**
+     * Returns whether read access is granted for a specific permission.
+     *
+     * @param p the Permission (user, group, others) to check.
+     * @return {@code true} if read access is granted.
+     */
+    public boolean canRead(Permission p) {
+        if (permissions != null) {
+            return permissions[p.value][0];
+        }
+        return false;
+    }
+
+    /**
+     * Returns whether write access is granted for a specific permission.
+     *
+     * @param p the Permission (user, group, others) to check.
+     * @return {@code true} if write access is granted.
+     */
+    public boolean canWrite(Permission p) {
+        if (permissions != null) {
+            return permissions[p.value][1];
+        }
+        return false;
+    }
+
+    /**
+     * Returns whether execute access is granted for a specific permission.
+     *
+     * @param p the Permission (user, group, others) to check.
+     * @return {@code true} if execute access is granted.
+     */
+    public boolean canExexcute(Permission p) {
+        if (permissions != null) {
+            return permissions[p.value][2];
+        }
+        return false;
+    }
+
+    /**
+     * Sets the permissions for that file. Intended mostly to be used
+     * from inside an {@link java.net.FtpDirParser} implementation.
+     * The permissions array is a 3x3 {@code boolean} array, the first index being
+     * the User, group or owner (0, 1 and 2 respectively) while the second
+     * index is read, write or execute (0, 1 and 2 respectively again).
+     * <p>E.G.: {@code permissions[1][2]} is the group/execute permission.</p>
+     *
+     * @param permissions a 3x3 {@code boolean} array
+     * @return this {@code FtpDirEntry}
+     */
+    public FtpDirEntry setPermissions(boolean[][] permissions) {
+        this.permissions = permissions;
+        return this;
+    }
+
+    /**
+     * Adds a 'fact', as defined in RFC 3659, to the list of facts of this file.
+     * Intended mostly to be used from inside a {@link java.net.FtpDirParser}
+     * implementation.
+     *
+     * @param fact the name of the fact (e.g. "Media-Type"). It is not case-sensitive.
+     * @param value the value associated with this fact.
+     * @return this {@code FtpDirEntry}
+     */
+    public FtpDirEntry addFact(String fact, String value) {
+        facts.put(fact.toLowerCase(), value);
+        return this;
+    }
+
+    /**
+     * Returns the requested 'fact', as defined in RFC 3659, if available.
+     *
+     * @param fact The name of the fact *e.g. "Media-Type"). It is not case sensitive.
+     * @return The value of the fact or, {@code null} if that fact wasn't
+     * provided by the server.
+     */
+    public String getFact(String fact) {
+        return facts.get(fact.toLowerCase());
+    }
+
+    /**
+     * Returns the creation time of the file, when provided by the server.
+     *
+     * @return The Date representing the creation time, or {@code null}
+     * if the server didn't provide that information.
+     */
+    public Date getCreated() {
+        return created;
+    }
+
+    /**
+     * Sets the creation time for that file. Intended mostly to be used from
+     * inside a {@link java.net.FtpDirParser} implementation.
+     *
+     * @param created the Date representing the creation time for that file, or
+     * {@code null} if that information is not available.
+     * @return this FtpDirEntry
+     */
+    public FtpDirEntry setCreated(Date created) {
+        this.created = created;
+        return this;
+    }
+
+    /**
+     * Returns a string representation of the object.
+     * The {@code toString} method for class {@code FtpDirEntry}
+     * returns a string consisting of the name of the file, followed by its
+     * type between brackets, followed by the user and group between
+     * parenthesis, then size between '{', and, finally, the lastModified of last
+     * modification if it's available.
+     *
+     * @return  a string representation of the object.
+     */
+    @Override
+    public String toString() {
+        if (lastModified == null) {
+            return name + " [" + type + "] (" + user + " / " + group + ") " + size;
+        }
+        return name + " [" + type + "] (" + user + " / " + group + ") {" + size + "} " + java.text.DateFormat.getDateInstance().format(lastModified);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/ftp/FtpDirParser.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,49 @@
+/*
+ * 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 sun.net.ftp;
+
+/**
+ * This interface describes a parser for the FtpClient class. Such a parser is
+ * used when listing a remote directory to transform text lines like:
+ *      drwxr-xr-x      1 user01      ftp   512 Jan 29 23:32 prog
+ * into FtpDirEntry instances.
+ *
+ * @see java.net.FtpClient#setFileParser(FtpDirParser)
+ * @since 1.7
+ */
+public interface FtpDirParser {
+
+    /**
+     * Takes one line from a directory listing and returns an FtpDirEntry instance
+     * based on the information contained.
+     *
+     * @param line a <code>String</code>, a line sent by the FTP server as a
+     *        result of the LST command.
+     * @return an <code>FtpDirEntry</code> instance.
+     * @see java.net.FtpDirEntry
+     */
+    public FtpDirEntry parseLine(String line);
+}
--- a/src/share/classes/sun/net/ftp/FtpLoginException.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/ftp/FtpLoginException.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1994-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1994-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
@@ -25,7 +25,7 @@
 
 package sun.net.ftp;
 
-import java.io.*;
+import java.io.IOException;
 
 /**
  * This exception is thrown when an error is encountered during an
@@ -33,10 +33,10 @@
  *
  * @author      Jonathan Payne
  */
-public class FtpLoginException extends FtpProtocolException {
+public class FtpLoginException extends IOException {
     private static final long serialVersionUID = 2218162403237941536L;
 
-    FtpLoginException(String s) {
+    public FtpLoginException(String s) {
         super(s);
     }
 }
--- a/src/share/classes/sun/net/ftp/FtpProtocolException.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/ftp/FtpProtocolException.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1994-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1994-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
@@ -22,21 +22,49 @@
  * CA 95054 USA or visit www.sun.com if you need additional information or
  * have any questions.
  */
-
 package sun.net.ftp;
 
-import java.io.*;
-
 /**
- * This exeception is thrown when unexpected results are returned during
- * an FTP session.
- *
+ * Thrown to indicate that the FTP server reported an error.
+ * For instance that the requested file doesn't exist or
+ * that a command isn't supported.
+ * <p>The specific error code can be retreived with {@link #getReplyCode() }.</p>
  * @author      Jonathan Payne
  */
-public class FtpProtocolException extends IOException {
+public class FtpProtocolException extends Exception {
     private static final long serialVersionUID = 5978077070276545054L;
+    private final FtpReplyCode code;
+
+    /**
+     * Constructs a new {@code FtpProtocolException} from the
+     * specified detail message. The reply code is set to unknow error.
+     *
+     * @param   detail   the detail message.
+     */
+    public FtpProtocolException(String detail) {
+            super(detail);
+            code = FtpReplyCode.UNKNOWN_ERROR;
+    }
 
-    FtpProtocolException(String s) {
-        super(s);
+    /**
+     * Constructs a new {@code FtpProtocolException} from the
+     * specified response code and exception detail message
+     *
+     * @param   detail   the detail message.
+     * @param   code The {@code FtpRelyCode} received from server.
+     */
+      public FtpProtocolException(String detail, FtpReplyCode code) {
+        super(detail);
+        this.code = code;
+    }
+
+    /**
+     * Gets the reply code sent by the server that led to this exception
+     * being thrown.
+     *
+     * @return The {@link FtpReplyCode} associated with that exception.
+     */
+    public FtpReplyCode getReplyCode() {
+        return code;
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/ftp/FtpReplyCode.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,248 @@
+/*
+ * 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 sun.net.ftp;
+
+/**
+ * This class describes a FTP protocol reply code and associates a meaning
+ * to the numerical value according to the various RFCs (RFC 959 in
+ * particular).
+ *
+ */
+public enum FtpReplyCode {
+
+    RESTART_MARKER(110),
+    SERVICE_READY_IN(120),
+    DATA_CONNECTION_ALREADY_OPEN(125),
+    FILE_STATUS_OK(150),
+    COMMAND_OK(200),
+    NOT_IMPLEMENTED(202),
+    SYSTEM_STATUS(211),
+    DIRECTORY_STATUS(212),
+    FILE_STATUS(213),
+    HELP_MESSAGE(214),
+    NAME_SYSTEM_TYPE(215),
+    SERVICE_READY(220),
+    SERVICE_CLOSING(221),
+    DATA_CONNECTION_OPEN(225),
+    CLOSING_DATA_CONNECTION(226),
+    ENTERING_PASSIVE_MODE(227),
+    ENTERING_EXT_PASSIVE_MODE(229),
+    LOGGED_IN(230),
+    SECURELY_LOGGED_IN(232),
+    SECURITY_EXCHANGE_OK(234),
+    SECURITY_EXCHANGE_COMPLETE(235),
+    FILE_ACTION_OK(250),
+    PATHNAME_CREATED(257),
+    NEED_PASSWORD(331),
+    NEED_ACCOUNT(332),
+    NEED_ADAT(334),
+    NEED_MORE_ADAT(335),
+    FILE_ACTION_PENDING(350),
+    SERVICE_NOT_AVAILABLE(421),
+    CANT_OPEN_DATA_CONNECTION(425),
+    CONNECTION_CLOSED(426),
+    NEED_SECURITY_RESOURCE(431),
+    FILE_ACTION_NOT_TAKEN(450),
+    ACTION_ABORTED(451),
+    INSUFFICIENT_STORAGE(452),
+    COMMAND_UNRECOGNIZED(500),
+    INVALID_PARAMETER(501),
+    BAD_SEQUENCE(503),
+    NOT_IMPLEMENTED_FOR_PARAMETER(504),
+    NOT_LOGGED_IN(530),
+    NEED_ACCOUNT_FOR_STORING(532),
+    PROT_LEVEL_DENIED(533),
+    REQUEST_DENIED(534),
+    FAILED_SECURITY_CHECK(535),
+    UNSUPPORTED_PROT_LEVEL(536),
+    PROT_LEVEL_NOT_SUPPORTED_BY_SECURITY(537),
+    FILE_UNAVAILABLE(550),
+    PAGE_TYPE_UNKNOWN(551),
+    EXCEEDED_STORAGE(552),
+    FILE_NAME_NOT_ALLOWED(553),
+    PROTECTED_REPLY(631),
+    UNKNOWN_ERROR(999);
+    private final int value;
+
+    FtpReplyCode(int val) {
+        this.value = val;
+    }
+
+    /**
+     * Returns the numerical value of the code.
+     *
+     * @return the numerical value.
+     */
+    public int getValue() {
+        return value;
+    }
+
+    /**
+     * Determines if the code is a Positive Preliminary response.
+     * This means beginning with a 1 (which means a value between 100 and 199)
+     *
+     * @return <code>true</code> if the reply code is a positive preliminary
+     *         response.
+     */
+    public boolean isPositivePreliminary() {
+        return value >= 100 && value < 200;
+    }
+
+    /**
+     * Determines if the code is a Positive Completion response.
+     * This means beginning with a 2 (which means a value between 200 and 299)
+     *
+     * @return <code>true</code> if the reply code is a positive completion
+     *         response.
+     */
+    public boolean isPositiveCompletion() {
+        return value >= 200 && value < 300;
+    }
+
+    /**
+     * Determines if the code is a positive internediate response.
+     * This means beginning with a 3 (which means a value between 300 and 399)
+     *
+     * @return <code>true</code> if the reply code is a positive intermediate
+     *         response.
+     */
+    public boolean isPositiveIntermediate() {
+        return value >= 300 && value < 400;
+    }
+
+    /**
+     * Determines if the code is a transient negative response.
+     * This means beginning with a 4 (which means a value between 400 and 499)
+     *
+     * @return <code>true</code> if the reply code is a transient negative
+     *         response.
+     */
+    public boolean isTransientNegative() {
+        return value >= 400 && value < 500;
+    }
+
+    /**
+     * Determines if the code is a permanent negative response.
+     * This means beginning with a 5 (which means a value between 500 and 599)
+     *
+     * @return <code>true</code> if the reply code is a permanent negative
+     *         response.
+     */
+    public boolean isPermanentNegative() {
+        return value >= 500 && value < 600;
+    }
+
+    /**
+     * Determines if the code is a protected reply response.
+     * This means beginning with a 6 (which means a value between 600 and 699)
+     *
+     * @return <code>true</code> if the reply code is a protected reply
+     *         response.
+     */
+    public boolean isProtectedReply() {
+        return value >= 600 && value < 700;
+    }
+
+    /**
+     * Determines if the code is a syntax related response.
+     * This means the second digit is a 0.
+     *
+     * @return <code>true</code> if the reply code is a syntax related
+     *         response.
+     */
+    public boolean isSyntax() {
+        return ((value / 10) - ((value / 100) * 10)) == 0;
+    }
+
+    /**
+     * Determines if the code is an information related response.
+     * This means the second digit is a 1.
+     *
+     * @return <code>true</code> if the reply code is an information related
+     *         response.
+     */
+    public boolean isInformation() {
+        return ((value / 10) - ((value / 100) * 10)) == 1;
+    }
+
+    /**
+     * Determines if the code is a connection related response.
+     * This means the second digit is a 2.
+     *
+     * @return <code>true</code> if the reply code is a connection related
+     *         response.
+     */
+    public boolean isConnection() {
+        return ((value / 10) - ((value / 100) * 10)) == 2;
+    }
+
+    /**
+     * Determines if the code is an authentication related response.
+     * This means the second digit is a 3.
+     *
+     * @return <code>true</code> if the reply code is an authentication related
+     *         response.
+     */
+    public boolean isAuthentication() {
+        return ((value / 10) - ((value / 100) * 10)) == 3;
+    }
+
+    /**
+     * Determines if the code is an unspecified type of response.
+     * This means the second digit is a 4.
+     *
+     * @return <code>true</code> if the reply code is an unspecified type of
+     *         response.
+     */
+    public boolean isUnspecified() {
+        return ((value / 10) - ((value / 100) * 10)) == 4;
+    }
+
+    /**
+     * Determines if the code is a file system related response.
+     * This means the second digit is a 5.
+     *
+     * @return <code>true</code> if the reply code is a file system related
+     *         response.
+     */
+    public boolean isFileSystem() {
+        return ((value / 10) - ((value / 100) * 10)) == 5;
+    }
+
+    /**
+     * Static utility method to convert a value into a FtpReplyCode.
+     *
+     * @param v the value to convert
+     * @return the <code>FtpReplyCode</code> associated with the value.
+     */
+    public static FtpReplyCode find(int v) {
+        for (FtpReplyCode code : FtpReplyCode.values()) {
+            if (code.getValue() == v) {
+                return code;
+            }
+        }
+        return UNKNOWN_ERROR;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/ftp/impl/DefaultFtpClientProvider.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,38 @@
+/*
+ * 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 sun.net.ftp.impl;
+
+/**
+ * Default FtpClientProvider.
+ * Uses sun.net.ftp.FtpCLient.
+ */
+public class DefaultFtpClientProvider extends sun.net.ftp.FtpClientProvider {
+
+    @Override
+    public sun.net.ftp.FtpClient createFtpClient() {
+        return sun.net.ftp.impl.FtpClient.create();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/ftp/impl/FtpClient.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,2191 @@
+/*
+ * 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 sun.net.ftp.impl;
+
+import java.net.*;
+import java.io.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.TimeZone;
+import java.util.Vector;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+import sun.misc.BASE64Decoder;
+import sun.misc.BASE64Encoder;
+import sun.net.ftp.*;
+import sun.util.logging.PlatformLogger;
+
+
+public class FtpClient extends sun.net.ftp.FtpClient {
+
+    private static int defaultSoTimeout;
+    private static int defaultConnectTimeout;
+    private static final PlatformLogger logger =
+             PlatformLogger.getLogger("sun.net.ftp.FtpClient");
+    private Proxy proxy;
+    private Socket server;
+    private PrintStream out;
+    private InputStream in;
+    private int readTimeout = -1;
+    private int connectTimeout = -1;
+
+    /* Name of encoding to use for output */
+    private static String encoding = "ISO8859_1";
+    /** remember the ftp server name because we may need it */
+    private InetSocketAddress serverAddr;
+    private boolean replyPending = false;
+    private boolean loggedIn = false;
+    private boolean useCrypto = false;
+    private SSLSocketFactory sslFact;
+    private Socket oldSocket;
+    /** Array of strings (usually 1 entry) for the last reply from the server. */
+    private Vector<String> serverResponse = new Vector<String>(1);
+    /** The last reply code from the ftp daemon. */
+    private FtpReplyCode lastReplyCode = null;
+    /** Welcome message from the server, if any. */
+    private String welcomeMsg;
+    private boolean passiveMode = true;
+    private TransferType type = TransferType.BINARY;
+    private long restartOffset = 0;
+    private long lastTransSize = -1; // -1 means 'unknown size'
+    private String lastFileName;
+    /**
+     * Static members used by the parser
+     */
+    private static String[] patStrings = {
+        // drwxr-xr-x  1 user01        ftp   512 Jan 29 23:32 prog
+        "([\\-ld](?:[r\\-][w\\-][x\\-]){3})\\s*\\d+ (\\w+)\\s*(\\w+)\\s*(\\d+)\\s*([A-Z][a-z][a-z]\\s*\\d+)\\s*(\\d\\d:\\d\\d)\\s*(\\p{Print}*)",
+        // drwxr-xr-x  1 user01        ftp   512 Jan 29 1997 prog
+        "([\\-ld](?:[r\\-][w\\-][x\\-]){3})\\s*\\d+ (\\w+)\\s*(\\w+)\\s*(\\d+)\\s*([A-Z][a-z][a-z]\\s*\\d+)\\s*(\\d{4})\\s*(\\p{Print}*)",
+        // 04/28/2006  09:12a               3,563 genBuffer.sh
+        "(\\d{2}/\\d{2}/\\d{4})\\s*(\\d{2}:\\d{2}[ap])\\s*((?:[0-9,]+)|(?:<DIR>))\\s*(\\p{Graph}*)",
+        // 01-29-97    11:32PM <DIR> prog
+        "(\\d{2}-\\d{2}-\\d{2})\\s*(\\d{2}:\\d{2}[AP]M)\\s*((?:[0-9,]+)|(?:<DIR>))\\s*(\\p{Graph}*)"
+    };
+    private static int[][] patternGroups = {
+        // 0 - file, 1 - size, 2 - date, 3 - time, 4 - year, 5 - permissions,
+        // 6 - user, 7 - group
+        {7, 4, 5, 6, 0, 1, 2, 3},
+        {7, 4, 5, 0, 6, 1, 2, 3},
+        {4, 3, 1, 2, 0, 0, 0, 0},
+        {4, 3, 1, 2, 0, 0, 0, 0}};
+    private static Pattern[] patterns;
+    private static Pattern linkp = Pattern.compile("(\\p{Print}+) \\-\\> (\\p{Print}+)$");
+    private DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, java.util.Locale.US);
+
+    static {
+        final int vals[] = {0, 0};
+        final String encs[] = {null};
+
+        AccessController.doPrivileged(
+                new PrivilegedAction<Object>() {
+
+                    public Object run() {
+                        vals[0] = Integer.getInteger("sun.net.client.defaultReadTimeout", 0).intValue();
+                        vals[1] = Integer.getInteger("sun.net.client.defaultConnectTimeout", 0).intValue();
+                        encs[0] = System.getProperty("file.encoding", "ISO8859_1");
+                        return null;
+                    }
+                });
+        if (vals[0] == 0) {
+            defaultSoTimeout = -1;
+        } else {
+            defaultSoTimeout = vals[0];
+        }
+
+        if (vals[1] == 0) {
+            defaultConnectTimeout = -1;
+        } else {
+            defaultConnectTimeout = vals[1];
+        }
+
+        encoding = encs[0];
+        try {
+            if (!isASCIISuperset(encoding)) {
+                encoding = "ISO8859_1";
+            }
+        } catch (Exception e) {
+            encoding = "ISO8859_1";
+        }
+
+        patterns = new Pattern[patStrings.length];
+        for (int i = 0; i < patStrings.length; i++) {
+            patterns[i] = Pattern.compile(patStrings[i]);
+        }
+    }
+
+    /**
+     * Test the named character encoding to verify that it converts ASCII
+     * characters correctly. We have to use an ASCII based encoding, or else
+     * the NetworkClients will not work correctly in EBCDIC based systems.
+     * However, we cannot just use ASCII or ISO8859_1 universally, because in
+     * Asian locales, non-ASCII characters may be embedded in otherwise
+     * ASCII based protocols (eg. HTTP). The specifications (RFC2616, 2398)
+     * are a little ambiguous in this matter. For instance, RFC2398 [part 2.1]
+     * says that the HTTP request URI should be escaped using a defined
+     * mechanism, but there is no way to specify in the escaped string what
+     * the original character set is. It is not correct to assume that
+     * UTF-8 is always used (as in URLs in HTML 4.0).  For this reason,
+     * until the specifications are updated to deal with this issue more
+     * comprehensively, and more importantly, HTTP servers are known to
+     * support these mechanisms, we will maintain the current behavior
+     * where it is possible to send non-ASCII characters in their original
+     * unescaped form.
+     */
+    private static boolean isASCIISuperset(String encoding) throws Exception {
+        String chkS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
+                "abcdefghijklmnopqrstuvwxyz-_.!~*'();/?:@&=+$,";
+
+        // Expected byte sequence for string above
+        byte[] chkB = {48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72,
+            73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99,
+            100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
+            115, 116, 117, 118, 119, 120, 121, 122, 45, 95, 46, 33, 126, 42, 39, 40, 41, 59,
+            47, 63, 58, 64, 38, 61, 43, 36, 44};
+
+        byte[] b = chkS.getBytes(encoding);
+        return java.util.Arrays.equals(b, chkB);
+    }
+
+    private class DefaultParser implements FtpDirParser {
+
+        /**
+         * Possible patterns:
+         *
+         *  drwxr-xr-x  1 user01        ftp   512 Jan 29 23:32 prog
+         *  drwxr-xr-x  1 user01        ftp   512 Jan 29 1997 prog
+         *  drwxr-xr-x  1 1             1     512 Jan 29 23:32 prog
+         *  lrwxr-xr-x  1 user01        ftp   512 Jan 29 23:32 prog -> prog2000
+         *  drwxr-xr-x  1 username      ftp   512 Jan 29 23:32 prog
+         *  -rw-r--r--  1 jcc      staff     105009 Feb  3 15:05 test.1
+         *
+         *  01-29-97    11:32PM <DIR> prog
+         *  04/28/2006  09:12a               3,563 genBuffer.sh
+         *
+         *  drwxr-xr-x  folder   0       Jan 29 23:32 prog
+         *
+         *  0 DIR 01-29-97 23:32 PROG
+         */
+        private DefaultParser() {
+        }
+
+        public FtpDirEntry parseLine(String line) {
+            String fdate = null;
+            String fsize = null;
+            String time = null;
+            String filename = null;
+            String permstring = null;
+            String username = null;
+            String groupname = null;
+            boolean dir = false;
+            Calendar now = Calendar.getInstance();
+            int year = now.get(Calendar.YEAR);
+
+            Matcher m = null;
+            for (int j = 0; j < patterns.length; j++) {
+                m = patterns[j].matcher(line);
+                if (m.find()) {
+                    // 0 - file, 1 - size, 2 - date, 3 - time, 4 - year,
+                    // 5 - permissions, 6 - user, 7 - group
+                    filename = m.group(patternGroups[j][0]);
+                    fsize = m.group(patternGroups[j][1]);
+                    fdate = m.group(patternGroups[j][2]);
+                    if (patternGroups[j][4] > 0) {
+                        fdate += (", " + m.group(patternGroups[j][4]));
+                    } else if (patternGroups[j][3] > 0) {
+                        fdate += (", " + String.valueOf(year));
+                    }
+                    if (patternGroups[j][3] > 0) {
+                        time = m.group(patternGroups[j][3]);
+                    }
+                    if (patternGroups[j][5] > 0) {
+                        permstring = m.group(patternGroups[j][5]);
+                        dir = permstring.startsWith("d");
+                    }
+                    if (patternGroups[j][6] > 0) {
+                        username = m.group(patternGroups[j][6]);
+                    }
+                    if (patternGroups[j][7] > 0) {
+                        groupname = m.group(patternGroups[j][7]);
+                    }
+                    // Old DOS format
+                    if ("<DIR>".equals(fsize)) {
+                        dir = true;
+                        fsize = null;
+                    }
+                }
+            }
+
+            if (filename != null) {
+                Date d;
+                try {
+                    d = df.parse(fdate);
+                } catch (Exception e) {
+                    d = null;
+                }
+                if (d != null && time != null) {
+                    int c = time.indexOf(":");
+                    now.setTime(d);
+                    now.set(Calendar.HOUR, Integer.parseInt(time.substring(0, c)));
+                    now.set(Calendar.MINUTE, Integer.parseInt(time.substring(c + 1)));
+                    d = now.getTime();
+                }
+                // see if it's a symbolic link, i.e. the name if followed
+                // by a -> and a path
+                Matcher m2 = linkp.matcher(filename);
+                if (m2.find()) {
+                    // Keep only the name then
+                    filename = m2.group(1);
+                }
+                boolean[][] perms = new boolean[3][3];
+                for (int i = 0; i < 3; i++) {
+                    for (int j = 0; j < 3; j++) {
+                        perms[i][j] = (permstring.charAt((i * 3) + j) != '-');
+                    }
+                }
+                FtpDirEntry file = new FtpDirEntry(filename);
+                file.setUser(username).setGroup(groupname);
+                file.setSize(Long.parseLong(fsize)).setLastModified(d);
+                file.setPermissions(perms);
+                file.setType(dir ? FtpDirEntry.Type.DIR : (line.charAt(0) == 'l' ? FtpDirEntry.Type.LINK : FtpDirEntry.Type.FILE));
+                return file;
+            }
+            return null;
+        }
+    }
+
+    private class MLSxParser implements FtpDirParser {
+
+        private SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmmss");
+
+        public FtpDirEntry parseLine(String line) {
+            String name = null;
+            int i = line.lastIndexOf(";");
+            if (i > 0) {
+                name = line.substring(i + 1).trim();
+                line = line.substring(0, i);
+            } else {
+                name = line.trim();
+                line = "";
+            }
+            FtpDirEntry file = new FtpDirEntry(name);
+            while (!line.isEmpty()) {
+                String s;
+                i = line.indexOf(";");
+                if (i > 0) {
+                    s = line.substring(0, i);
+                    line = line.substring(i + 1);
+                } else {
+                    s = line;
+                    line = "";
+                }
+                i = s.indexOf("=");
+                if (i > 0) {
+                    String fact = s.substring(0, i);
+                    String value = s.substring(i + 1);
+                    file.addFact(fact, value);
+                }
+            }
+            String s = file.getFact("Size");
+            if (s != null) {
+                file.setSize(Long.parseLong(s));
+            }
+            s = file.getFact("Modify");
+            if (s != null) {
+                Date d = null;
+                try {
+                    d = df.parse(s);
+                } catch (ParseException ex) {
+                }
+                if (d != null) {
+                    file.setLastModified(d);
+                }
+            }
+            s = file.getFact("Create");
+            if (s != null) {
+                Date d = null;
+                try {
+                    d = df.parse(s);
+                } catch (ParseException ex) {
+                }
+                if (d != null) {
+                    file.setCreated(d);
+                }
+            }
+            s = file.getFact("Type");
+            if (s != null) {
+                if (s.equalsIgnoreCase("file")) {
+                    file.setType(FtpDirEntry.Type.FILE);
+                }
+                if (s.equalsIgnoreCase("dir")) {
+                    file.setType(FtpDirEntry.Type.DIR);
+                }
+                if (s.equalsIgnoreCase("cdir")) {
+                    file.setType(FtpDirEntry.Type.CDIR);
+                }
+                if (s.equalsIgnoreCase("pdir")) {
+                    file.setType(FtpDirEntry.Type.PDIR);
+                }
+            }
+            return file;
+        }
+    };
+    private FtpDirParser parser = new DefaultParser();
+    private FtpDirParser mlsxParser = new MLSxParser();
+    private static Pattern transPat = null;
+
+    private void getTransferSize() {
+        lastTransSize = -1;
+        /**
+         * If it's a start of data transfer response, let's try to extract
+         * the size from the response string. Usually it looks like that:
+         *
+         * 150 Opening BINARY mode data connection for foo (6701 bytes).
+         */
+        String response = getLastResponseString();
+        if (transPat == null) {
+            transPat = Pattern.compile("150 Opening .*\\((\\d+) bytes\\).");
+        }
+        Matcher m = transPat.matcher(response);
+        if (m.find()) {
+            String s = m.group(1);
+            lastTransSize = Long.parseLong(s);
+        }
+    }
+
+    /**
+     * extract the created file name from the response string:
+     * 226 Transfer complete (unique file name:toto.txt.1).
+     * Usually happens when a STOU (store unique) command had been issued.
+     */
+    private void getTransferName() {
+        lastFileName = null;
+        String response = getLastResponseString();
+        int i = response.indexOf("unique file name:");
+        int e = response.lastIndexOf(')');
+        if (i >= 0) {
+            i += 17; // Length of "unique file name:"
+            lastFileName = response.substring(i, e);
+        }
+    }
+
+    /**
+     * Pulls the response from the server and returns the code as a
+     * number. Returns -1 on failure.
+     */
+    private int readServerResponse() throws IOException {
+        StringBuffer replyBuf = new StringBuffer(32);
+        int c;
+        int continuingCode = -1;
+        int code;
+        String response;
+
+        serverResponse.setSize(0);
+        while (true) {
+            while ((c = in.read()) != -1) {
+                if (c == '\r') {
+                    if ((c = in.read()) != '\n') {
+                        replyBuf.append('\r');
+                    }
+                }
+                replyBuf.append((char) c);
+                if (c == '\n') {
+                    break;
+                }
+            }
+            response = replyBuf.toString();
+            replyBuf.setLength(0);
+            if (logger.isLoggable(PlatformLogger.FINEST)) {
+                logger.finest("Server [" + serverAddr + "] --> " + response);
+            }
+
+            if (response.length() == 0) {
+                code = -1;
+            } else {
+                try {
+                    code = Integer.parseInt(response.substring(0, 3));
+                } catch (NumberFormatException e) {
+                    code = -1;
+                } catch (StringIndexOutOfBoundsException e) {
+                    /* this line doesn't contain a response code, so
+                    we just completely ignore it */
+                    continue;
+                }
+            }
+            serverResponse.addElement(response);
+            if (continuingCode != -1) {
+                /* we've seen a ###- sequence */
+                if (code != continuingCode ||
+                        (response.length() >= 4 && response.charAt(3) == '-')) {
+                    continue;
+                } else {
+                    /* seen the end of code sequence */
+                    continuingCode = -1;
+                    break;
+                }
+            } else if (response.length() >= 4 && response.charAt(3) == '-') {
+                continuingCode = code;
+                continue;
+            } else {
+                break;
+            }
+        }
+
+        return code;
+    }
+
+    /** Sends command <i>cmd</i> to the server. */
+    private void sendServer(String cmd) {
+        out.print(cmd);
+        if (logger.isLoggable(PlatformLogger.FINEST)) {
+            logger.finest("Server [" + serverAddr + "] <-- " + cmd);
+        }
+    }
+
+    /** converts the server response into a string. */
+    private String getResponseString() {
+        return serverResponse.elementAt(0);
+    }
+
+    /** Returns all server response strings. */
+    private Vector<String> getResponseStrings() {
+        return serverResponse;
+    }
+
+    /**
+     * Read the reply from the FTP server.
+     *
+     * @return <code>true</code> if the command was successful
+     * @throws IOException if an error occured
+     */
+    private boolean readReply() throws IOException {
+        lastReplyCode = FtpReplyCode.find(readServerResponse());
+
+        if (lastReplyCode.isPositivePreliminary()) {
+            replyPending = true;
+            return true;
+        }
+        if (lastReplyCode.isPositiveCompletion() || lastReplyCode.isPositiveIntermediate()) {
+            if (lastReplyCode == FtpReplyCode.CLOSING_DATA_CONNECTION) {
+                getTransferName();
+            }
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Sends a command to the FTP server and returns the error code
+     * (which can be a "success") sent by the server.
+     *
+     * @param cmd
+     * @return <code>true</code> if the command was successful
+     * @throws IOException
+     */
+    private boolean issueCommand(String cmd) throws IOException {
+        if (!isConnected()) {
+            throw new IllegalStateException("Not connected");
+        }
+        if (replyPending) {
+            try {
+                completePending();
+            } catch (sun.net.ftp.FtpProtocolException e) {
+                // ignore...
+            }
+        }
+        sendServer(cmd + "\r\n");
+        return readReply();
+    }
+
+    /**
+     * Send a command to the FTP server and check for success.
+     *
+     * @param cmd String containing the command
+     *
+     * @throws FtpProtocolException if an error occured
+     */
+    private void issueCommandCheck(String cmd) throws sun.net.ftp.FtpProtocolException, IOException {
+        if (!issueCommand(cmd)) {
+            throw new sun.net.ftp.FtpProtocolException(cmd + ":" + getResponseString(), getLastReplyCode());
+        }
+    }
+    private static Pattern epsvPat = null;
+    private static Pattern pasvPat = null;
+
+    /**
+     * Opens a "PASSIVE" connection with the server and returns the connected
+     * <code>Socket</code>.
+     *
+     * @return the connected <code>Socket</code>
+     * @throws IOException if the connection was unsuccessful.
+     */
+    private Socket openPassiveDataConnection(String cmd) throws sun.net.ftp.FtpProtocolException, IOException {
+        String serverAnswer;
+        int port;
+        InetSocketAddress dest = null;
+
+        /**
+         * Here is the idea:
+         *
+         * - First we want to try the new (and IPv6 compatible) EPSV command
+         *   But since we want to be nice with NAT software, we'll issue the
+         *   EPSV ALL command first.
+         *   EPSV is documented in RFC2428
+         * - If EPSV fails, then we fall back to the older, yet ok, PASV
+         * - If PASV fails as well, then we throw an exception and the calling
+         *   method will have to try the EPRT or PORT command
+         */
+        if (issueCommand("EPSV ALL")) {
+            // We can safely use EPSV commands
+            issueCommandCheck("EPSV");
+            serverAnswer = getResponseString();
+
+            // The response string from a EPSV command will contain the port number
+            // the format will be :
+            //  229 Entering Extended PASSIVE Mode (|||58210|)
+            //
+            // So we'll use the regular expresions package to parse the output.
+
+            if (epsvPat == null) {
+                epsvPat = Pattern.compile("^229 .* \\(\\|\\|\\|(\\d+)\\|\\)");
+            }
+            Matcher m = epsvPat.matcher(serverAnswer);
+            if (!m.find()) {
+                throw new sun.net.ftp.FtpProtocolException("EPSV failed : " + serverAnswer);
+            }
+            // Yay! Let's extract the port number
+            String s = m.group(1);
+            port = Integer.parseInt(s);
+            InetAddress add = server.getInetAddress();
+            if (add != null) {
+                dest = new InetSocketAddress(add, port);
+            } else {
+                // This means we used an Unresolved address to connect in
+                // the first place. Most likely because the proxy is doing
+                // the name resolution for us, so let's keep using unresolved
+                // address.
+                dest = InetSocketAddress.createUnresolved(serverAddr.getHostName(), port);
+            }
+        } else {
+            // EPSV ALL failed, so Let's try the regular PASV cmd
+            issueCommandCheck("PASV");
+            serverAnswer = getResponseString();
+
+            // Let's parse the response String to get the IP & port to connect
+            // to. The String should be in the following format :
+            //
+            // 227 Entering PASSIVE Mode (A1,A2,A3,A4,p1,p2)
+            //
+            // Note that the two parenthesis are optional
+            //
+            // The IP address is A1.A2.A3.A4 and the port is p1 * 256 + p2
+            //
+            // The regular expression is a bit more complex this time, because
+            // the parenthesis are optionals and we have to use 3 groups.
+
+            if (pasvPat == null) {
+                pasvPat = Pattern.compile("227 .* \\(?(\\d{1,3},\\d{1,3},\\d{1,3},\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)?");
+            }
+            Matcher m = pasvPat.matcher(serverAnswer);
+            if (!m.find()) {
+                throw new sun.net.ftp.FtpProtocolException("PASV failed : " + serverAnswer);
+            }
+            // Get port number out of group 2 & 3
+            port = Integer.parseInt(m.group(3)) + (Integer.parseInt(m.group(2)) << 8);
+            // IP address is simple
+            String s = m.group(1).replace(',', '.');
+            dest = new InetSocketAddress(s, port);
+        }
+        // Got everything, let's open the socket!
+        Socket s;
+        if (proxy != null) {
+            if (proxy.type() == Proxy.Type.SOCKS) {
+                s = AccessController.doPrivileged(
+                        new PrivilegedAction<Socket>() {
+
+                            public Socket run() {
+                                return new Socket(proxy);
+                            }
+                        });
+            } else {
+                s = new Socket(Proxy.NO_PROXY);
+            }
+        } else {
+            s = new Socket();
+        }
+        // Bind the socket to the same address as the control channel. This
+        // is needed in case of multi-homed systems.
+        s.bind(new InetSocketAddress(server.getLocalAddress(), 0));
+        if (connectTimeout >= 0) {
+            s.connect(dest, connectTimeout);
+        } else {
+            if (defaultConnectTimeout > 0) {
+                s.connect(dest, defaultConnectTimeout);
+            } else {
+                s.connect(dest);
+            }
+        }
+        if (readTimeout >= 0) {
+            s.setSoTimeout(readTimeout);
+        } else if (defaultSoTimeout > 0) {
+            s.setSoTimeout(defaultSoTimeout);
+        }
+        if (useCrypto) {
+            try {
+                s = sslFact.createSocket(s, dest.getHostName(), dest.getPort(), true);
+            } catch (Exception e) {
+                throw new sun.net.ftp.FtpProtocolException("Can't open secure data channel: " + e);
+            }
+        }
+        if (!issueCommand(cmd)) {
+            s.close();
+            throw new sun.net.ftp.FtpProtocolException(cmd + ":" + getResponseString(), getLastReplyCode());
+        }
+        return s;
+    }
+
+    /**
+     * Opens a data connection with the server according to the set mode
+     * (ACTIVE or PASSIVE) then send the command passed as an argument.
+     *
+     * @param cmd the <code>String</code> containing the command to execute
+     * @return the connected <code>Socket</code>
+     * @throws IOException if the connection or command failed
+     */
+    private Socket openDataConnection(String cmd) throws sun.net.ftp.FtpProtocolException, IOException {
+        Socket clientSocket;
+
+        if (passiveMode) {
+            return openPassiveDataConnection(cmd);
+        }
+        ServerSocket portSocket;
+        InetAddress myAddress;
+        String portCmd;
+
+        if (proxy != null && proxy.type() == Proxy.Type.SOCKS) {
+            // We're behind a firewall and the passive mode fail,
+            // since we can't accept a connection through SOCKS (yet)
+            // throw an exception
+            throw new sun.net.ftp.FtpProtocolException("Passive mode failed");
+        }
+        // Bind the ServerSocket to the same address as the control channel
+        // This is needed for multi-homed systems
+        portSocket = new ServerSocket(0, 1, server.getLocalAddress());
+        try {
+            myAddress = portSocket.getInetAddress();
+            if (myAddress.isAnyLocalAddress()) {
+                myAddress = server.getLocalAddress();
+            }
+            // Let's try the new, IPv6 compatible EPRT command
+            // See RFC2428 for specifics
+            // Some FTP servers (like the one on Solaris) are bugged, they
+            // will accept the EPRT command but then, the subsequent command
+            // (e.g. RETR) will fail, so we have to check BOTH results (the
+            // EPRT cmd then the actual command) to decide wether we should
+            // fall back on the older PORT command.
+            portCmd = "EPRT |" + ((myAddress instanceof Inet6Address) ? "2" : "1") + "|" +
+                    myAddress.getHostAddress() + "|" + portSocket.getLocalPort() + "|";
+            if (!issueCommand(portCmd) || !issueCommand(cmd)) {
+                // The EPRT command failed, let's fall back to good old PORT
+                portCmd = "PORT ";
+                byte[] addr = myAddress.getAddress();
+
+                /* append host addr */
+                for (int i = 0; i < addr.length; i++) {
+                    portCmd = portCmd + (addr[i] & 0xFF) + ",";
+                }
+
+                /* append port number */
+                portCmd = portCmd + ((portSocket.getLocalPort() >>> 8) & 0xff) + "," + (portSocket.getLocalPort() & 0xff);
+                issueCommandCheck(portCmd);
+                issueCommandCheck(cmd);
+            }
+            // Either the EPRT or the PORT command was successful
+            // Let's create the client socket
+            if (connectTimeout >= 0) {
+                portSocket.setSoTimeout(connectTimeout);
+            } else {
+                if (defaultConnectTimeout > 0) {
+                    portSocket.setSoTimeout(defaultConnectTimeout);
+                }
+            }
+            clientSocket = portSocket.accept();
+            if (readTimeout >= 0) {
+                clientSocket.setSoTimeout(readTimeout);
+            } else {
+                if (defaultSoTimeout > 0) {
+                    clientSocket.setSoTimeout(defaultSoTimeout);
+                }
+            }
+        } finally {
+            portSocket.close();
+        }
+        if (useCrypto) {
+            try {
+                clientSocket = sslFact.createSocket(clientSocket, serverAddr.getHostName(), serverAddr.getPort(), true);
+            } catch (Exception ex) {
+                throw new IOException(ex.getLocalizedMessage());
+            }
+        }
+        return clientSocket;
+    }
+
+    private InputStream createInputStream(InputStream in) {
+        if (type == TransferType.ASCII) {
+            return new sun.net.TelnetInputStream(in, false);
+        }
+        return in;
+    }
+
+    private OutputStream createOutputStream(OutputStream out) {
+        if (type == TransferType.ASCII) {
+            return new sun.net.TelnetOutputStream(out, false);
+        }
+        return out;
+    }
+
+    /**
+     * Creates an instance of FtpClient. The client is not connected to any
+     * server yet.
+     *
+     */
+    protected FtpClient() {
+    }
+
+    /**
+     * Creates an instance of FtpClient. The client is not connected to any
+     * server yet.
+     *
+     */
+    public static sun.net.ftp.FtpClient create() {
+        return new FtpClient();
+    }
+
+    /**
+     * Set the transfer mode to <I>passive</I>. In that mode, data connections
+     * are established by having the client connect to the server.
+     * This is the recommended default mode as it will work best through
+     * firewalls and NATs.
+     *
+     * @return This FtpClient
+     * @see #setActiveMode()
+     */
+    public sun.net.ftp.FtpClient enablePassiveMode(boolean passive) {
+        passiveMode = passive;
+        return this;
+    }
+
+    /**
+     * Gets the current transfer mode.
+     *
+     * @return the current <code>FtpTransferMode</code>
+     */
+    public boolean isPassiveModeEnabled() {
+        return passiveMode;
+    }
+
+    /**
+     * Sets the timeout value to use when connecting to the server,
+     *
+     * @param timeout the timeout value, in milliseconds, to use for the connect
+     *        operation. A value of zero or less, means use the default timeout.
+     *
+     * @return This FtpClient
+     */
+    public sun.net.ftp.FtpClient setConnectTimeout(int timeout) {
+        connectTimeout = timeout;
+        return this;
+    }
+
+    /**
+     * Returns the current connection timeout value.
+     *
+     * @return the value, in milliseconds, of the current connect timeout.
+     * @see #setConnectTimeout(int)
+     */
+    public int getConnectTimeout() {
+        return connectTimeout;
+    }
+
+    /**
+     * Sets the timeout value to use when reading from the server,
+     *
+     * @param timeout the timeout value, in milliseconds, to use for the read
+     *        operation. A value of zero or less, means use the default timeout.
+     * @return This FtpClient
+     */
+    public sun.net.ftp.FtpClient setReadTimeout(int timeout) {
+        readTimeout = timeout;
+        return this;
+    }
+
+    /**
+     * Returns the current read timeout value.
+     *
+     * @return the value, in milliseconds, of the current read timeout.
+     * @see #setReadTimeout(int)
+     */
+    public int getReadTimeout() {
+        return readTimeout;
+    }
+
+    public sun.net.ftp.FtpClient setProxy(Proxy p) {
+        proxy = p;
+        return this;
+    }
+
+    /**
+     * Get the proxy of this FtpClient
+     *
+     * @return the <code>Proxy</code>, this client is using, or <code>null</code>
+     *         if none is used.
+     * @see #setProxy(Proxy)
+     */
+    public Proxy getProxy() {
+        return proxy;
+    }
+
+    /**
+     * Connects to the specified destination.
+     *
+     * @param dest the <code>InetSocketAddress</code> to connect to.
+     * @throws IOException if the connection fails.
+     */
+    private void tryConnect(InetSocketAddress dest, int timeout) throws IOException {
+        if (isConnected()) {
+            disconnect();
+        }
+        server = doConnect(dest, timeout);
+        try {
+            out = new PrintStream(new BufferedOutputStream(server.getOutputStream()),
+                    true, encoding);
+        } catch (UnsupportedEncodingException e) {
+            throw new InternalError(encoding + "encoding not found");
+        }
+        in = new BufferedInputStream(server.getInputStream());
+    }
+
+    private Socket doConnect(InetSocketAddress dest, int timeout) throws IOException {
+        Socket s;
+        if (proxy != null) {
+            if (proxy.type() == Proxy.Type.SOCKS) {
+                s = AccessController.doPrivileged(
+                        new PrivilegedAction<Socket>() {
+
+                            public Socket run() {
+                                return new Socket(proxy);
+                            }
+                        });
+            } else {
+                s = new Socket(Proxy.NO_PROXY);
+            }
+        } else {
+            s = new Socket();
+        }
+        // Instance specific timeouts do have priority, that means
+        // connectTimeout & readTimeout (-1 means not set)
+        // Then global default timeouts
+        // Then no timeout.
+        if (timeout >= 0) {
+            s.connect(dest, timeout);
+        } else {
+            if (connectTimeout >= 0) {
+                s.connect(dest, connectTimeout);
+            } else {
+                if (defaultConnectTimeout > 0) {
+                    s.connect(dest, defaultConnectTimeout);
+                } else {
+                    s.connect(dest);
+                }
+            }
+        }
+        if (readTimeout >= 0) {
+            s.setSoTimeout(readTimeout);
+        } else if (defaultSoTimeout > 0) {
+            s.setSoTimeout(defaultSoTimeout);
+        }
+        return s;
+    }
+
+    private void disconnect() throws IOException {
+        if (isConnected()) {
+            server.close();
+        }
+        server = null;
+        in = null;
+        out = null;
+        lastTransSize = -1;
+        lastFileName = null;
+        restartOffset = 0;
+        welcomeMsg = null;
+        lastReplyCode = null;
+        serverResponse.setSize(0);
+    }
+
+    /**
+     * Tests whether this client is connected or not to a server.
+     *
+     * @return <code>true</code> if the client is connected.
+     */
+    public boolean isConnected() {
+        return server != null;
+    }
+
+    public SocketAddress getServerAddress() {
+        return server == null ? null : server.getRemoteSocketAddress();
+    }
+
+    public sun.net.ftp.FtpClient connect(SocketAddress dest) throws sun.net.ftp.FtpProtocolException, IOException {
+        return connect(dest, -1);
+    }
+
+    /**
+     * Connects the FtpClient to the specified destination.
+     *
+     * @param dest the address of the destination server
+     * @throws IOException if connection failed.
+     */
+    public sun.net.ftp.FtpClient connect(SocketAddress dest, int timeout) throws sun.net.ftp.FtpProtocolException, IOException {
+        if (!(dest instanceof InetSocketAddress)) {
+            throw new IllegalArgumentException("Wrong address type");
+        }
+        serverAddr = (InetSocketAddress) dest;
+        tryConnect(serverAddr, timeout);
+        if (!readReply()) {
+            throw new sun.net.ftp.FtpProtocolException("Welcome message: " +
+                    getResponseString(), lastReplyCode);
+        }
+        welcomeMsg = getResponseString().substring(4);
+        return this;
+    }
+
+    private void tryLogin(String user, char[] password) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("USER " + user);
+
+        /*
+         * Checks for "331 User name okay, need password." answer
+         */
+        if (lastReplyCode == FtpReplyCode.NEED_PASSWORD) {
+            if ((password != null) && (password.length > 0)) {
+                issueCommandCheck("PASS " + String.valueOf(password));
+            }
+        }
+    }
+
+    /**
+     * Attempts to log on the server with the specified user name and password.
+     *
+     * @param user The user name
+     * @param password The password for that user
+     * @return <code>true</code> if the login was successful.
+     * @throws IOException if an error occured during the transmission
+     */
+    public sun.net.ftp.FtpClient login(String user, char[] password) throws sun.net.ftp.FtpProtocolException, IOException {
+        if (!isConnected()) {
+            throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
+        }
+        if (user == null || user.length() == 0) {
+            throw new IllegalArgumentException("User name can't be null or empty");
+        }
+        tryLogin(user, password);
+
+        // keep the welcome message around so we can
+        // put it in the resulting HTML page.
+        String l;
+        StringBuffer sb = new StringBuffer();
+        for (int i = 0; i < serverResponse.size(); i++) {
+            l = serverResponse.elementAt(i);
+            if (l != null) {
+                if (l.length() >= 4 && l.startsWith("230")) {
+                    // get rid of the "230-" prefix
+                    l = l.substring(4);
+                }
+                sb.append(l);
+            }
+        }
+        welcomeMsg = sb.toString();
+        loggedIn = true;
+        return this;
+    }
+
+    /**
+     * Attempts to log on the server with the specified user name, password and
+     * account name.
+     *
+     * @param user The user name
+     * @param password The password for that user.
+     * @param account The account name for that user.
+     * @return <code>true</code> if the login was successful.
+     * @throws IOException if an error occurs during the transmission.
+     */
+    public sun.net.ftp.FtpClient login(String user, char[] password, String account) throws sun.net.ftp.FtpProtocolException, IOException {
+
+        if (!isConnected()) {
+            throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
+        }
+        if (user == null || user.length() == 0) {
+            throw new IllegalArgumentException("User name can't be null or empty");
+        }
+        tryLogin(user, password);
+
+        /*
+         * Checks for "332 Need account for login." answer
+         */
+        if (lastReplyCode == FtpReplyCode.NEED_ACCOUNT) {
+            issueCommandCheck("ACCT " + account);
+        }
+
+        // keep the welcome message around so we can
+        // put it in the resulting HTML page.
+        StringBuffer sb = new StringBuffer();
+        if (serverResponse != null) {
+            for (String l : serverResponse) {
+                if (l != null) {
+                    if (l.length() >= 4 && l.startsWith("230")) {
+                        // get rid of the "230-" prefix
+                        l = l.substring(4);
+                    }
+                    sb.append(l);
+                }
+            }
+        }
+        welcomeMsg = sb.toString();
+        loggedIn = true;
+        return this;
+    }
+
+    /**
+     * Logs out the current user. This is in effect terminates the current
+     * session and the connection to the server will be closed.
+     *
+     */
+    public void close() throws IOException {
+        if (isConnected()) {
+            issueCommand("QUIT");
+            loggedIn = false;
+        }
+        disconnect();
+    }
+
+    /**
+     * Checks whether the client is logged in to the server or not.
+     *
+     * @return <code>true</code> if the client has already completed a login.
+     */
+    public boolean isLoggedIn() {
+        return loggedIn;
+    }
+
+    /**
+     * Changes to a specific directory on a remote FTP server
+     *
+     * @param remoteDirectory path of the directory to CD to.
+     * @return <code>true</code> if the operation was successful.
+     * @exception <code>FtpProtocolException</code>
+     */
+    public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException {
+        if (remoteDirectory == null || "".equals(remoteDirectory)) {
+            throw new IllegalArgumentException("directory can't be null or empty");
+        }
+
+        issueCommandCheck("CWD " + remoteDirectory);
+        return this;
+    }
+
+    /**
+     * Changes to the parent directory, sending the CDUP command to the server.
+     *
+     * @return <code>true</code> if the command was successful.
+     * @throws IOException
+     */
+    public sun.net.ftp.FtpClient changeToParentDirectory() throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("CDUP");
+        return this;
+    }
+
+    /**
+     * Returns the server current working directory, or <code>null</code> if
+     * the PWD command failed.
+     *
+     * @return a <code>String</code> containing the current working directory,
+     *         or <code>null</code>
+     * @throws IOException
+     */
+    public String getWorkingDirectory() throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("PWD");
+        /*
+         * answer will be of the following format :
+         *
+         * 257 "/" is current directory.
+         */
+        String answ = getResponseString();
+        if (!answ.startsWith("257")) {
+            return null;
+        }
+        return answ.substring(5, answ.lastIndexOf('"'));
+    }
+
+    /**
+     * Sets the restart offset to the specified value.  That value will be
+     * sent through a <code>REST</code> command to server before a file
+     * transfer and has the effect of resuming a file transfer from the
+     * specified point. After a transfer the restart offset is set back to
+     * zero.
+     *
+     * @param offset the offset in the remote file at which to start the next
+     *        transfer. This must be a value greater than or equal to zero.
+     * @throws IllegalArgumentException if the offset is negative.
+     */
+    public sun.net.ftp.FtpClient setRestartOffset(long offset) {
+        if (offset < 0) {
+            throw new IllegalArgumentException("offset can't be negative");
+        }
+        restartOffset = offset;
+        return this;
+    }
+
+    /**
+     * Retrieves a file from the ftp server and writes it to the specified
+     * <code>OutputStream</code>.
+     * If the restart offset was set, then a <code>REST</code> command will be
+     * sent before the RETR in order to restart the tranfer from the specified
+     * offset.
+     * The <code>OutputStream</code> is not closed by this method at the end
+     * of the transfer.
+     *
+     * @param name a <code>String<code> containing the name of the file to
+     *        retreive from the server.
+     * @param local the <code>OutputStream</code> the file should be written to.
+     * @throws IOException if the transfer fails.
+     */
+    public sun.net.ftp.FtpClient getFile(String name, OutputStream local) throws sun.net.ftp.FtpProtocolException, IOException {
+        int mtu = 1500;
+        if (restartOffset > 0) {
+            Socket s;
+            try {
+                s = openDataConnection("REST " + restartOffset);
+            } finally {
+                restartOffset = 0;
+            }
+            issueCommandCheck("RETR " + name);
+            getTransferSize();
+            InputStream remote = createInputStream(s.getInputStream());
+            byte[] buf = new byte[mtu * 10];
+            int l;
+            while ((l = remote.read(buf)) >= 0) {
+                if (l > 0) {
+                    local.write(buf, 0, l);
+                }
+            }
+            remote.close();
+        } else {
+            Socket s = openDataConnection("RETR " + name);
+            getTransferSize();
+            InputStream remote = createInputStream(s.getInputStream());
+            byte[] buf = new byte[mtu * 10];
+            int l;
+            while ((l = remote.read(buf)) >= 0) {
+                if (l > 0) {
+                    local.write(buf, 0, l);
+                }
+            }
+            remote.close();
+        }
+        return completePending();
+    }
+
+    /**
+     * Retrieves a file from the ftp server, using the RETR command, and
+     * returns the InputStream from* the established data connection.
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is done reading from the returned stream.
+     *
+     * @param name the name of the remote file
+     * @return the {@link java.io.InputStream} from the data connection, or
+     *         <code>null</code> if the command was unsuccessful.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public InputStream getFileStream(String name) throws sun.net.ftp.FtpProtocolException, IOException {
+        Socket s;
+        if (restartOffset > 0) {
+            try {
+                s = openDataConnection("REST " + restartOffset);
+            } finally {
+                restartOffset = 0;
+            }
+            if (s == null) {
+                return null;
+            }
+            issueCommandCheck("RETR " + name);
+            getTransferSize();
+            return createInputStream(s.getInputStream());
+        }
+
+        s = openDataConnection("RETR " + name);
+        if (s == null) {
+            return null;
+        }
+        getTransferSize();
+        return createInputStream(s.getInputStream());
+    }
+
+    /**
+     * Transfers a file from the client to the server (aka a <I>put</I>)
+     * by sending the STOR or STOU command, depending on the
+     * <code>unique</code> argument, and returns the <code>OutputStream</code>
+     * from the established data connection.
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is finished writing to the stream.
+     *
+     * A new file is created at the server site if the file specified does
+     * not already exist.
+     *
+     * If <code>unique</code> is set to <code>true</code>, the resultant file
+     * is to be created under a name unique to that directory, meaning
+     * it will not overwrite an existing file, instead the server will
+     * generate a new, unique, file name.
+     * The name of the remote file can be retrieved, after completion of the
+     * transfer, by calling {@link #getLastFileName()}.
+     *
+     * @param name the name of the remote file to write.
+     * @param unique <code>true</code> if the remote files should be unique,
+     *        in which case the STOU command will be used.
+     * @return the {@link java.io.OutputStream} from the data connection or
+     *         <code>null</code> if the command was unsuccessful.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public OutputStream putFileStream(String name, boolean unique) throws sun.net.ftp.FtpProtocolException, IOException {
+        String cmd = unique ? "STOU " : "STOR ";
+        Socket s = openDataConnection(cmd + name);
+        if (s == null) {
+            return null;
+        }
+        if (type == TransferType.BINARY) {
+            return s.getOutputStream();
+        }
+        return new sun.net.TelnetOutputStream(s.getOutputStream(), false);
+    }
+
+    /**
+     * Transfers a file from the client to the server (aka a <I>put</I>)
+     * by sending the STOR command. The content of the <code>InputStream</code>
+     * passed in argument is written into the remote file, overwriting any
+     * existing data.
+     *
+     * A new file is created at the server site if the file specified does
+     * not already exist.
+     *
+     * @param name the name of the remote file to write.
+     * @param local the <code>InputStream</code> that points to the data to
+     *        transfer.
+     * @param unique <code>true</code> if the remote file should be unique
+     *        (i.e. not already existing), <code>false</code> otherwise.
+     * @return <code>true</code> if the transfer was successful.
+     * @throws IOException if an error occured during the transmission.
+     * @see #getLastFileName()
+     */
+    public sun.net.ftp.FtpClient putFile(String name, InputStream local, boolean unique) throws sun.net.ftp.FtpProtocolException, IOException {
+        String cmd = unique ? "STOU " : "STOR ";
+        int mtu = 1500;
+        if (type == TransferType.BINARY) {
+            Socket s = openDataConnection(cmd + name);
+            OutputStream remote = createOutputStream(s.getOutputStream());
+            byte[] buf = new byte[mtu * 10];
+            int l;
+            while ((l = local.read(buf)) >= 0) {
+                if (l > 0) {
+                    remote.write(buf, 0, l);
+                }
+            }
+            remote.close();
+        }
+        return completePending();
+    }
+
+    /**
+     * Sends the APPE command to the server in order to transfer a data stream
+     * passed in argument and append it to the content of the specified remote
+     * file.
+     *
+     * @param name A <code>String</code> containing the name of the remote file
+     *        to append to.
+     * @param local The <code>InputStream</code> providing access to the data
+     *        to be appended.
+     * @return <code>true</code> if the transfer was successful.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public sun.net.ftp.FtpClient appendFile(String name, InputStream local) throws sun.net.ftp.FtpProtocolException, IOException {
+        int mtu = 1500;
+        Socket s = openDataConnection("APPE " + name);
+        OutputStream remote = createOutputStream(s.getOutputStream());
+        byte[] buf = new byte[mtu * 10];
+        int l;
+        while ((l = local.read(buf)) >= 0) {
+            if (l > 0) {
+                remote.write(buf, 0, l);
+            }
+        }
+        remote.close();
+        return completePending();
+    }
+
+    /**
+     * Renames a file on the server.
+     *
+     * @param from the name of the file being renamed
+     * @param to the new name for the file
+     * @throws IOException if the command fails
+     */
+    public sun.net.ftp.FtpClient rename(String from, String to) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("RNFR " + from);
+        issueCommandCheck("RNTO " + to);
+        return this;
+    }
+
+    /**
+     * Deletes a file on the server.
+     *
+     * @param name a <code>String</code> containing the name of the file
+     *        to delete.
+     * @return <code>true</code> if the command was successful
+     * @throws IOException if an error occured during the exchange
+     */
+    public sun.net.ftp.FtpClient deleteFile(String name) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("DELE " + name);
+        return this;
+    }
+
+    /**
+     * Creates a new directory on the server.
+     *
+     * @param name a <code>String</code> containing the name of the directory
+     *        to create.
+     * @return <code>true</code> if the operation was successful.
+     * @throws IOException if an error occured during the exchange
+     */
+    public sun.net.ftp.FtpClient makeDirectory(String name) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("MKD " + name);
+        return this;
+    }
+
+    /**
+     * Removes a directory on the server.
+     *
+     * @param name a <code>String</code> containing the name of the directory
+     *        to remove.
+     *
+     * @return <code>true</code> if the operation was successful.
+     * @throws IOException if an error occured during the exchange.
+     */
+    public sun.net.ftp.FtpClient removeDirectory(String name) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("RMD " + name);
+        return this;
+    }
+
+    /**
+     * Sends a No-operation command. It's useful for testing the connection
+     * status or as a <I>keep alive</I> mechanism.
+     *
+     * @throws FtpProtocolException if the command fails
+     */
+    public sun.net.ftp.FtpClient noop() throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("NOOP");
+        return this;
+    }
+
+    /**
+     * Sends the STAT command to the server.
+     * This can be used while a data connection is open to get a status
+     * on the current transfer, in that case the parameter should be
+     * <code>null</code>.
+     * If used between file transfers, it may have a pathname as argument
+     * in which case it will work as the LIST command except no data
+     * connection will be created.
+     *
+     * @param name an optional <code>String</code> containing the pathname
+     *        the STAT command should apply to.
+     * @return the response from the server or <code>null</code> if the
+     *         command failed.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public String getStatus(String name) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck((name == null ? "STAT" : "STAT " + name));
+        /*
+         * A typical response will be:
+         *  213-status of t32.gif:
+         * -rw-r--r--   1 jcc      staff     247445 Feb 17  1998 t32.gif
+         * 213 End of Status
+         *
+         * or
+         *
+         * 211-jsn FTP server status:
+         *     Version wu-2.6.2+Sun
+         *     Connected to localhost (::1)
+         *     Logged in as jccollet
+         *     TYPE: ASCII, FORM: Nonprint; STRUcture: File; transfer MODE: Stream
+         *      No data connection
+         *     0 data bytes received in 0 files
+         *     0 data bytes transmitted in 0 files
+         *     0 data bytes total in 0 files
+         *     53 traffic bytes received in 0 transfers
+         *     485 traffic bytes transmitted in 0 transfers
+         *     587 traffic bytes total in 0 transfers
+         * 211 End of status
+         *
+         * So we need to remove the 1st and last line
+         */
+        Vector<String> resp = getResponseStrings();
+        StringBuffer sb = new StringBuffer();
+        for (int i = 1; i < resp.size() - 1; i++) {
+            sb.append(resp.get(i));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Sends the FEAT command to the server and returns the list of supported
+     * features in the form of strings.
+     *
+     * The features are the supported commands, like AUTH TLS, PROT or PASV.
+     * See the RFCs for a complete list.
+     *
+     * Note that not all FTP servers support that command, in which case
+     * the method will return <code>null</code>
+     *
+     * @return a <code>List</code> of <code>Strings</code> describing the
+     *         supported additional features, or <code>null</code>
+     *         if the command is not supported.
+     * @throws IOException if an error occurs during the transmission.
+     */
+    public List<String> getFeatures() throws sun.net.ftp.FtpProtocolException, IOException {
+        /*
+         * The FEAT command, when implemented will return something like:
+         *
+         * 211-Features:
+         *   AUTH TLS
+         *   PBSZ
+         *   PROT
+         *   EPSV
+         *   EPRT
+         *   PASV
+         *   REST STREAM
+         *  211 END
+         */
+        ArrayList<String> features = new ArrayList<String>();
+        issueCommandCheck("FEAT");
+        Vector<String> resp = getResponseStrings();
+        // Note that we start at index 1 to skip the 1st line (211-...)
+        // and we stop before the last line.
+        for (int i = 1; i < resp.size() - 1; i++) {
+            String s = resp.get(i);
+            // Get rid of leading space and trailing newline
+            features.add(s.substring(1, s.length() - 1));
+        }
+        return features;
+    }
+
+    /**
+     * sends the ABOR command to the server.
+     * It tells the server to stop the previous command or transfer.
+     *
+     * @return <code>true</code> if the command was successful.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public sun.net.ftp.FtpClient abort() throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("ABOR");
+        // TODO: Must check the ReplyCode:
+        /*
+         * From the RFC:
+         * There are two cases for the server upon receipt of this
+         * command: (1) the FTP service command was already completed,
+         * or (2) the FTP service command is still in progress.
+         * In the first case, the server closes the data connection
+         * (if it is open) and responds with a 226 reply, indicating
+         * that the abort command was successfully processed.
+         * In the second case, the server aborts the FTP service in
+         * progress and closes the data connection, returning a 426
+         * reply to indicate that the service request terminated
+         * abnormally.  The server then sends a 226 reply,
+         * indicating that the abort command was successfully
+         * processed.
+         */
+
+
+        return this;
+    }
+
+    /**
+     * Some methods do not wait until completion before returning, so this
+     * method can be called to wait until completion. This is typically the case
+     * with commands that trigger a transfer like {@link #getFileStream(String)}.
+     * So this method should be called before accessing information related to
+     * such a command.
+     * <p>This method will actually block reading on the command channel for a
+     * notification from the server that the command is finished. Such a
+     * notification often carries extra information concerning the completion
+     * of the pending action (e.g. number of bytes transfered).</p>
+     * <p>Note that this will return true immediately if no command or action
+     * is pending</p>
+     * <p>It should be also noted that most methods issuing commands to the ftp
+     * server will call this method if a previous command is pending.
+     * <p>Example of use:
+     * <pre>
+     * InputStream in = cl.getFileStream("file");
+     * ...
+     * cl.completePending();
+     * long size = cl.getLastTransferSize();
+     * </pre>
+     * On the other hand, it's not necessary in a case like:
+     * <pre>
+     * InputStream in = cl.getFileStream("file");
+     * // read content
+     * ...
+     * cl.logout();
+     * </pre>
+     * <p>Since {@link #logout()} will call completePending() if necessary.</p>
+     * @return <code>true</code> if the completion was successful or if no
+     *         action was pending.
+     * @throws IOException
+     */
+    public sun.net.ftp.FtpClient completePending() throws sun.net.ftp.FtpProtocolException, IOException {
+        while (replyPending) {
+            replyPending = false;
+            if (!readReply()) {
+                throw new sun.net.ftp.FtpProtocolException(getLastResponseString(), lastReplyCode);
+            }
+        }
+        return this;
+    }
+
+    /**
+     * Reinitializes the USER parameters on the FTP server
+     *
+     * @throws FtpProtocolException if the command fails
+     */
+    public sun.net.ftp.FtpClient reInit() throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("REIN");
+        loggedIn = false;
+        if (useCrypto) {
+            if (server instanceof SSLSocket) {
+                javax.net.ssl.SSLSession session = ((SSLSocket) server).getSession();
+                session.invalidate();
+                // Restore previous socket and streams
+                server = oldSocket;
+                oldSocket = null;
+                try {
+                    out = new PrintStream(new BufferedOutputStream(server.getOutputStream()),
+                            true, encoding);
+                } catch (UnsupportedEncodingException e) {
+                    throw new InternalError(encoding + "encoding not found");
+                }
+                in = new BufferedInputStream(server.getInputStream());
+            }
+        }
+        useCrypto = false;
+        return this;
+    }
+
+    /**
+     * Changes the transfer type (binary, ascii, ebcdic) and issue the
+     * proper command (e.g. TYPE A) to the server.
+     *
+     * @param type the <code>FtpTransferType</code> to use.
+     * @return This FtpClient
+     * @throws IOException if an error occurs during transmission.
+     */
+    public sun.net.ftp.FtpClient setType(TransferType type) throws sun.net.ftp.FtpProtocolException, IOException {
+        String cmd = "NOOP";
+
+        this.type = type;
+        if (type == TransferType.ASCII) {
+            cmd = "TYPE A";
+        }
+        if (type == TransferType.BINARY) {
+            cmd = "TYPE I";
+        }
+        if (type == TransferType.EBCDIC) {
+            cmd = "TYPE E";
+        }
+        issueCommandCheck(cmd);
+        return this;
+    }
+
+    /**
+     * Issues a LIST command to the server to get the current directory
+     * listing, and returns the InputStream from the data connection.
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is finished writing to the stream.
+     *
+     * @param path the pathname of the directory to list, or <code>null</code>
+     *        for the current working directory.
+     * @return the <code>InputStream</code> from the resulting data connection
+     * @throws IOException if an error occurs during the transmission.
+     * @see #changeDirectory(String)
+     * @see #listFiles(String)
+     */
+    public InputStream list(String path) throws sun.net.ftp.FtpProtocolException, IOException {
+        Socket s;
+        s = openDataConnection(path == null ? "LIST" : "LIST " + path);
+        if (s != null) {
+            return createInputStream(s.getInputStream());
+        }
+        return null;
+    }
+
+    /**
+     * Issues a NLST path command to server to get the specified directory
+     * content. It differs from {@link #list(String)} method by the fact that
+     * it will only list the file names which would make the parsing of the
+     * somewhat easier.
+     *
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is finished writing to the stream.
+     *
+     * @param path a <code>String</code> containing the pathname of the
+     *        directory to list or <code>null</code> for the current working
+     *        directory.
+     * @return the <code>InputStream</code> from the resulting data connection
+     * @throws IOException if an error occurs during the transmission.
+     */
+    public InputStream nameList(String path) throws sun.net.ftp.FtpProtocolException, IOException {
+        Socket s;
+        s = openDataConnection("NLST " + path);
+        if (s != null) {
+            return createInputStream(s.getInputStream());
+        }
+        return null;
+    }
+
+    /**
+     * Issues the SIZE [path] command to the server to get the size of a
+     * specific file on the server.
+     * Note that this command may not be supported by the server. In which
+     * case -1 will be returned.
+     *
+     * @param path a <code>String</code> containing the pathname of the
+     *        file.
+     * @return a <code>long</code> containing the size of the file or -1 if
+     *         the server returned an error, which can be checked with
+     *         {@link #getLastReplyCode()}.
+     * @throws IOException if an error occurs during the transmission.
+     */
+    public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException {
+        if (path == null || path.length() == 0) {
+            throw new IllegalArgumentException("path can't be null or empty");
+        }
+        issueCommandCheck("SIZE " + path);
+        if (lastReplyCode == FtpReplyCode.FILE_STATUS) {
+            String s = getResponseString();
+            s = s.substring(4, s.length() - 1);
+            return Long.parseLong(s);
+        }
+        return -1;
+    }
+    private static String[] MDTMformats = {
+        "yyyyMMddHHmmss.SSS",
+        "yyyyMMddHHmmss"
+    };
+    private static SimpleDateFormat[] dateFormats = new SimpleDateFormat[MDTMformats.length];
+
+    static {
+        for (int i = 0; i < MDTMformats.length; i++) {
+            dateFormats[i] = new SimpleDateFormat(MDTMformats[i]);
+            dateFormats[i].setTimeZone(TimeZone.getTimeZone("GMT"));
+        }
+    }
+
+    /**
+     * Issues the MDTM [path] command to the server to get the modification
+     * time of a specific file on the server.
+     * Note that this command may not be supported by the server, in which
+     * case <code>null</code> will be returned.
+     *
+     * @param path a <code>String</code> containing the pathname of the file.
+     * @return a <code>Date</code> representing the last modification time
+     *         or <code>null</code> if the server returned an error, which
+     *         can be checked with {@link #getLastReplyCode()}.
+     * @throws IOException if an error occurs during the transmission.
+     */
+    public Date getLastModified(String path) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("MDTM " + path);
+        if (lastReplyCode == FtpReplyCode.FILE_STATUS) {
+            String s = getResponseString().substring(4);
+            Date d = null;
+            for (SimpleDateFormat dateFormat : dateFormats) {
+                try {
+                    d = dateFormat.parse(s);
+                } catch (ParseException ex) {
+                }
+                if (d != null) {
+                    return d;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Sets the parser used to handle the directory output to the specified
+     * one. By default the parser is set to one that can handle most FTP
+     * servers output (Unix base mostly). However it may be necessary for
+     * and application to provide its own parser due to some uncommon
+     * output format.
+     *
+     * @param p The <code>FtpDirParser</code> to use.
+     * @see #listFiles(String)
+     */
+    public sun.net.ftp.FtpClient setDirParser(FtpDirParser p) {
+        parser = p;
+        return this;
+    }
+
+    private class FtpFileIterator implements Iterator<FtpDirEntry>, Closeable {
+
+        private BufferedReader in = null;
+        private FtpDirEntry nextFile = null;
+        private FtpDirParser fparser = null;
+        private boolean eof = false;
+
+        public FtpFileIterator(FtpDirParser p, BufferedReader in) {
+            this.in = in;
+            this.fparser = p;
+            readNext();
+        }
+
+        private void readNext() {
+            nextFile = null;
+            if (eof) {
+                return;
+            }
+            String line = null;
+            try {
+                do {
+                    line = in.readLine();
+                    if (line != null) {
+                        nextFile = fparser.parseLine(line);
+                        if (nextFile != null) {
+                            return;
+                        }
+                    }
+                } while (line != null);
+                in.close();
+            } catch (IOException iOException) {
+            }
+            eof = true;
+        }
+
+        public boolean hasNext() {
+            return nextFile != null;
+        }
+
+        public FtpDirEntry next() {
+            FtpDirEntry ret = nextFile;
+            readNext();
+            return ret;
+        }
+
+        public void remove() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public void close() throws IOException {
+            if (in != null && !eof) {
+                in.close();
+            }
+            eof = true;
+            nextFile = null;
+        }
+    }
+
+    /**
+     * Issues a MLSD command to the server to get the specified directory
+     * listing and applies the current parser to create an Iterator of
+     * {@link java.net.ftp.FtpDirEntry}. Note that the Iterator returned is also a
+     * {@link java.io.Closeable}.
+     * If the server doesn't support the MLSD command, the LIST command is used
+     * instead.
+     *
+     * {@link #completePending()} <b>has</b> to be called once the application
+     * is finished iterating through the files.
+     *
+     * @param path the pathname of the directory to list or <code>null</code>
+     *        for the current working directoty.
+     * @return a <code>Iterator</code> of files or <code>null</code> if the
+     *         command failed.
+     * @throws IOException if an error occured during the transmission
+     * @see #setDirParser(FtpDirParser)
+     * @see #changeDirectory(String)
+     */
+    public Iterator<FtpDirEntry> listFiles(String path) throws sun.net.ftp.FtpProtocolException, IOException {
+        Socket s = null;
+        BufferedReader sin = null;
+        try {
+            s = openDataConnection(path == null ? "MLSD" : "MLSD " + path);
+        } catch (sun.net.ftp.FtpProtocolException FtpException) {
+            // The server doesn't understand new MLSD command, ignore and fall
+            // back to LIST
+        }
+
+        if (s != null) {
+            sin = new BufferedReader(new InputStreamReader(s.getInputStream()));
+            return new FtpFileIterator(mlsxParser, sin);
+        } else {
+            s = openDataConnection(path == null ? "LIST" : "LIST " + path);
+            if (s != null) {
+                sin = new BufferedReader(new InputStreamReader(s.getInputStream()));
+                return new FtpFileIterator(parser, sin);
+            }
+        }
+        return null;
+    }
+
+    private boolean sendSecurityData(byte[] buf) throws IOException {
+        BASE64Encoder encoder = new BASE64Encoder();
+        String s = encoder.encode(buf);
+        return issueCommand("ADAT " + s);
+    }
+
+    private byte[] getSecurityData() {
+        String s = getLastResponseString();
+        if (s.substring(4, 9).equalsIgnoreCase("ADAT=")) {
+            BASE64Decoder decoder = new BASE64Decoder();
+            try {
+                // Need to get rid of the leading '315 ADAT='
+                // and the trailing newline
+                return decoder.decodeBuffer(s.substring(9, s.length() - 1));
+            } catch (IOException e) {
+                //
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Attempts to use Kerberos GSSAPI as an authentication mechanism with the
+     * ftp server. This will issue an <code>AUTH GSSAPI</code> command, and if
+     * it is accepted by the server, will followup with <code>ADAT</code>
+     * command to exchange the various tokens until authentification is
+     * successful. This conforms to Appendix I of RFC 2228.
+     *
+     * @return <code>true</code> if authentication was successful.
+     * @throws IOException if an error occurs during the transmission.
+     */
+    public sun.net.ftp.FtpClient useKerberos() throws sun.net.ftp.FtpProtocolException, IOException {
+        /*
+         * Comment out for the moment since it's not in use and would create
+         * needless cross-package links.
+         *
+        issueCommandCheck("AUTH GSSAPI");
+        if (lastReplyCode != FtpReplyCode.NEED_ADAT)
+        throw new sun.net.ftp.FtpProtocolException("Unexpected reply from server");
+        try {
+        GSSManager manager = GSSManager.getInstance();
+        GSSName name = manager.createName("SERVICE:ftp@"+
+        serverAddr.getHostName(), null);
+        GSSContext context = manager.createContext(name, null, null,
+        GSSContext.DEFAULT_LIFETIME);
+        context.requestMutualAuth(true);
+        context.requestReplayDet(true);
+        context.requestSequenceDet(true);
+        context.requestCredDeleg(true);
+        byte []inToken = new byte[0];
+        while (!context.isEstablished()) {
+        byte[] outToken
+        = context.initSecContext(inToken, 0, inToken.length);
+        // send the output token if generated
+        if (outToken != null) {
+        if (sendSecurityData(outToken)) {
+        inToken = getSecurityData();
+        }
+        }
+        }
+        loggedIn = true;
+        } catch (GSSException e) {
+
+        }
+         */
+        return this;
+    }
+
+    /**
+     * Returns the Welcome string the server sent during initial connection.
+     *
+     * @return a <code>String</code> containing the message the server
+     *         returned during connection or <code>null</code>.
+     */
+    public String getWelcomeMsg() {
+        return welcomeMsg;
+    }
+
+    /**
+     * Returns the last reply code sent by the server.
+     *
+     * @return the lastReplyCode
+     */
+    public FtpReplyCode getLastReplyCode() {
+        return lastReplyCode;
+    }
+
+    /**
+     * Returns the last response string sent by the server.
+     *
+     * @return the message string, which can be quite long, last returned
+     *         by the server.
+     */
+    public String getLastResponseString() {
+        StringBuffer sb = new StringBuffer();
+        if (serverResponse != null) {
+            for (String l : serverResponse) {
+                if (l != null) {
+                    sb.append(l);
+                }
+            }
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Returns, when available, the size of the latest started transfer.
+     * This is retreived by parsing the response string received as an initial
+     * response to a RETR or similar request.
+     *
+     * @return the size of the latest transfer or -1 if either there was no
+     *         transfer or the information was unavailable.
+     */
+    public long getLastTransferSize() {
+        return lastTransSize;
+    }
+
+    /**
+     * Returns, when available, the remote name of the last transfered file.
+     * This is mainly useful for "put" operation when the unique flag was
+     * set since it allows to recover the unique file name created on the
+     * server which may be different from the one submitted with the command.
+     *
+     * @return the name the latest transfered file remote name, or
+     *         <code>null</code> if that information is unavailable.
+     */
+    public String getLastFileName() {
+        return lastFileName;
+    }
+
+    /**
+     * Attempts to switch to a secure, encrypted connection. This is done by
+     * sending the "AUTH TLS" command.
+     * <p>See <a href="http://www.ietf.org/rfc/rfc4217.txt">RFC 4217</a></p>
+     * If successful this will establish a secure command channel with the
+     * server, it will also make it so that all other transfers (e.g. a RETR
+     * command) will be done over an encrypted channel as well unless a
+     * {@link #reInit()} command or a {@link #endSecureSession()} command is issued.
+     *
+     * @return <code>true</code> if the operation was successful.
+     * @throws IOException if an error occured during the transmission.
+     * @see #endSecureSession()
+     */
+    public sun.net.ftp.FtpClient startSecureSession() throws sun.net.ftp.FtpProtocolException, IOException {
+        if (!isConnected()) {
+            throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
+        }
+        if (sslFact == null) {
+            try {
+                sslFact = (SSLSocketFactory) SSLSocketFactory.getDefault();
+            } catch (Exception e) {
+                throw new IOException(e.getLocalizedMessage());
+            }
+        }
+        issueCommandCheck("AUTH TLS");
+        Socket s = null;
+        try {
+            s = sslFact.createSocket(server, serverAddr.getHostName(), serverAddr.getPort(), true);
+        } catch (javax.net.ssl.SSLException ssle) {
+            try {
+                disconnect();
+            } catch (Exception e) {
+            }
+            throw ssle;
+        }
+        // Remember underlying socket so we can restore it later
+        oldSocket = server;
+        server = s;
+        try {
+            out = new PrintStream(new BufferedOutputStream(server.getOutputStream()),
+                    true, encoding);
+        } catch (UnsupportedEncodingException e) {
+            throw new InternalError(encoding + "encoding not found");
+        }
+        in = new BufferedInputStream(server.getInputStream());
+
+        issueCommandCheck("PBSZ 0");
+        issueCommandCheck("PROT P");
+        useCrypto = true;
+        return this;
+    }
+
+    /**
+     * Sends a <code>CCC</code> command followed by a <code>PROT C</code>
+     * command to the server terminating an encrypted session and reverting
+     * back to a non crypted transmission.
+     *
+     * @return <code>true</code> if the operation was successful.
+     * @throws IOException if an error occured during transmission.
+     * @see #startSecureSession()
+     */
+    public sun.net.ftp.FtpClient endSecureSession() throws sun.net.ftp.FtpProtocolException, IOException {
+        if (!useCrypto) {
+            return this;
+        }
+
+        issueCommandCheck("CCC");
+        issueCommandCheck("PROT C");
+        useCrypto = false;
+        // Restore previous socket and streams
+        server = oldSocket;
+        oldSocket = null;
+        try {
+            out = new PrintStream(new BufferedOutputStream(server.getOutputStream()),
+                    true, encoding);
+        } catch (UnsupportedEncodingException e) {
+            throw new InternalError(encoding + "encoding not found");
+        }
+        in = new BufferedInputStream(server.getInputStream());
+
+        return this;
+    }
+
+    /**
+     * Sends the "Allocate" (ALLO) command to the server telling it to
+     * pre-allocate the specified number of bytes for the next transfer.
+     *
+     * @param size The number of bytes to allocate.
+     * @return <code>true</code> if the operation was successful.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public sun.net.ftp.FtpClient allocate(long size) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("ALLO " + size);
+        return this;
+    }
+
+    /**
+     * Sends the "Structure Mount" (SMNT) command to the server. This let the
+     * user mount a different file system data structure without altering his
+     * login or accounting information.
+     *
+     * @param struct a <code>String</code> containing the name of the
+     *        structure to mount.
+     * @return <code>true</code> if the operation was successful.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public sun.net.ftp.FtpClient structureMount(String struct) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("SMNT " + struct);
+        return this;
+    }
+
+    /**
+     * Sends a SYST (System) command to the server and returns the String
+     * sent back by the server describing the operating system at the
+     * server.
+     *
+     * @return a <code>String</code> describing the OS, or <code>null</code>
+     *         if the operation was not successful.
+     * @throws IOException if an error occured during the transmission.
+     */
+    public String getSystem() throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("SYST");
+        /*
+         * 215 UNIX Type: L8 Version: SUNOS
+         */
+        String resp = getResponseString();
+        // Get rid of the leading code and blank
+        return resp.substring(4);
+    }
+
+    /**
+     * Sends the HELP command to the server, with an optional command, like
+     * SITE, and returns the text sent back by the server.
+     *
+     * @param cmd the command for which the help is requested or
+     *        <code>null</code> for the general help
+     * @return a <code>String</code> containing the text sent back by the
+     *         server, or <code>null</code> if the command failed.
+     * @throws IOException if an error occured during transmission
+     */
+    public String getHelp(String cmd) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("HELP " + cmd);
+        /**
+         *
+         * HELP
+         * 214-The following commands are implemented.
+         *   USER    EPRT    STRU    ALLO    DELE    SYST    RMD     MDTM    ADAT
+         *   PASS    EPSV    MODE    REST    CWD     STAT    PWD     PROT
+         *   QUIT    LPRT    RETR    RNFR    LIST    HELP    CDUP    PBSZ
+         *   PORT    LPSV    STOR    RNTO    NLST    NOOP    STOU    AUTH
+         *   PASV    TYPE    APPE    ABOR    SITE    MKD     SIZE    CCC
+         * 214 Direct comments to ftp-bugs@jsn.
+         *
+         * HELP SITE
+         * 214-The following SITE commands are implemented.
+         *   UMASK           HELP            GROUPS
+         *   IDLE            ALIAS           CHECKMETHOD
+         *   CHMOD           CDPATH          CHECKSUM
+         * 214 Direct comments to ftp-bugs@jsn.
+         */
+        Vector<String> resp = getResponseStrings();
+        if (resp.size() == 1) {
+            // Single line response
+            return resp.get(0).substring(4);
+        }
+        // on multiple lines answers, like the ones above, remove 1st and last
+        // line, concat the the others.
+        StringBuffer sb = new StringBuffer();
+        for (int i = 1; i < resp.size() - 1; i++) {
+            sb.append(resp.get(i).substring(3));
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Sends the SITE command to the server. This is used by the server
+     * to provide services specific to his system that are essential
+     * to file transfer.
+     *
+     * @param cmd the command to be sent.
+     * @return <code>true</code> if the command was successful.
+     * @throws IOException if an error occured during transmission
+     */
+    public sun.net.ftp.FtpClient siteCmd(String cmd) throws sun.net.ftp.FtpProtocolException, IOException {
+        issueCommandCheck("SITE " + cmd);
+        return this;
+    }
+}
--- a/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1994-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1994-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
@@ -37,10 +37,8 @@
 import java.io.FilterOutputStream;
 import java.io.FileNotFoundException;
 import java.net.URL;
-import java.net.URLStreamHandler;
 import java.net.SocketPermission;
 import java.net.UnknownHostException;
-import java.net.MalformedURLException;
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.Proxy;
@@ -84,7 +82,6 @@
     // In case we have to use proxies, we use HttpURLConnection
     HttpURLConnection http = null;
     private Proxy instProxy;
-    Proxy proxy = null;
 
     InputStream is = null;
     OutputStream os = null;
@@ -125,12 +122,11 @@
             ftp = cl;
         }
 
+        @Override
         public void close() throws IOException {
             super.close();
-            try {
-                if (ftp != null)
-                    ftp.closeServer();
-            } catch (IOException ex) {
+            if (ftp != null) {
+                ftp.close();
             }
         }
     }
@@ -149,12 +145,11 @@
             ftp = cl;
         }
 
+        @Override
         public void close() throws IOException {
             super.close();
-            try {
-                if (ftp != null)
-                    ftp.closeServer();
-            } catch (IOException ex) {
+            if (ftp != null) {
+                ftp.close();
             }
         }
     }
@@ -192,10 +187,12 @@
 
     private void setTimeouts() {
         if (ftp != null) {
-            if (connectTimeout >= 0)
+            if (connectTimeout >= 0) {
                 ftp.setConnectTimeout(connectTimeout);
-            if (readTimeout >= 0)
+            }
+            if (readTimeout >= 0) {
                 ftp.setReadTimeout(readTimeout);
+            }
         }
     }
 
@@ -218,21 +215,22 @@
              * Do we have to use a proxy?
              */
             ProxySelector sel = java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<ProxySelector>() {
-                    public ProxySelector run() {
-                                return ProxySelector.getDefault();
-                            }
-                            });
+                    new java.security.PrivilegedAction<ProxySelector>() {
+                        public ProxySelector run() {
+                            return ProxySelector.getDefault();
+                        }
+                    });
             if (sel != null) {
                 URI uri = sun.net.www.ParseUtil.toURI(url);
                 Iterator<Proxy> it = sel.select(uri).iterator();
                 while (it.hasNext()) {
                     p = it.next();
                     if (p == null || p == Proxy.NO_PROXY ||
-                        p.type() == Proxy.Type.SOCKS)
+                        p.type() == Proxy.Type.SOCKS) {
                         break;
+                    }
                     if (p.type() != Proxy.Type.HTTP ||
-                        !(p.address() instanceof InetSocketAddress)) {
+                            !(p.address() instanceof InetSocketAddress)) {
                         sel.connectFailed(uri, p.address(), new IOException("Wrong proxy type"));
                         continue;
                     }
@@ -240,10 +238,14 @@
                     InetSocketAddress paddr = (InetSocketAddress) p.address();
                     try {
                         http = new HttpURLConnection(url, p);
-                        if (connectTimeout >= 0)
+                        http.setDoInput(getDoInput());
+                        http.setDoOutput(getDoOutput());
+                        if (connectTimeout >= 0) {
                             http.setConnectTimeout(connectTimeout);
-                        if (readTimeout >= 0)
+                        }
+                        if (readTimeout >= 0) {
                             http.setReadTimeout(readTimeout);
+                        }
                         http.connect();
                         connected = true;
                         return;
@@ -257,10 +259,14 @@
             p = instProxy;
             if (p.type() == Proxy.Type.HTTP) {
                 http = new HttpURLConnection(url, instProxy);
-                if (connectTimeout >= 0)
+                http.setDoInput(getDoInput());
+                http.setDoOutput(getDoOutput());
+                if (connectTimeout >= 0) {
                     http.setConnectTimeout(connectTimeout);
-                if (readTimeout >= 0)
+                }
+                if (readTimeout >= 0) {
                     http.setReadTimeout(readTimeout);
+                }
                 http.connect();
                 connected = true;
                 return;
@@ -270,31 +276,35 @@
         if (user == null) {
             user = "anonymous";
             String vers = java.security.AccessController.doPrivileged(
-                new GetPropertyAction("java.version"));
+                    new GetPropertyAction("java.version"));
             password = java.security.AccessController.doPrivileged(
-                new GetPropertyAction("ftp.protocol.user",
-                                      "Java" + vers +"@"));
+                    new GetPropertyAction("ftp.protocol.user",
+                                          "Java" + vers + "@"));
         }
         try {
-            if (p != null)
-                ftp = new FtpClient(p);
-            else
-                ftp = new FtpClient();
+            ftp = FtpClient.create();
+            if (p != null) {
+                ftp.setProxy(p);
+            }
             setTimeouts();
-            if (port != -1)
-                ftp.openServer(host, port);
-            else
-                ftp.openServer(host);
+            if (port != -1) {
+                ftp.connect(new InetSocketAddress(host, port));
+            } else {
+                ftp.connect(new InetSocketAddress(host, FtpClient.defaultPort()));
+            }
         } catch (UnknownHostException e) {
             // Maybe do something smart here, like use a proxy like iftp.
             // Just keep throwing for now.
             throw e;
+        } catch (FtpProtocolException fe) {
+            throw new IOException(fe);
         }
         try {
-            ftp.login(user, password);
-        } catch (sun.net.ftp.FtpLoginException e) {
-            ftp.closeServer();
-            throw e;
+            ftp.login(user, password.toCharArray());
+        } catch (sun.net.ftp.FtpProtocolException e) {
+            ftp.close();
+            // Backward compatibility
+            throw new sun.net.ftp.FtpLoginException("Invalid username/password");
         }
         connected = true;
     }
@@ -306,24 +316,29 @@
     private void decodePath(String path) {
         int i = path.indexOf(";type=");
         if (i >= 0) {
-            String s1 = path.substring(i+6, path.length());
-            if ("i".equalsIgnoreCase(s1))
+            String s1 = path.substring(i + 6, path.length());
+            if ("i".equalsIgnoreCase(s1)) {
                 type = BIN;
-            if ("a".equalsIgnoreCase(s1))
+            }
+            if ("a".equalsIgnoreCase(s1)) {
                 type = ASCII;
-            if ("d".equalsIgnoreCase(s1))
+            }
+            if ("d".equalsIgnoreCase(s1)) {
                 type = DIR;
+            }
             path = path.substring(0, i);
         }
         if (path != null && path.length() > 1 &&
-            path.charAt(0) == '/')
+                path.charAt(0) == '/') {
             path = path.substring(1);
-        if (path == null || path.length() == 0)
+        }
+        if (path == null || path.length() == 0) {
             path = "./";
+        }
         if (!path.endsWith("/")) {
             i = path.lastIndexOf('/');
             if (i > 0) {
-                filename = path.substring(i+1, path.length());
+                filename = path.substring(i + 1, path.length());
                 filename = ParseUtil.decode(filename);
                 pathname = path.substring(0, i);
             } else {
@@ -334,10 +349,11 @@
             pathname = path.substring(0, path.length() - 1);
             filename = null;
         }
-        if (pathname != null)
+        if (pathname != null) {
             fullpath = pathname + "/" + (filename != null ? filename : "");
-        else
+        } else {
             fullpath = filename;
+        }
     }
 
     /*
@@ -346,18 +362,19 @@
      * This is because, '/' is not necessarly the directory delimiter
      * on every systems.
      */
-
-    private void cd(String path) throws IOException {
-        if (path == null || "".equals(path))
+    private void cd(String path) throws FtpProtocolException, IOException {
+        if (path == null || path.isEmpty()) {
             return;
+        }
         if (path.indexOf('/') == -1) {
-            ftp.cd(ParseUtil.decode(path));
+            ftp.changeDirectory(ParseUtil.decode(path));
             return;
         }
 
-        StringTokenizer token = new StringTokenizer(path,"/");
-        while (token.hasMoreTokens())
-            ftp.cd(ParseUtil.decode(token.nextToken()));
+        StringTokenizer token = new StringTokenizer(path, "/");
+        while (token.hasMoreTokens()) {
+            ftp.changeDirectory(ParseUtil.decode(token.nextToken()));
+        }
     }
 
     /**
@@ -369,16 +386,19 @@
      * @throws  IOException if already opened for output
      * @throws  FtpProtocolException if errors occur during the transfert.
      */
+    @Override
     public InputStream getInputStream() throws IOException {
         if (!connected) {
             connect();
         }
 
-        if (http != null)
+        if (http != null) {
             return http.getInputStream();
+        }
 
-        if (os != null)
+        if (os != null) {
             throw new IOException("Already opened for output");
+        }
 
         if (is != null) {
             return is;
@@ -386,82 +406,85 @@
 
         MessageHeader msgh = new MessageHeader();
 
+        boolean isAdir = false;
         try {
             decodePath(url.getPath());
             if (filename == null || type == DIR) {
-                ftp.ascii();
+                ftp.setAsciiType();
                 cd(pathname);
-                if (filename == null)
-                    is = new FtpInputStream(ftp, ftp.list());
-                else
+                if (filename == null) {
+                    is = new FtpInputStream(ftp, ftp.list(null));
+                } else {
                     is = new FtpInputStream(ftp, ftp.nameList(filename));
+                }
             } else {
-                if (type == ASCII)
-                    ftp.ascii();
-                else
-                    ftp.binary();
+                if (type == ASCII) {
+                    ftp.setAsciiType();
+                } else {
+                    ftp.setBinaryType();
+                }
                 cd(pathname);
-                is = new FtpInputStream(ftp, ftp.get(filename));
+                is = new FtpInputStream(ftp, ftp.getFileStream(filename));
             }
 
             /* Try to get the size of the file in bytes.  If that is
-               successful, then create a MeteredStream. */
+            successful, then create a MeteredStream. */
             try {
-                String response = ftp.getResponseString();
-                int offset;
+                long l = ftp.getLastTransferSize();
+                msgh.add("content-length", Long.toString(l));
+                if (l > 0) {
 
-                if ((offset = response.indexOf(" bytes)")) != -1) {
-                    int i = offset;
-                    int c;
+                    // Wrap input stream with MeteredStream to ensure read() will always return -1
+                    // at expected length.
 
-                    while (--i >= 0 && ((c = response.charAt(i)) >= '0'
-                                        && c <= '9'))
-                        ;
-                    long l = Long.parseLong(response.substring(i + 1, offset));
-                    msgh.add("content-length", Long.toString(l));
-                    if (l > 0) {
-
-                        // Wrap input stream with MeteredStream to ensure read() will always return -1
-                        // at expected length.
+                    // Check if URL should be metered
+                    boolean meteredInput = ProgressMonitor.getDefault().shouldMeterInput(url, "GET");
+                    ProgressSource pi = null;
 
-                        // Check if URL should be metered
-                        boolean meteredInput = ProgressMonitor.getDefault().shouldMeterInput(url, "GET");
-                        ProgressSource pi = null;
+                    if (meteredInput) {
+                        pi = new ProgressSource(url, "GET", l);
+                        pi.beginTracking();
+                    }
 
-                        if (meteredInput)   {
-                            pi = new ProgressSource(url, "GET", l);
-                            pi.beginTracking();
-                        }
-
-                        is = new MeteredStream(is, pi, l);
-                    }
+                    is = new MeteredStream(is, pi, l);
                 }
             } catch (Exception e) {
                 e.printStackTrace();
-                /* do nothing, since all we were doing was trying to
-                   get the size in bytes of the file */
+            /* do nothing, since all we were doing was trying to
+            get the size in bytes of the file */
             }
 
-            String type = guessContentTypeFromName(fullpath);
-            if (type == null && is.markSupported()) {
-                type = guessContentTypeFromStream(is);
-            }
-            if (type != null) {
-                msgh.add("content-type", type);
+            if (isAdir) {
+                msgh.add("content-type", "text/plain");
+                msgh.add("access-type", "directory");
+            } else {
+                msgh.add("access-type", "file");
+                String ftype = guessContentTypeFromName(fullpath);
+                if (ftype == null && is.markSupported()) {
+                    ftype = guessContentTypeFromStream(is);
+                }
+                if (ftype != null) {
+                    msgh.add("content-type", ftype);
+                }
             }
         } catch (FileNotFoundException e) {
             try {
                 cd(fullpath);
                 /* if that worked, then make a directory listing
-                   and build an html stream with all the files in
-                   the directory */
-                ftp.ascii();
+                and build an html stream with all the files in
+                the directory */
+                ftp.setAsciiType();
 
-                is = new FtpInputStream(ftp, ftp.list());
+                is = new FtpInputStream(ftp, ftp.list(null));
                 msgh.add("content-type", "text/plain");
+                msgh.add("access-type", "directory");
             } catch (IOException ex) {
                 throw new FileNotFoundException(fullpath);
+            } catch (FtpProtocolException ex2) {
+                throw new FileNotFoundException(fullpath);
             }
+        } catch (FtpProtocolException ftpe) {
+            throw new IOException(ftpe);
         }
         setProperties(msgh);
         return is;
@@ -477,31 +500,45 @@
      *          points to a directory
      * @throws  FtpProtocolException if errors occur during the transfert.
      */
+    @Override
     public OutputStream getOutputStream() throws IOException {
         if (!connected) {
             connect();
         }
 
-        if (http != null)
-            return http.getOutputStream();
+        if (http != null) {
+            OutputStream out = http.getOutputStream();
+            // getInputStream() is neccessary to force a writeRequests()
+            // on the http client.
+            http.getInputStream();
+            return out;
+        }
 
-        if (is != null)
+        if (is != null) {
             throw new IOException("Already opened for input");
+        }
 
         if (os != null) {
             return os;
         }
 
         decodePath(url.getPath());
-        if (filename == null || filename.length() == 0)
+        if (filename == null || filename.length() == 0) {
             throw new IOException("illegal filename for a PUT");
-        if (pathname != null)
-            cd(pathname);
-        if (type == ASCII)
-            ftp.ascii();
-        else
-            ftp.binary();
-        os = new FtpOutputStream(ftp, ftp.put(filename));
+        }
+        try {
+            if (pathname != null) {
+                cd(pathname);
+            }
+            if (type == ASCII) {
+                ftp.setAsciiType();
+            } else {
+                ftp.setBinaryType();
+            }
+            os = new FtpOutputStream(ftp, ftp.putFileStream(filename, false));
+        } catch (FtpProtocolException e) {
+            throw new IOException(e);
+        }
         return os;
     }
 
@@ -514,12 +551,13 @@
      *
      * @return  The <code>Permission</code> object.
      */
+    @Override
     public Permission getPermission() {
         if (permission == null) {
-            int port = url.getPort();
-            port = port < 0 ? FtpClient.FTP_PORT : port;
-            String host = this.host + ":" + port;
-            permission = new SocketPermission(host, "connect");
+            int urlport = url.getPort();
+            urlport = urlport < 0 ? FtpClient.defaultPort() : urlport;
+            String urlhost = this.host + ":" + urlport;
+            permission = new SocketPermission(urlhost, "connect");
         }
         return permission;
     }
@@ -534,21 +572,22 @@
      * @throws IllegalStateException if already connected
      * @see #getRequestProperty(java.lang.String)
      */
+    @Override
     public void setRequestProperty(String key, String value) {
-        super.setRequestProperty (key, value);
-        if ("type".equals (key)) {
-            if ("i".equalsIgnoreCase(value))
+        super.setRequestProperty(key, value);
+        if ("type".equals(key)) {
+            if ("i".equalsIgnoreCase(value)) {
                 type = BIN;
-            else if ("a".equalsIgnoreCase(value))
+            } else if ("a".equalsIgnoreCase(value)) {
                 type = ASCII;
-            else
-                if ("d".equalsIgnoreCase(value))
-                    type = DIR;
-            else
+            } else if ("d".equalsIgnoreCase(value)) {
+                type = DIR;
+            } else {
                 throw new IllegalArgumentException(
-                    "Value of '" + key +
-                    "' request property was '" + value +
-                    "' when it must be either 'i', 'a' or 'd'");
+                        "Value of '" + key +
+                        "' request property was '" + value +
+                        "' when it must be either 'i', 'a' or 'd'");
+            }
         }
     }
 
@@ -562,33 +601,41 @@
      * @throws IllegalStateException if already connected
      * @see #setRequestProperty(java.lang.String, java.lang.String)
      */
+    @Override
     public String getRequestProperty(String key) {
-        String value = super.getRequestProperty (key);
+        String value = super.getRequestProperty(key);
 
         if (value == null) {
-            if ("type".equals (key))
+            if ("type".equals(key)) {
                 value = (type == ASCII ? "a" : type == DIR ? "d" : "i");
+            }
         }
 
         return value;
     }
 
+    @Override
     public void setConnectTimeout(int timeout) {
-        if (timeout < 0)
+        if (timeout < 0) {
             throw new IllegalArgumentException("timeouts can't be negative");
+        }
         connectTimeout = timeout;
     }
 
+    @Override
     public int getConnectTimeout() {
         return (connectTimeout < 0 ? 0 : connectTimeout);
     }
 
+    @Override
     public void setReadTimeout(int timeout) {
-        if (timeout < 0)
+        if (timeout < 0) {
             throw new IllegalArgumentException("timeouts can't be negative");
+        }
         readTimeout = timeout;
     }
 
+    @Override
     public int getReadTimeout() {
         return readTimeout < 0 ? 0 : readTimeout;
     }
--- a/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,12 +25,10 @@
 
 package sun.net.www.protocol.http;
 
-import java.io.*;
-import java.net.*;
-import java.util.Hashtable;
-import java.util.LinkedList;
-import java.util.ListIterator;
-import java.util.Enumeration;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.PasswordAuthentication;
+import java.net.URL;
 import java.util.HashMap;
 
 import sun.net.www.HeaderParser;
@@ -51,12 +49,12 @@
 //      policy in HttpURLConnection.  A failure on baz.foo.com shouldn't
 //      uncache foo.com!
 
-abstract class AuthenticationInfo extends AuthCacheValue implements Cloneable {
+public abstract class AuthenticationInfo extends AuthCacheValue implements Cloneable {
 
     // Constants saying what kind of authroization this is.  This determines
     // the namespace in the hash table lookup.
-    static final char SERVER_AUTHENTICATION = 's';
-    static final char PROXY_AUTHENTICATION = 'p';
+    public static final char SERVER_AUTHENTICATION = 's';
+    public static final char PROXY_AUTHENTICATION = 'p';
 
     /**
      * If true, then simultaneous authentication requests to the same realm/proxy
@@ -188,7 +186,7 @@
     String path;
 
     /** Use this constructor only for proxy entries */
-    AuthenticationInfo(char type, AuthScheme authScheme, String host, int port, String realm) {
+    public AuthenticationInfo(char type, AuthScheme authScheme, String host, int port, String realm) {
         this.type = type;
         this.authScheme = authScheme;
         this.protocol = "";
@@ -211,7 +209,7 @@
      * Constructor used to limit the authorization to the path within
      * the URL. Use this constructor for origin server entries.
      */
-    AuthenticationInfo(char type, AuthScheme authScheme, URL url, String realm) {
+    public AuthenticationInfo(char type, AuthScheme authScheme, URL url, String realm) {
         this.type = type;
         this.authScheme = authScheme;
         this.protocol = url.getProtocol().toLowerCase();
@@ -358,13 +356,19 @@
     /**
      * @return true if this authentication supports preemptive authorization
      */
-    abstract boolean supportsPreemptiveAuthorization();
+    public abstract boolean supportsPreemptiveAuthorization();
 
     /**
      * @return the name of the HTTP header this authentication wants set.
      *          This is used for preemptive authorization.
      */
-    abstract String getHeaderName();
+    public String getHeaderName() {
+        if (type == SERVER_AUTHENTICATION) {
+            return "Authorization";
+        } else {
+            return "Proxy-authorization";
+        }
+    }
 
     /**
      * Calculates and returns the authentication header value based
@@ -375,7 +379,7 @@
      * @return the value of the HTTP header this authentication wants set.
      *          Used for preemptive authorization.
      */
-    abstract String getHeaderValue(URL url, String method);
+    public abstract String getHeaderValue(URL url, String method);
 
     /**
      * Set header(s) on the given connection.  Subclasses must override
@@ -386,7 +390,7 @@
      * @param raw The raw header field (if needed)
      * @return true if all goes well, false if no headers were set.
      */
-    abstract boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw);
+    public abstract boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw);
 
     /**
      * Check if the header indicates that the current auth. parameters are stale.
@@ -396,7 +400,7 @@
      * returning false means we have to go back to the user to ask for a new
      * username password.
      */
-    abstract boolean isAuthorizationStale (String header);
+    public abstract boolean isAuthorizationStale (String header);
 
     /**
      * Give a key for hash table lookups.
--- a/src/share/classes/sun/net/www/protocol/http/BasicAuthentication.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/BasicAuthentication.java	Wed Nov 25 11:08:25 2009 -0800
@@ -131,22 +131,12 @@
     /**
      * @return true if this authentication supports preemptive authorization
      */
-    boolean supportsPreemptiveAuthorization() {
+    @Override
+    public boolean supportsPreemptiveAuthorization() {
         return true;
     }
 
     /**
-     * @return the name of the HTTP header this authentication wants set
-     */
-    String getHeaderName() {
-        if (type == SERVER_AUTHENTICATION) {
-            return "Authorization";
-        } else {
-            return "Proxy-authorization";
-        }
-    }
-
-    /**
      * Set header(s) on the given connection. This will only be called for
      * definitive (i.e. non-preemptive) authorization.
      * @param conn The connection to apply the header(s) to
@@ -154,7 +144,8 @@
      * @param raw The raw header values for this connection, if needed.
      * @return true if all goes well, false if no headers were set.
      */
-    boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
+    @Override
+    public boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
         conn.setAuthenticationProperty(getHeaderName(), getHeaderValue(null,null));
         return true;
     }
@@ -162,7 +153,8 @@
     /**
      * @return the value of the HTTP header this authentication wants set
      */
-    String getHeaderValue(URL url, String method) {
+    @Override
+    public String getHeaderValue(URL url, String method) {
         /* For Basic the authorization string does not depend on the request URL
          * or the request method
          */
@@ -174,7 +166,8 @@
      * In other words there is no possibility to reuse the credentials.
      * They are always either valid or invalid.
      */
-    boolean isAuthorizationStale (String header) {
+    @Override
+    public boolean isAuthorizationStale (String header) {
         return false;
     }
 
--- a/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/DigestAuthentication.java	Wed Nov 25 11:08:25 2009 -0800
@@ -200,22 +200,12 @@
     /**
      * @return true if this authentication supports preemptive authorization
      */
-    boolean supportsPreemptiveAuthorization() {
+    @Override
+    public boolean supportsPreemptiveAuthorization() {
         return true;
     }
 
     /**
-     * @return the name of the HTTP header this authentication wants set
-     */
-    String getHeaderName() {
-        if (type == SERVER_AUTHENTICATION) {
-            return "Authorization";
-        } else {
-            return "Proxy-Authorization";
-        }
-    }
-
-    /**
      * Reclaculates the request-digest and returns it.
      *
      * <P> Used in the common case where the requestURI is simply the
@@ -229,7 +219,8 @@
      *
      * @return the value of the HTTP header this authentication wants set
      */
-    String getHeaderValue(URL url, String method) {
+    @Override
+    public String getHeaderValue(URL url, String method) {
         return getHeaderValueImpl(url.getFile(), method);
     }
 
@@ -259,7 +250,8 @@
      * returning false means we have to go back to the user to ask for a new
      * username password.
      */
-    boolean isAuthorizationStale (String header) {
+    @Override
+    public boolean isAuthorizationStale (String header) {
         HeaderParser p = new HeaderParser (header);
         String s = p.findValue ("stale");
         if (s == null || !s.equals("true"))
@@ -279,19 +271,22 @@
      * @param raw Raw header values for this connection, if needed.
      * @return true if all goes well, false if no headers were set.
      */
-    boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
+    @Override
+    public boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
         params.setNonce (p.findValue("nonce"));
         params.setOpaque (p.findValue("opaque"));
         params.setQop (p.findValue("qop"));
 
-        String uri;
+        String uri="";
         String method;
         if (type == PROXY_AUTHENTICATION &&
                 conn.tunnelState() == HttpURLConnection.TunnelState.SETUP) {
             uri = HttpURLConnection.connectRequestURI(conn.getURL());
             method = HTTP_CONNECT;
         } else {
-            uri = conn.getRequestURI();
+            try {
+                uri = conn.getRequestURI();
+            } catch (IOException e) {}
             method = conn.getMethod();
         }
 
--- a/src/share/classes/sun/net/www/protocol/http/HttpLogFormatter.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,131 +0,0 @@
-/*
- * 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 sun.net.www.protocol.http;
-
-import java.util.logging.LogRecord;
-import java.util.regex.*;
-
-/**
- * A Formatter to make the HTTP logs a bit more palatable to the developer
- * looking at them. The idea is to present the HTTP events in such a way that
- * commands and headers are easily spotted (i.e. on separate lines).
- * @author jccollet
- */
-public class HttpLogFormatter extends java.util.logging.SimpleFormatter {
-    // Pattern for MessageHeader data. Mostly pairs within curly brackets
-    private static volatile Pattern pattern = null;
-    // Pattern for Cookies
-    private static volatile Pattern cpattern = null;
-
-    public HttpLogFormatter() {
-        if (pattern == null) {
-            pattern = Pattern.compile("\\{[^\\}]*\\}");
-            cpattern = Pattern.compile("[^,\\] ]{2,}");
-        }
-    }
-
-    @Override
-    public String format(LogRecord record) {
-        String sourceClassName = record.getSourceClassName();
-        if (sourceClassName == null ||
-            !(sourceClassName.startsWith("sun.net.www.protocol.http") ||
-              sourceClassName.startsWith("sun.net.www.http"))) {
-            return super.format(record);
-        }
-        String src = record.getMessage();
-        StringBuilder buf = new StringBuilder("HTTP: ");
-        if (src.startsWith("sun.net.www.MessageHeader@")) {
-            // MessageHeader logs are composed of pairs within curly brackets
-            // Let's extract them to make it more readable. That way we get one
-            // header pair (name, value) per line. A lot easier to read.
-            Matcher match = pattern.matcher(src);
-            while (match.find()) {
-                int i = match.start();
-                int j = match.end();
-                String s = src.substring(i + 1, j - 1);
-                if (s.startsWith("null: ")) {
-                    s = s.substring(6);
-                }
-                if (s.endsWith(": null")) {
-                    s = s.substring(0, s.length() - 6);
-                }
-                buf.append("\t").append(s).append("\n");
-            }
-        } else if (src.startsWith("Cookies retrieved: {")) {
-            // This comes from the Cookie handler, let's clean up the format a bit
-            String s = src.substring(20);
-            buf.append("Cookies from handler:\n");
-            while (s.length() >= 7) {
-                if (s.startsWith("Cookie=[")) {
-                    String s2 = s.substring(8);
-                    int c = s2.indexOf("Cookie2=[");
-                    if (c > 0) {
-                        s2 = s2.substring(0, c-1);
-                        s = s2.substring(c);
-                    } else {
-                        s = "";
-                    }
-                    if (s2.length() < 4) {
-                        continue;
-                    }
-                    Matcher m = cpattern.matcher(s2);
-                    while (m.find()) {
-                        int i = m.start();
-                        int j = m.end();
-                        if (i >= 0) {
-                            String cookie = s2.substring(i + 1, j > 0 ? j - 1 : s2.length() - 1);
-                            buf.append("\t").append(cookie).append("\n");
-                        }
-                    }
-                }
-                if (s.startsWith("Cookie2=[")) {
-                    String s2 = s.substring(9);
-                    int c = s2.indexOf("Cookie=[");
-                    if (c > 0) {
-                        s2 = s2.substring(0, c-1);
-                        s = s2.substring(c);
-                    } else {
-                        s = "";
-                    }
-                    Matcher m = cpattern.matcher(s2);
-                    while (m.find()) {
-                        int i = m.start();
-                        int j = m.end();
-                        if (i >= 0) {
-                            String cookie = s2.substring(i+1, j > 0 ? j-1 : s2.length() - 1);
-                            buf.append("\t").append(cookie).append("\n");
-                        }
-                    }
-                }
-            }
-        } else {
-            // Anything else we let as is.
-            buf.append(src).append("\n");
-        }
-        return buf.toString();
-    }
-
-}
--- a/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/HttpURLConnection.java	Wed Nov 25 11:08:25 2009 -0800
@@ -243,7 +243,7 @@
     private boolean tryTransparentNTLMProxy = true;
 
     /* Used by Windows specific code */
-    Object authObj;
+    private Object authObj;
 
     /* Set if the user is manually setting the Authorization or Proxy-Authorization headers */
     boolean isUserServerAuth;
@@ -332,6 +332,15 @@
         return logger;
     }
 
+    /* Used for Windows NTLM implementation */
+    public Object authObj() {
+        return authObj;
+    }
+
+    public void authObj(Object authObj) {
+        this.authObj = authObj;
+    }
+
     /*
      * checks the validity of http message header and throws
      * IllegalArgumentException if invalid.
@@ -1543,7 +1552,7 @@
      * because ntlm does not support this feature.
      */
     private AuthenticationInfo
-        resetProxyAuthentication(AuthenticationInfo proxyAuthentication, AuthenticationHeader auth) {
+        resetProxyAuthentication(AuthenticationInfo proxyAuthentication, AuthenticationHeader auth) throws IOException {
         if ((proxyAuthentication != null )&&
              proxyAuthentication.getAuthScheme() != NTLM) {
             String raw = auth.raw();
@@ -1767,7 +1776,7 @@
     /**
      * Sets pre-emptive proxy authentication in header
      */
-    private void setPreemptiveProxyAuthentication(MessageHeader requests) {
+    private void setPreemptiveProxyAuthentication(MessageHeader requests) throws IOException {
         AuthenticationInfo pauth
             = AuthenticationInfo.getProxyAuth(http.getProxyHostUsed(),
                                               http.getProxyPortUsed());
@@ -2123,13 +2132,9 @@
 
     String requestURI = null;
 
-    String getRequestURI() {
+    String getRequestURI() throws IOException {
         if (requestURI == null) {
-            try {
-                requestURI = http.getURLFile();
-            } catch (IOException e) {
-                requestURI = "";
-            }
+            requestURI = http.getURLFile();
         }
         return requestURI;
     }
@@ -2529,7 +2534,7 @@
     // Set a property for authentication.  This can safely disregard
     // the connected test.
     //
-    void setAuthenticationProperty(String key, String value) {
+    public void setAuthenticationProperty(String key, String value) {
         checkMessageHeader(key, value);
         requests.set(key, value);
     }
--- a/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/NTLMAuthenticationProxy.java	Wed Nov 25 11:08:25 2009 -0800
@@ -36,7 +36,7 @@
  */
 class NTLMAuthenticationProxy {
     private static Method supportsTA;
-    private static final String clazzStr = "sun.net.www.protocol.http.NTLMAuthentication";
+    private static final String clazzStr = "sun.net.www.protocol.http.ntlm.NTLMAuthentication";
     private static final String supportsTAStr = "supportsTransparentAuth";
 
     static final NTLMAuthenticationProxy proxy = tryLoadNTLMAuthentication();
--- a/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/NegotiateAuthentication.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,17 +25,13 @@
 
 package sun.net.www.protocol.http;
 
+import java.net.URL;
+import java.io.IOException;
+import java.net.Authenticator.RequestorType;
 import java.util.HashMap;
-
 import sun.net.www.HeaderParser;
 import sun.misc.BASE64Decoder;
 import sun.misc.BASE64Encoder;
-import sun.util.logging.PlatformLogger;
-
-import java.net.URL;
-import java.io.IOException;
-import java.net.Authenticator.RequestorType;
-import java.lang.reflect.Constructor;
 import static sun.net.www.protocol.http.AuthScheme.NEGOTIATE;
 import static sun.net.www.protocol.http.AuthScheme.KERBEROS;
 
@@ -78,7 +74,8 @@
     /**
      * @return true if this authentication supports preemptive authorization
      */
-    boolean supportsPreemptiveAuthorization() {
+    @Override
+    public boolean supportsPreemptiveAuthorization() {
         return false;
     }
 
@@ -104,34 +101,24 @@
             return supported.get(hostname);
         }
 
-        try {
-            Negotiator neg = Negotiator.getSupported(hci);
+        Negotiator neg = Negotiator.getNegotiator(hci);
+        if (neg != null) {
             supported.put(hostname, true);
             // the only place cache.put is called. here we can make sure
             // the object is valid and the oneToken inside is not null
             cache.put(hostname, neg);
             return true;
-        } catch(Exception e) {
+        } else {
             supported.put(hostname, false);
             return false;
         }
     }
 
     /**
-     * @return the name of the HTTP header this authentication wants to set
-     */
-    String getHeaderName() {
-        if (type == SERVER_AUTHENTICATION) {
-            return "Authorization";
-        } else {
-            return "Proxy-Authorization";
-        }
-    }
-
-    /**
      * Not supported. Must use the setHeaders() method
      */
-    String getHeaderValue(URL url, String method) {
+    @Override
+    public String getHeaderValue(URL url, String method) {
         throw new RuntimeException ("getHeaderValue not supported");
     }
 
@@ -143,7 +130,8 @@
      * returning false means we have to go back to the user to ask for a new
      * username password.
      */
-    boolean isAuthorizationStale (String header) {
+    @Override
+    public boolean isAuthorizationStale (String header) {
         return false; /* should not be called for Negotiate */
     }
 
@@ -155,7 +143,8 @@
      * @param raw The raw header field.
      * @return true if all goes well, false if no headers were set.
      */
-    synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
+    @Override
+    public synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
 
         try {
             String response;
@@ -177,7 +166,7 @@
     /**
      * return the first token.
      * @returns the token
-     * @throws IOException if <code>Negotiator.getSupported()</code> or
+     * @throws IOException if <code>Negotiator.getNegotiator()</code> or
      *                     <code>Negotiator.firstToken()</code> failed.
      */
     private byte[] firstToken() throws IOException {
@@ -191,11 +180,9 @@
             }
         }
         if (negotiator == null) {
-            try {
-                negotiator = Negotiator.getSupported(hci);
-            } catch(Exception e) {
+            negotiator = Negotiator.getNegotiator(hci);
+            if (negotiator == null) {
                 IOException ioe = new IOException("Cannot initialize Negotiator");
-                ioe.initCause(e);
                 throw ioe;
             }
         }
@@ -228,55 +215,3 @@
     // Currently we ignore this header.
 
 }
-
-/**
- * This abstract class is a bridge to connect NegotiteAuthentication and
- * NegotiatorImpl, so that JAAS and JGSS calls can be made
- */
-abstract class Negotiator {
-    static Negotiator getSupported(HttpCallerInfo hci)
-                throws Exception {
-
-        // These lines are equivalent to
-        //     return new NegotiatorImpl(hci);
-        // The current implementation will make sure NegotiatorImpl is not
-        // directly referenced when compiling, thus smooth the way of building
-        // the J2SE platform where HttpURLConnection is a bootstrap class.
-        //
-        // Makes NegotiatorImpl, and the security classes it references, a
-        // runtime dependency rather than a static one.
-
-        Class clazz;
-        Constructor c;
-        try {
-            clazz = Class.forName("sun.net.www.protocol.http.NegotiatorImpl", true, null);
-            c = clazz.getConstructor(HttpCallerInfo.class);
-        } catch (ClassNotFoundException cnfe) {
-            finest(cnfe);
-            throw cnfe;
-        } catch (ReflectiveOperationException roe) {
-            // if the class is there then something seriously wrong if
-            // the constructor is not.
-            throw new AssertionError(roe);
-        }
-
-        try {
-            return (Negotiator) (c.newInstance(hci));
-        } catch (ReflectiveOperationException roe) {
-            finest(roe);
-            Throwable t = roe.getCause();
-            if (t != null && t instanceof Exception)
-                finest((Exception)t);
-            throw roe;
-        }
-    }
-
-    abstract byte[] firstToken() throws IOException;
-
-    abstract byte[] nextToken(byte[] in) throws IOException;
-
-    static void finest(Exception e) {
-        PlatformLogger logger = HttpURLConnection.getHttpLogger();
-        logger.finest("NegotiateAuthentication: " + e);
-    }
-}
--- a/src/share/classes/sun/net/www/protocol/http/NegotiateCallbackHandler.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,89 +0,0 @@
-/*
- * Copyright 2005-2009 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.net.www.protocol.http;
-import java.io.IOException;
-import java.net.Authenticator;
-import java.net.PasswordAuthentication;
-import java.util.Arrays;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.NameCallback;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-
-/**
- * @since 1.6
- * Special callback handler used in JGSS for the HttpCaller.
- */
-public class NegotiateCallbackHandler implements CallbackHandler {
-
-    private String username;
-    private char[] password;
-
-    private final HttpCallerInfo hci;
-
-    public NegotiateCallbackHandler(HttpCallerInfo hci) {
-        this.hci = hci;
-    }
-
-    public void handle(Callback[] callbacks) throws
-            UnsupportedCallbackException, IOException {
-        for (int i=0; i<callbacks.length; i++) {
-            Callback callBack = callbacks[i];
-
-            if (callBack instanceof NameCallback) {
-                if (username == null) {
-                    PasswordAuthentication passAuth =
-                            Authenticator.requestPasswordAuthentication(
-                            hci.host, hci.addr, hci.port, hci.protocol,
-                            hci.prompt, hci.scheme, hci.url, hci.authType);
-                    username = passAuth.getUserName();
-                    password = passAuth.getPassword();
-                }
-                NameCallback nameCallback =
-                        (NameCallback)callBack;
-                nameCallback.setName(username);
-
-            } else if (callBack instanceof PasswordCallback) {
-                PasswordCallback passwordCallback =
-                        (PasswordCallback)callBack;
-                if (password == null) {
-                    PasswordAuthentication passAuth =
-                            Authenticator.requestPasswordAuthentication(
-                            hci.host, hci.addr, hci.port, hci.protocol,
-                            hci.prompt, hci.scheme, hci.url, hci.authType);
-                    username = passAuth.getUserName();
-                    password = passAuth.getPassword();
-                }
-                passwordCallback.setPassword(password);
-                Arrays.fill(password, ' ');
-            } else {
-                throw new UnsupportedCallbackException(callBack,
-                        "Call back not supported");
-            }
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/Negotiator.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,82 @@
+/*
+ * 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 sun.net.www.protocol.http;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import sun.util.logging.PlatformLogger;
+
+/**
+ * This abstract class is a bridge to connect NegotiteAuthentication and
+ * NegotiatorImpl, so that JAAS and JGSS calls can be made
+ */
+public abstract class Negotiator {
+    static Negotiator getNegotiator(HttpCallerInfo hci) {
+
+        // These lines are equivalent to
+        // return new NegotiatorImpl(hci);
+        // The current implementation will make sure NegotiatorImpl is not
+        // directly referenced when compiling, thus smooth the way of building
+        // the J2SE platform where HttpURLConnection is a bootstrap class.
+        //
+        // Makes NegotiatorImpl, and the security classes it references, a
+        // runtime dependency rather than a static one.
+
+        Class clazz;
+        Constructor c;
+        try {
+            clazz = Class.forName("sun.net.www.protocol.http.spnego.NegotiatorImpl", true, null);
+            c = clazz.getConstructor(HttpCallerInfo.class);
+        } catch (ClassNotFoundException cnfe) {
+            finest(cnfe);
+            return null;
+        } catch (ReflectiveOperationException roe) {
+            // if the class is there then something seriously wrong if
+            // the constructor is not.
+            throw new AssertionError(roe);
+        }
+
+        try {
+            return (Negotiator) (c.newInstance(hci));
+        } catch (ReflectiveOperationException roe) {
+            finest(roe);
+            Throwable t = roe.getCause();
+            if (t != null && t instanceof Exception)
+                finest((Exception)t);
+            return null;
+        }
+    }
+
+    public abstract byte[] firstToken() throws IOException;
+
+    public abstract byte[] nextToken(byte[] in) throws IOException;
+
+    private static void finest(Exception e) {
+        PlatformLogger logger = HttpURLConnection.getHttpLogger();
+        logger.finest("NegotiateAuthentication: " + e);
+    }
+}
+
--- a/src/share/classes/sun/net/www/protocol/http/NegotiatorImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
- * Copyright 2005-2009 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.net.www.protocol.http;
-
-import java.io.IOException;
-
-import org.ietf.jgss.GSSContext;
-import org.ietf.jgss.GSSException;
-import org.ietf.jgss.GSSName;
-import org.ietf.jgss.Oid;
-
-import sun.security.jgss.GSSManagerImpl;
-import sun.security.jgss.GSSUtil;
-import sun.security.jgss.HttpCaller;
-
-/**
- * This class encapsulates all JAAS and JGSS API calls in a separate class
- * outside NegotiateAuthentication.java so that J2SE build can go smoothly
- * without the presence of it.
- *
- * @author weijun.wang@sun.com
- * @since 1.6
- */
-public class NegotiatorImpl extends Negotiator {
-
-    private static final boolean DEBUG =
-        java.security.AccessController.doPrivileged(
-              new sun.security.action.GetBooleanAction("sun.security.krb5.debug"));
-
-    private GSSContext context;
-    private byte[] oneToken;
-
-    /**
-     * Initialize the object, which includes:<ul>
-     * <li>Find out what GSS mechanism to use from the system property
-     * <code>http.negotiate.mechanism.oid</code>, defaults SPNEGO
-     * <li>Creating the GSSName for the target host, "HTTP/"+hostname
-     * <li>Creating GSSContext
-     * <li>A first call to initSecContext</ul>
-     */
-    private void init(HttpCallerInfo hci) throws GSSException {
-        final Oid oid;
-
-        if (hci.scheme.equalsIgnoreCase("Kerberos")) {
-            // we can only use Kerberos mech when the scheme is kerberos
-            oid = GSSUtil.GSS_KRB5_MECH_OID;
-        } else {
-            String pref = java.security.AccessController.doPrivileged(
-                    new java.security.PrivilegedAction<String>() {
-                        public String run() {
-                            return System.getProperty(
-                                "http.auth.preference",
-                                "spnego");
-                        }
-                    });
-            if (pref.equalsIgnoreCase("kerberos")) {
-                oid = GSSUtil.GSS_KRB5_MECH_OID;
-            } else {
-                // currently there is no 3rd mech we can use
-                oid = GSSUtil.GSS_SPNEGO_MECH_OID;
-            }
-        }
-
-        GSSManagerImpl manager = new GSSManagerImpl(
-                new HttpCaller(hci));
-
-        // RFC 4559 4.1 uses uppercase service name "HTTP".
-        // RFC 4120 6.2.1 demands the host be lowercase
-        String peerName = "HTTP@" + hci.host.toLowerCase();
-
-        GSSName serverName = manager.createName(peerName,
-                GSSName.NT_HOSTBASED_SERVICE);
-        context = manager.createContext(serverName,
-                                        oid,
-                                        null,
-                                        GSSContext.DEFAULT_LIFETIME);
-
-        // In order to support credential delegation in HTTP/SPNEGO,
-        // we always request it before initSecContext. The current
-        // implementation will check the OK-AS-DELEGATE flag inside
-        // the service ticket of the web server, and only enable
-        // delegation when this flag is set. This check is only
-        // performed when the GSS caller is CALLER_HTTP_NEGOTIATE,
-        // so all other normal GSS-API calls are not affected.
-
-        context.requestCredDeleg(true);
-        oneToken = context.initSecContext(new byte[0], 0, 0);
-    }
-
-    /**
-     * Constructor
-     * @throws java.io.IOException If negotiator cannot be constructed
-     */
-    public NegotiatorImpl(HttpCallerInfo hci) throws IOException {
-        try {
-            init(hci);
-        } catch (GSSException e) {
-            if (DEBUG) {
-                System.out.println("Negotiate support not initiated, will " +
-                        "fallback to other scheme if allowed. Reason:");
-                e.printStackTrace();
-            }
-            IOException ioe = new IOException("Negotiate support not initiated");
-            ioe.initCause(e);
-            throw ioe;
-        }
-    }
-
-    /**
-     * Return the first token of GSS, in SPNEGO, it's called NegTokenInit
-     * @return the first token
-     */
-    public byte[] firstToken() {
-        return oneToken;
-    }
-
-    /**
-     * Return the rest tokens of GSS, in SPNEGO, it's called NegTokenTarg
-     * @param token the token received from server
-     * @return the next token
-     * @throws java.io.IOException if the token cannot be created successfully
-     */
-    public byte[] nextToken(byte[] token) throws IOException {
-        try {
-            return context.initSecContext(token, 0, token.length);
-        } catch (GSSException e) {
-            if (DEBUG) {
-                System.out.println("Negotiate support cannot continue. Reason:");
-                e.printStackTrace();
-            }
-            IOException ioe = new IOException("Negotiate support cannot continue");
-            ioe.initCause(e);
-            throw ioe;
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/logging/HttpLogFormatter.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,131 @@
+/*
+ * 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 sun.net.www.protocol.http.logging;
+
+import java.util.logging.LogRecord;
+import java.util.regex.*;
+
+/**
+ * A Formatter to make the HTTP logs a bit more palatable to the developer
+ * looking at them. The idea is to present the HTTP events in such a way that
+ * commands and headers are easily spotted (i.e. on separate lines).
+ * @author jccollet
+ */
+public class HttpLogFormatter extends java.util.logging.SimpleFormatter {
+    // Pattern for MessageHeader data. Mostly pairs within curly brackets
+    private static volatile Pattern pattern = null;
+    // Pattern for Cookies
+    private static volatile Pattern cpattern = null;
+
+    public HttpLogFormatter() {
+        if (pattern == null) {
+            pattern = Pattern.compile("\\{[^\\}]*\\}");
+            cpattern = Pattern.compile("[^,\\] ]{2,}");
+        }
+    }
+
+    @Override
+    public String format(LogRecord record) {
+        String sourceClassName = record.getSourceClassName();
+        if (sourceClassName == null ||
+            !(sourceClassName.startsWith("sun.net.www.protocol.http") ||
+              sourceClassName.startsWith("sun.net.www.http"))) {
+            return super.format(record);
+        }
+        String src = record.getMessage();
+        StringBuilder buf = new StringBuilder("HTTP: ");
+        if (src.startsWith("sun.net.www.MessageHeader@")) {
+            // MessageHeader logs are composed of pairs within curly brackets
+            // Let's extract them to make it more readable. That way we get one
+            // header pair (name, value) per line. A lot easier to read.
+            Matcher match = pattern.matcher(src);
+            while (match.find()) {
+                int i = match.start();
+                int j = match.end();
+                String s = src.substring(i + 1, j - 1);
+                if (s.startsWith("null: ")) {
+                    s = s.substring(6);
+                }
+                if (s.endsWith(": null")) {
+                    s = s.substring(0, s.length() - 6);
+                }
+                buf.append("\t").append(s).append("\n");
+            }
+        } else if (src.startsWith("Cookies retrieved: {")) {
+            // This comes from the Cookie handler, let's clean up the format a bit
+            String s = src.substring(20);
+            buf.append("Cookies from handler:\n");
+            while (s.length() >= 7) {
+                if (s.startsWith("Cookie=[")) {
+                    String s2 = s.substring(8);
+                    int c = s2.indexOf("Cookie2=[");
+                    if (c > 0) {
+                        s2 = s2.substring(0, c-1);
+                        s = s2.substring(c);
+                    } else {
+                        s = "";
+                    }
+                    if (s2.length() < 4) {
+                        continue;
+                    }
+                    Matcher m = cpattern.matcher(s2);
+                    while (m.find()) {
+                        int i = m.start();
+                        int j = m.end();
+                        if (i >= 0) {
+                            String cookie = s2.substring(i + 1, j > 0 ? j - 1 : s2.length() - 1);
+                            buf.append("\t").append(cookie).append("\n");
+                        }
+                    }
+                }
+                if (s.startsWith("Cookie2=[")) {
+                    String s2 = s.substring(9);
+                    int c = s2.indexOf("Cookie=[");
+                    if (c > 0) {
+                        s2 = s2.substring(0, c-1);
+                        s = s2.substring(c);
+                    } else {
+                        s = "";
+                    }
+                    Matcher m = cpattern.matcher(s2);
+                    while (m.find()) {
+                        int i = m.start();
+                        int j = m.end();
+                        if (i >= 0) {
+                            String cookie = s2.substring(i+1, j > 0 ? j-1 : s2.length() - 1);
+                            buf.append("\t").append(cookie).append("\n");
+                        }
+                    }
+                }
+            }
+        } else {
+            // Anything else we let as is.
+            buf.append(src).append("\n");
+        }
+        return buf.toString();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/spnego/NegotiateCallbackHandler.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2005-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.net.www.protocol.http.spnego;
+
+import java.io.IOException;
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+import java.util.Arrays;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import sun.net.www.protocol.http.HttpCallerInfo;
+
+/**
+ * @since 1.6
+ * Special callback handler used in JGSS for the HttpCaller.
+ */
+public class NegotiateCallbackHandler implements CallbackHandler {
+
+    private String username;
+    private char[] password;
+
+    private final HttpCallerInfo hci;
+
+    public NegotiateCallbackHandler(HttpCallerInfo hci) {
+        this.hci = hci;
+    }
+
+    public void handle(Callback[] callbacks) throws
+            UnsupportedCallbackException, IOException {
+        for (int i=0; i<callbacks.length; i++) {
+            Callback callBack = callbacks[i];
+
+            if (callBack instanceof NameCallback) {
+                if (username == null) {
+                    PasswordAuthentication passAuth =
+                            Authenticator.requestPasswordAuthentication(
+                            hci.host, hci.addr, hci.port, hci.protocol,
+                            hci.prompt, hci.scheme, hci.url, hci.authType);
+                    username = passAuth.getUserName();
+                    password = passAuth.getPassword();
+                }
+                NameCallback nameCallback =
+                        (NameCallback)callBack;
+                nameCallback.setName(username);
+
+            } else if (callBack instanceof PasswordCallback) {
+                PasswordCallback passwordCallback =
+                        (PasswordCallback)callBack;
+                if (password == null) {
+                    PasswordAuthentication passAuth =
+                            Authenticator.requestPasswordAuthentication(
+                            hci.host, hci.addr, hci.port, hci.protocol,
+                            hci.prompt, hci.scheme, hci.url, hci.authType);
+                    username = passAuth.getUserName();
+                    password = passAuth.getPassword();
+                }
+                passwordCallback.setPassword(password);
+                Arrays.fill(password, ' ');
+            } else {
+                throw new UnsupportedCallbackException(callBack,
+                        "Call back not supported");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/net/www/protocol/http/spnego/NegotiatorImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2005-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.net.www.protocol.http.spnego;
+
+import java.io.IOException;
+
+import org.ietf.jgss.GSSContext;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+
+import sun.net.www.protocol.http.HttpCallerInfo;
+import sun.net.www.protocol.http.Negotiator;
+import sun.security.jgss.GSSManagerImpl;
+import sun.security.jgss.GSSUtil;
+import sun.security.jgss.HttpCaller;
+
+/**
+ * This class encapsulates all JAAS and JGSS API calls in a separate class
+ * outside NegotiateAuthentication.java so that J2SE build can go smoothly
+ * without the presence of it.
+ *
+ * @author weijun.wang@sun.com
+ * @since 1.6
+ */
+public class NegotiatorImpl extends Negotiator {
+
+    private static final boolean DEBUG =
+        java.security.AccessController.doPrivileged(
+              new sun.security.action.GetBooleanAction("sun.security.krb5.debug"));
+
+    private GSSContext context;
+    private byte[] oneToken;
+
+    /**
+     * Initialize the object, which includes:<ul>
+     * <li>Find out what GSS mechanism to use from the system property
+     * <code>http.negotiate.mechanism.oid</code>, defaults SPNEGO
+     * <li>Creating the GSSName for the target host, "HTTP/"+hostname
+     * <li>Creating GSSContext
+     * <li>A first call to initSecContext</ul>
+     */
+    private void init(HttpCallerInfo hci) throws GSSException {
+        final Oid oid;
+
+        if (hci.scheme.equalsIgnoreCase("Kerberos")) {
+            // we can only use Kerberos mech when the scheme is kerberos
+            oid = GSSUtil.GSS_KRB5_MECH_OID;
+        } else {
+            String pref = java.security.AccessController.doPrivileged(
+                    new java.security.PrivilegedAction<String>() {
+                        public String run() {
+                            return System.getProperty(
+                                "http.auth.preference",
+                                "spnego");
+                        }
+                    });
+            if (pref.equalsIgnoreCase("kerberos")) {
+                oid = GSSUtil.GSS_KRB5_MECH_OID;
+            } else {
+                // currently there is no 3rd mech we can use
+                oid = GSSUtil.GSS_SPNEGO_MECH_OID;
+            }
+        }
+
+        GSSManagerImpl manager = new GSSManagerImpl(
+                new HttpCaller(hci));
+
+        // RFC 4559 4.1 uses uppercase service name "HTTP".
+        // RFC 4120 6.2.1 demands the host be lowercase
+        String peerName = "HTTP@" + hci.host.toLowerCase();
+
+        GSSName serverName = manager.createName(peerName,
+                GSSName.NT_HOSTBASED_SERVICE);
+        context = manager.createContext(serverName,
+                                        oid,
+                                        null,
+                                        GSSContext.DEFAULT_LIFETIME);
+
+        // In order to support credential delegation in HTTP/SPNEGO,
+        // we always request it before initSecContext. The current
+        // implementation will check the OK-AS-DELEGATE flag inside
+        // the service ticket of the web server, and only enable
+        // delegation when this flag is set. This check is only
+        // performed when the GSS caller is CALLER_HTTP_NEGOTIATE,
+        // so all other normal GSS-API calls are not affected.
+
+        context.requestCredDeleg(true);
+        oneToken = context.initSecContext(new byte[0], 0, 0);
+    }
+
+    /**
+     * Constructor
+     * @throws java.io.IOException If negotiator cannot be constructed
+     */
+    public NegotiatorImpl(HttpCallerInfo hci) throws IOException {
+        try {
+            init(hci);
+        } catch (GSSException e) {
+            if (DEBUG) {
+                System.out.println("Negotiate support not initiated, will " +
+                        "fallback to other scheme if allowed. Reason:");
+                e.printStackTrace();
+            }
+            IOException ioe = new IOException("Negotiate support not initiated");
+            ioe.initCause(e);
+            throw ioe;
+        }
+    }
+
+    /**
+     * Return the first token of GSS, in SPNEGO, it's called NegTokenInit
+     * @return the first token
+     */
+    @Override
+    public byte[] firstToken() {
+        return oneToken;
+    }
+
+    /**
+     * Return the rest tokens of GSS, in SPNEGO, it's called NegTokenTarg
+     * @param token the token received from server
+     * @return the next token
+     * @throws java.io.IOException if the token cannot be created successfully
+     */
+    @Override
+    public byte[] nextToken(byte[] token) throws IOException {
+        try {
+            return context.initSecContext(token, 0, token.length);
+        } catch (GSSException e) {
+            if (DEBUG) {
+                System.out.println("Negotiate support cannot continue. Reason:");
+                e.printStackTrace();
+            }
+            IOException ioe = new IOException("Negotiate support cannot continue");
+            ioe.initCause(e);
+            throw ioe;
+        }
+    }
+}
--- a/src/share/classes/sun/net/www/protocol/https/HttpsClient.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/net/www/protocol/https/HttpsClient.java	Wed Nov 25 11:08:25 2009 -0800
@@ -54,7 +54,6 @@
 import java.security.AccessController;
 
 import javax.security.auth.x500.X500Principal;
-import javax.security.auth.kerberos.KerberosPrincipal;
 
 import javax.net.ssl.*;
 import sun.security.x509.X500Name;
@@ -466,16 +465,14 @@
             HostnameChecker checker = HostnameChecker.getInstance(
                                                 HostnameChecker.TYPE_TLS);
 
-            Principal principal = getPeerPrincipal();
-            // X.500 principal or Kerberos principal.
-            // (Use ciphersuite check to determine whether Kerberos is present.)
-            if (cipher.startsWith("TLS_KRB5") &&
-                    principal instanceof KerberosPrincipal) {
-                if (!checker.match(host, (KerberosPrincipal)principal)) {
+            // Use ciphersuite to determine whether Kerberos is present.
+            if (cipher.startsWith("TLS_KRB5")) {
+                if (!checker.match(host, getPeerPrincipal())) {
                     throw new SSLPeerUnverifiedException("Hostname checker" +
                                 " failed for Kerberos");
                 }
-            } else {
+            } else { // X.509
+
                 // get the subject's certificate
                 peerCerts = session.getPeerCertificates();
 
--- a/src/share/classes/sun/reflect/misc/MethodUtil.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/reflect/misc/MethodUtil.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2005-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
@@ -44,6 +44,7 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
+import sun.misc.IOUtils;
 import sun.net.www.ParseUtil;
 import sun.security.util.SecurityConstants;
 
@@ -373,34 +374,7 @@
 
         byte[] b;
         try {
-            if (len != -1) {
-                // Read exactly len bytes from the input stream
-                b = new byte[len];
-                while (len > 0) {
-                    int n = in.read(b, b.length - len, len);
-                    if (n == -1) {
-                        throw new IOException("unexpected EOF");
-                    }
-                    len -= n;
-                }
-            } else {
-                b = new byte[8192];
-                int total = 0;
-                while ((len = in.read(b, total, b.length - total)) != -1) {
-                    total += len;
-                    if (total >= b.length) {
-                        byte[] tmp = new byte[total * 2];
-                        System.arraycopy(b, 0, tmp, 0, total);
-                        b = tmp;
-                    }
-                }
-                // Trim array to correct size, if necessary
-                if (total != b.length) {
-                    byte[] tmp = new byte[total];
-                    System.arraycopy(b, 0, tmp, 0, total);
-                    b = tmp;
-                }
-            }
+            b = IOUtils.readFully(in, len, true);
         } finally {
             in.close();
         }
--- a/src/share/classes/sun/security/jca/Providers.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/jca/Providers.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-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
@@ -86,6 +86,9 @@
     private static final String[] jarVerificationProviders = {
         "sun.security.provider.Sun",
         "sun.security.rsa.SunRsaSign",
+        // Note: SunEC *is* in a signed JAR file, but it's not signed
+        // by EC itself. So it's still safe to be listed here.
+        "sun.security.ec.SunEC",
         BACKUP_PROVIDER_CLASSNAME,
     };
 
--- a/src/share/classes/sun/security/jgss/GSSUtil.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/jgss/GSSUtil.java	Wed Nov 25 11:08:25 2009 -0800
@@ -237,7 +237,7 @@
 
         CallbackHandler cb = null;
         if (caller instanceof HttpCaller) {
-            cb = new sun.net.www.protocol.http.NegotiateCallbackHandler(
+            cb = new sun.net.www.protocol.http.spnego.NegotiateCallbackHandler(
                     ((HttpCaller)caller).info());
         } else {
             String defaultHandler =
--- a/src/share/classes/sun/security/krb5/EncryptionKey.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/krb5/EncryptionKey.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Portions Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Portions Copyright 2000-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
@@ -503,7 +503,19 @@
                              + '\n'));
     }
 
+    /**
+     * Find a key with given etype
+     */
     public static EncryptionKey findKey(int etype, EncryptionKey[] keys)
+            throws KrbException {
+        return findKey(etype, null, keys);
+    }
+
+    /**
+     * Find a key with given etype and kvno
+     * @param kvno if null, return any (first?) key
+     */
+    public static EncryptionKey findKey(int etype, Integer kvno, EncryptionKey[] keys)
         throws KrbException {
 
         // check if encryption type is supported
@@ -516,7 +528,8 @@
         for (int i = 0; i < keys.length; i++) {
             ktype = keys[i].getEType();
             if (EType.isSupported(ktype)) {
-                if (etype == ktype) {
+                Integer kv = keys[i].getKeyVersionNumber();
+                if (etype == ktype && (kvno == null || kvno.equals(kv))) {
                     return keys[i];
                 }
             }
@@ -528,8 +541,11 @@
             for (int i = 0; i < keys.length; i++) {
                 ktype = keys[i].getEType();
                 if (ktype == EncryptedData.ETYPE_DES_CBC_CRC ||
-                    ktype == EncryptedData.ETYPE_DES_CBC_MD5) {
-                    return new EncryptionKey(etype, keys[i].getBytes());
+                        ktype == EncryptedData.ETYPE_DES_CBC_MD5) {
+                    Integer kv = keys[i].getKeyVersionNumber();
+                    if (kvno == null || kvno.equals(kv)) {
+                        return new EncryptionKey(etype, keys[i].getBytes());
+                    }
                 }
             }
         }
--- a/src/share/classes/sun/security/krb5/KrbApReq.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/krb5/KrbApReq.java	Wed Nov 25 11:08:25 2009 -0800
@@ -268,7 +268,8 @@
     private void authenticate(EncryptionKey[] keys, InetAddress initiator)
         throws KrbException, IOException {
         int encPartKeyType = apReqMessg.ticket.encPart.getEType();
-        EncryptionKey dkey = EncryptionKey.findKey(encPartKeyType, keys);
+        Integer kvno = apReqMessg.ticket.encPart.getKeyVersionNumber();
+        EncryptionKey dkey = EncryptionKey.findKey(encPartKeyType, kvno, keys);
 
         if (dkey == null) {
             throw new KrbException(Krb5.API_INVALID_ARG,
--- a/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java	Wed Nov 25 11:08:25 2009 -0800
@@ -395,6 +395,28 @@
         }
     }
 
+    /**
+     * Only used by KDC test. This method can specify kvno and does not
+     * remove any old keys.
+     */
+    public void addEntry(PrincipalName service, char[] psswd, int kvno)
+         throws KrbException {
+
+        EncryptionKey[] encKeys = EncryptionKey.acquireSecretKeys(
+            psswd, service.getSalt());
+
+        for (int i = 0; encKeys != null && i < encKeys.length; i++) {
+            int keyType = encKeys[i].getEType();
+            byte[] keyValue = encKeys[i].getBytes();
+            KeyTabEntry newEntry = new KeyTabEntry(service,
+                            service.getRealm(),
+                            new KerberosTime(System.currentTimeMillis()),
+                                               kvno, keyType, keyValue);
+            if (entries == null)
+                entries = new Vector<KeyTabEntry> ();
+            entries.addElement(newEntry);
+        }
+    }
 
     /**
      * Retrieves the key table entry with the specified service name.
--- a/src/share/classes/sun/security/pkcs/SignerInfo.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/pkcs/SignerInfo.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-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
@@ -286,8 +286,6 @@
             }
 
             String digestAlgname = getDigestAlgorithmId().getName();
-            if (digestAlgname.equalsIgnoreCase("SHA"))
-                digestAlgname = "SHA1";
 
             byte[] dataSigned;
 
@@ -337,9 +335,12 @@
             String encryptionAlgname =
                 getDigestEncryptionAlgorithmId().getName();
 
-            if (encryptionAlgname.equalsIgnoreCase("SHA1withDSA"))
-                encryptionAlgname = "DSA";
-            String algname = digestAlgname + "with" + encryptionAlgname;
+            // Workaround: sometimes the encryptionAlgname is actually
+            // a signature name
+            String tmp = AlgorithmId.getEncAlgFromSigAlg(encryptionAlgname);
+            if (tmp != null) encryptionAlgname = tmp;
+            String algname = AlgorithmId.makeSigAlg(
+                    digestAlgname, encryptionAlgname);
 
             Signature sig = Signature.getInstance(algname);
             X509Certificate cert = getCertificate(block);
--- a/src/share/classes/sun/security/provider/SeedGenerator.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/provider/SeedGenerator.java	Wed Nov 25 11:08:25 2009 -0800
@@ -63,13 +63,13 @@
  * @author Gadi Guy
  */
 
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 import java.security.*;
 import java.io.*;
 import java.util.Properties;
 import java.util.Enumeration;
 import java.net.*;
-import java.nio.file.DirectoryStream;
-import java.nio.file.Path;
 import java.util.Random;
 import sun.security.util.Debug;
 
@@ -183,26 +183,38 @@
 
                         // The temporary dir
                         File f = new File(p.getProperty("java.io.tmpdir"));
-                        int count = 0;
-                        DirectoryStream<Path> ds
-                                = f.toPath().newDirectoryStream();
-                        try {
+
+                        // Go thru files in the tmp dir using NIO's
+                        // DirectoryStream. Fallback to File.list()
+                        // if NIO is not available.
+                        if (NIODirectoryStream.isAvailable()) {
+                            int count = 0;
+                            Iterable<?> stream =
+                                    NIODirectoryStream.newDirectoryStream(f);
                             // We use a Random object to choose what file names
                             // should be used. Otherwise on a machine with too
                             // many files, the same first 1024 files always get
                             // used. Any, We make sure the first 512 files are
                             // always used.
                             Random r = new Random();
-                            for (Path path: ds) {
-                                if (count < 512 || r.nextBoolean()) {
-                                    md.update(path.getName().toString().getBytes());
+                            try {
+                                for (Object entry: stream) {
+                                    if (count < 512 || r.nextBoolean()) {
+                                        md.update(NIODirectoryStream.getName(
+                                                entry).getBytes());
+                                    }
+                                    if (count++ > 1024) {
+                                        break;
+                                    }
                                 }
-                                if (count++ > 1024) {
-                                    break;
-                                }
+                            } finally {
+                                ((Closeable)stream).close();
                             }
-                        } finally {
-                            ds.close();
+                        } else {
+                            String[] sa = f.list();
+                            for(int i = 0; i < sa.length; i++) {
+                                md.update(sa[i].getBytes());
+                            }
                         }
                     } catch (Exception ex) {
                         md.update((byte)ex.hashCode());
@@ -505,4 +517,76 @@
 
     }
 
+    /**
+     * A wrapper of NIO DirectoryStream using reflection.
+     */
+    private static class NIODirectoryStream {
+        private static final Class<?> pathClass =
+                getClass("java.nio.file.Path");
+
+        private static final Method toPathMethod =
+                (pathClass == null) ? null : getMethod(File.class, "toPath");
+        private static final Method getNameMethod =
+                getMethod(pathClass, "getName");
+        private static final Method newDirectoryStreamMethod =
+                getMethod(pathClass, "newDirectoryStream");
+
+        private static Class<?> getClass(String name) {
+            try {
+                return Class.forName(name, true, null);
+            } catch (ClassNotFoundException e) {
+                return null;
+            }
+        }
+
+        private static Method getMethod(Class<?> clazz,
+                                        String name,
+                                        Class<?>... paramTypes) {
+            if (clazz != null) {
+                try {
+                    return clazz.getMethod(name, paramTypes);
+                } catch (NoSuchMethodException e) {
+                    throw new AssertionError(e);
+                }
+            } else {
+                return null;
+            }
+        }
+
+        static boolean isAvailable() {
+            return pathClass != null;
+        }
+
+        static Iterable<?> newDirectoryStream(File dir) throws IOException {
+            assert pathClass != null;
+            try {
+                Object path = toPathMethod.invoke(dir);
+                return (Iterable<?>)newDirectoryStreamMethod.invoke(path);
+            } catch (InvocationTargetException e) {
+                Throwable cause = e.getCause();
+                if (cause instanceof IOException)
+                    throw (IOException)cause;
+                if (cause instanceof RuntimeException)
+                    throw (RuntimeException)cause;
+                if (cause instanceof Error)
+                    throw (Error)cause;
+                throw new AssertionError(e);
+            } catch (IllegalAccessException iae) {
+                throw new AssertionError(iae);
+            }
+        }
+
+        static String getName(Object path) {
+            assert pathClass != null;
+            try {
+                Object name = getNameMethod.invoke(path);
+                return name.toString();
+            } catch (InvocationTargetException e) {
+                throw new AssertionError(e);
+            } catch (IllegalAccessException iae) {
+                throw new AssertionError(iae);
+            }
+        }
+    }
 }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/security/provider/certpath/AlgorithmChecker.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,119 @@
+/*
+ * 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 sun.security.provider.certpath;
+
+import java.util.Set;
+import java.util.Collection;
+import java.util.Locale;
+import java.security.cert.Certificate;
+import java.security.cert.X509Certificate;
+import java.security.cert.X509CRL;
+import java.security.cert.CertPathValidatorException;
+import java.security.cert.PKIXCertPathChecker;
+
+import sun.security.x509.AlgorithmId;
+
+/**
+ * AlgorithmChecker is a <code>PKIXCertPathChecker</code> that checks that
+ * the signature algorithm of the specified certificate is not disabled.
+ *
+ * @author      Xuelei Fan
+ */
+final public class AlgorithmChecker extends PKIXCertPathChecker {
+
+    // the disabled algorithms
+    private static final String[] disabledAlgorithms = new String[] {"md2"};
+
+    // singleton instance
+    static final AlgorithmChecker INSTANCE = new AlgorithmChecker();
+
+    /**
+     * Default Constructor
+     */
+    private AlgorithmChecker() {
+        // do nothing
+    }
+
+    /**
+     * Return a AlgorithmChecker instance.
+     */
+    static AlgorithmChecker getInstance() {
+        return INSTANCE;
+    }
+
+    /**
+     * Initializes the internal state of the checker from parameters
+     * specified in the constructor.
+     */
+    public void init(boolean forward) throws CertPathValidatorException {
+        // do nothing
+    }
+
+    public boolean isForwardCheckingSupported() {
+        return false;
+    }
+
+    public Set<String> getSupportedExtensions() {
+        return null;
+    }
+
+    /**
+     * Checks the signature algorithm of the specified certificate.
+     */
+    public void check(Certificate cert, Collection<String> unresolvedCritExts)
+            throws CertPathValidatorException {
+        check(cert);
+    }
+
+    public static void check(Certificate cert)
+            throws CertPathValidatorException {
+        X509Certificate xcert = (X509Certificate)cert;
+        check(xcert.getSigAlgName());
+    }
+
+    static void check(AlgorithmId aid) throws CertPathValidatorException {
+        check(aid.getName());
+    }
+
+    static void check(X509CRL crl) throws CertPathValidatorException {
+        check(crl.getSigAlgName());
+    }
+
+    private static void check(String algName)
+            throws CertPathValidatorException {
+
+        String lowerCaseAlgName = algName.toLowerCase(Locale.ENGLISH);
+
+        for (String disabled : disabledAlgorithms) {
+            // checking the signature algorithm name
+            if (lowerCaseAlgName.indexOf(disabled) != -1) {
+                throw new CertPathValidatorException(
+                    "algorithm check failed: " + algName + " is disabled");
+            }
+        }
+    }
+
+}
--- a/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java	Wed Nov 25 11:08:25 2009 -0800
@@ -289,6 +289,16 @@
         X500Name certIssuer = (X500Name) certImpl.getIssuerDN();
         X500Name crlIssuer = (X500Name) crlImpl.getIssuerDN();
 
+        // check the crl signature algorithm
+        try {
+            AlgorithmChecker.check(crl);
+        } catch (CertPathValidatorException cpve) {
+            if (debug != null) {
+                debug.println("CRL signature algorithm check failed: " + cpve);
+            }
+            return false;
+        }
+
         // if crlIssuer is set, verify that it matches the issuer of the
         // CRL and the CRL contains an IDP extension with the indirectCRL
         // boolean asserted. Otherwise, verify that the CRL issuer matches the
--- a/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/provider/certpath/ForwardBuilder.java	Wed Nov 25 11:08:25 2009 -0800
@@ -719,6 +719,11 @@
         /* we don't perform any validation of the trusted cert */
         if (!isTrustedCert) {
             /*
+             * check that the signature algorithm is not disabled.
+             */
+            AlgorithmChecker.check(cert);
+
+            /*
              * Check CRITICAL private extensions for user checkers that
              * support forward checking (forwardCheckers) and remove
              * ones we know how to check.
--- a/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java	Wed Nov 25 11:08:25 2009 -0800
@@ -275,6 +275,7 @@
         int certPathLen = certList.size();
 
         basicChecker = new BasicChecker(anchor, testDate, sigProvider, false);
+        AlgorithmChecker algorithmChecker= AlgorithmChecker.getInstance();
         KeyChecker keyChecker = new KeyChecker(certPathLen,
             pkixParam.getTargetCertConstraints());
         ConstraintsChecker constraintsChecker =
@@ -291,6 +292,7 @@
         ArrayList<PKIXCertPathChecker> certPathCheckers =
             new ArrayList<PKIXCertPathChecker>();
         // add standard checkers that we will be using
+        certPathCheckers.add(algorithmChecker);
         certPathCheckers.add(keyChecker);
         certPathCheckers.add(constraintsChecker);
         certPathCheckers.add(policyChecker);
--- a/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/provider/certpath/ReverseBuilder.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-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
@@ -347,6 +347,9 @@
             return;
         }
 
+        /* check that the signature algorithm is not disabled. */
+        AlgorithmChecker.check(cert);
+
         /*
          * check for looping - abort a loop if
          * ((we encounter the same certificate twice) AND
--- a/src/share/classes/sun/security/ssl/CipherSuite.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/CipherSuite.java	Wed Nov 25 11:08:25 2009 -0800
@@ -74,7 +74,7 @@
     // Flag indicating if CipherSuite availability can change dynamically.
     // This is the case when we rely on a JCE cipher implementation that
     // may not be available in the installed JCE providers.
-    // It is true because we might not have an ECC or Kerberos implementation.
+    // It is true because we might not have an ECC implementation.
     final static boolean DYNAMIC_AVAILABILITY = true;
 
     private final static boolean ALLOW_ECC = Debug.getBooleanProperty
--- a/src/share/classes/sun/security/ssl/ClientHandshaker.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/ClientHandshaker.java	Wed Nov 25 11:08:25 2009 -0800
@@ -44,9 +44,6 @@
 import javax.net.ssl.*;
 
 import javax.security.auth.Subject;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import sun.security.jgss.krb5.Krb5Util;
-import sun.security.jgss.GSSCaller;
 
 import com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager;
 
@@ -362,9 +359,7 @@
                         subject = AccessController.doPrivileged(
                             new PrivilegedExceptionAction<Subject>() {
                             public Subject run() throws Exception {
-                                return Krb5Util.getSubject(
-                                    GSSCaller.CALLER_SSL_CLIENT,
-                                    getAccSE());
+                                return Krb5Helper.getClientSubject(getAccSE());
                             }});
                     } catch (PrivilegedActionException e) {
                         subject = null;
@@ -375,8 +370,9 @@
                     }
 
                     if (subject != null) {
-                        Set<KerberosPrincipal> principals =
-                                subject.getPrincipals(KerberosPrincipal.class);
+                        // Eliminate dependency on KerberosPrincipal
+                        Set<Principal> principals =
+                            subject.getPrincipals(Principal.class);
                         if (!principals.contains(localPrincipal)) {
                             throw new SSLProtocolException("Server resumed" +
                                 " session with wrong subject identity");
@@ -754,7 +750,7 @@
         case K_KRB5:
         case K_KRB5_EXPORT:
             byte[] secretBytes =
-                ((KerberosClientKeyExchange)m2).getPreMasterSecret().getUnencrypted();
+                ((KerberosClientKeyExchange)m2).getUnencryptedPreMasterSecret();
             preMasterSecret = new SecretKeySpec(secretBytes, "TlsPremasterSecret");
             break;
         case K_DHE_RSA:
--- a/src/share/classes/sun/security/ssl/Debug.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/Debug.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1999-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
@@ -160,7 +160,7 @@
         System.err.println(prefix + ": "+message);
     }
 
-    static void println(PrintStream s, String name, byte[] data) {
+    public static void println(PrintStream s, String name, byte[] data) {
         s.print(name + ":  { ");
         if (data == null) {
             s.print("null");
--- a/src/share/classes/sun/security/ssl/HandshakeInStream.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/HandshakeInStream.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-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
@@ -52,7 +52,7 @@
  *
  * @author David Brownell
  */
-class HandshakeInStream extends InputStream {
+public class HandshakeInStream extends InputStream {
 
     InputRecord r;
 
@@ -196,7 +196,7 @@
         return b;
     }
 
-    byte[] getBytes16() throws IOException {
+    public byte[] getBytes16() throws IOException {
         int len = getInt16();
         byte b[] = new byte[len];
 
--- a/src/share/classes/sun/security/ssl/HandshakeMessage.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/HandshakeMessage.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-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
@@ -23,7 +23,6 @@
  * have any questions.
  */
 
-
 package sun.security.ssl;
 
 import java.io.*;
@@ -73,7 +72,7 @@
  *
  * @author David Brownell
  */
-abstract class HandshakeMessage {
+public abstract class HandshakeMessage {
 
     HandshakeMessage() { }
 
@@ -92,7 +91,7 @@
     static final byte   ht_finished = 20;
 
     /* Class and subclass dynamic debugging support */
-    static final Debug debug = Debug.getInstance("ssl");
+    public static final Debug debug = Debug.getInstance("ssl");
 
     /**
      * Utility method to convert a BigInteger to a byte array in unsigned
@@ -468,7 +467,6 @@
     }
 }
 
-
 /*
  * ServerKeyExchange ... SERVER --> CLIENT
  *
--- a/src/share/classes/sun/security/ssl/HandshakeOutStream.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/HandshakeOutStream.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-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
@@ -41,7 +41,7 @@
  *
  * @author  David Brownell
  */
-class HandshakeOutStream extends OutputStream {
+public class HandshakeOutStream extends OutputStream {
 
     private SSLSocketImpl socket;
     private SSLEngineImpl engine;
@@ -196,7 +196,7 @@
         write(b, 0, b.length);
     }
 
-    void putBytes16(byte b[]) throws IOException {
+    public void putBytes16(byte b[]) throws IOException {
         if (b == null) {
             putInt16(0);
             return;
--- a/src/share/classes/sun/security/ssl/KerberosClientKeyExchange.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/KerberosClientKeyExchange.java	Wed Nov 25 11:08:25 2009 -0800
@@ -29,199 +29,67 @@
 import java.io.PrintStream;
 import java.security.AccessController;
 import java.security.AccessControlContext;
-import java.security.PrivilegedExceptionAction;
-import java.security.PrivilegedActionException;
+import java.security.Principal;
+import java.security.PrivilegedAction;
 import java.security.SecureRandom;
-import java.net.InetAddress;
-
-import javax.security.auth.kerberos.KerberosTicket;
-import javax.security.auth.kerberos.KerberosKey;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import javax.security.auth.kerberos.ServicePermission;
-import sun.security.jgss.GSSCaller;
-
-import sun.security.krb5.EncryptionKey;
-import sun.security.krb5.EncryptedData;
-import sun.security.krb5.PrincipalName;
-import sun.security.krb5.Realm;
-import sun.security.krb5.internal.Ticket;
-import sun.security.krb5.internal.EncTicketPart;
-import sun.security.krb5.internal.crypto.KeyUsage;
-
-import sun.security.jgss.krb5.Krb5Util;
+import javax.crypto.SecretKey;
 
 /**
- * This is Kerberos option in the client key exchange message
- * (CLIENT -> SERVER). It holds the Kerberos ticket and the encrypted
- * premaster secret encrypted with the session key sealed in the ticket.
- * From RFC 2712:
- *  struct
- *  {
- *    opaque Ticket;
- *    opaque authenticator;            // optional
- *    opaque EncryptedPreMasterSecret; // encrypted with the session key
- *                                     // which is sealed in the ticket
- *  } KerberosWrapper;
- *
- *
- * Ticket and authenticator are encrypted as per RFC 1510 (in ASN.1)
- * Encrypted pre-master secret has the same structure as it does for RSA
- * except for Kerberos, the encryption key is the session key instead of
- * the RSA public key.
- *
- * XXX authenticator currently ignored
- *
+ * A helper class that calls the KerberosClientKeyExchange implementation.
  */
-final class KerberosClientKeyExchange extends HandshakeMessage {
+public class KerberosClientKeyExchange extends HandshakeMessage {
+
+    private static final String IMPL_CLASS =
+        "sun.security.ssl.krb5.KerberosClientKeyExchangeImpl";
 
-    private KerberosPreMasterSecret preMaster;
-    private byte[] encodedTicket;
-    private KerberosPrincipal peerPrincipal;
-    private KerberosPrincipal localPrincipal;
+    private static final Class<?> implClass = AccessController.doPrivileged(
+            new PrivilegedAction<Class<?>>() {
+                public Class<?> run() {
+                    try {
+                        return Class.forName(IMPL_CLASS, true, null);
+                    } catch (ClassNotFoundException cnf) {
+                        return null;
+                    }
+                }
+            }
+        );
+    private final KerberosClientKeyExchange impl = createImpl();
 
-    /**
-     * Creates an instance of KerberosClientKeyExchange consisting of the
-     * Kerberos service ticket, authenticator and encrypted premaster secret.
-     * Called by client handshaker.
-     *
-     * @param serverName name of server with which to do handshake;
-     *             this is used to get the Kerberos service ticket
-     * @param protocolVersion Maximum version supported by client (i.e,
-     *          version it requested in client hello)
-     * @param rand random number generator to use for generating pre-master
-     *          secret
-     */
-    KerberosClientKeyExchange(String serverName, boolean isLoopback,
+    private KerberosClientKeyExchange createImpl() {
+        if (getClass() == KerberosClientKeyExchange.class) {
+            try {
+                return (KerberosClientKeyExchange)implClass.newInstance();
+            } catch (InstantiationException e) {
+                throw new AssertionError(e);
+            } catch (IllegalAccessException e) {
+                throw new AssertionError(e);
+            }
+        }
+        return null;
+    }
+
+    public KerberosClientKeyExchange() {
+    }
+
+    public KerberosClientKeyExchange(String serverName, boolean isLoopback,
         AccessControlContext acc, ProtocolVersion protocolVersion,
         SecureRandom rand) throws IOException {
 
-         // Get service ticket
-         KerberosTicket ticket = getServiceTicket(serverName, isLoopback, acc);
-         encodedTicket = ticket.getEncoded();
-
-         // Record the Kerberos principals
-         peerPrincipal = ticket.getServer();
-         localPrincipal = ticket.getClient();
-
-         // Optional authenticator, encrypted using session key,
-         // currently ignored
-
-         // Generate premaster secret and encrypt it using session key
-         EncryptionKey sessionKey = new EncryptionKey(
-                                        ticket.getSessionKeyType(),
-                                        ticket.getSessionKey().getEncoded());
-
-         preMaster = new KerberosPreMasterSecret(protocolVersion,
-             rand, sessionKey);
+        if (impl != null) {
+            init(serverName, isLoopback, acc, protocolVersion, rand);
+        } else {
+            throw new IllegalStateException("Kerberos is unavailable");
+        }
     }
 
-    /**
-     * Creates an instance of KerberosClientKeyExchange from its ASN.1 encoding.
-     * Used by ServerHandshaker to verify and obtain premaster secret.
-     *
-     * @param protocolVersion current protocol version
-     * @param clientVersion version requested by client in its ClientHello;
-     *          used by premaster secret version check
-     * @param rand random number generator used for generating random
-     *          premaster secret if ticket and/or premaster verification fails
-     * @param input inputstream from which to get ASN.1-encoded KerberosWrapper
-     * @param serverKey server's master secret key
-     */
-    KerberosClientKeyExchange(ProtocolVersion protocolVersion,
-        ProtocolVersion clientVersion,
-        SecureRandom rand, HandshakeInStream input, KerberosKey[] serverKeys)
-        throws IOException {
-
-        // Read ticket
-        encodedTicket = input.getBytes16();
-
-        if (debug != null && Debug.isOn("verbose")) {
-            Debug.println(System.out,
-                "encoded Kerberos service ticket", encodedTicket);
-        }
-
-        EncryptionKey sessionKey = null;
-
-        try {
-            Ticket t = new Ticket(encodedTicket);
-
-            EncryptedData encPart = t.encPart;
-            PrincipalName ticketSname = t.sname;
-            Realm ticketRealm = t.realm;
-
-            String serverPrincipal = serverKeys[0].getPrincipal().getName();
-
-            /*
-             * permission to access and use the secret key of the Kerberized
-             * "host" service is done in ServerHandshaker.getKerberosKeys()
-             * to ensure server has the permission to use the secret key
-             * before promising the client
-             */
+    public KerberosClientKeyExchange(ProtocolVersion protocolVersion,
+        ProtocolVersion clientVersion, SecureRandom rand,
+        HandshakeInStream input, SecretKey[] serverKeys) throws IOException {
 
-            // Check that ticket Sname matches serverPrincipal
-            String ticketPrinc = ticketSname.toString().concat("@" +
-                                        ticketRealm.toString());
-            if (!ticketPrinc.equals(serverPrincipal)) {
-                if (debug != null && Debug.isOn("handshake"))
-                   System.out.println("Service principal in Ticket does not"
-                        + " match associated principal in KerberosKey");
-                throw new IOException("Server principal is " +
-                    serverPrincipal + " but ticket is for " +
-                    ticketPrinc);
-            }
-
-            // See if we have the right key to decrypt the ticket to get
-            // the session key.
-            int encPartKeyType = encPart.getEType();
-            KerberosKey dkey = findKey(encPartKeyType, serverKeys);
-            if (dkey == null) {
-                // %%% Should print string repr of etype
-                throw new IOException(
-        "Cannot find key of appropriate type to decrypt ticket - need etype " +
-                                   encPartKeyType);
-            }
-
-            EncryptionKey secretKey = new EncryptionKey(
-                encPartKeyType,
-                dkey.getEncoded());
-
-            // Decrypt encPart using server's secret key
-            byte[] bytes = encPart.decrypt(secretKey, KeyUsage.KU_TICKET);
-
-            // Reset data stream after decryption, remove redundant bytes
-            byte[] temp = encPart.reset(bytes, true);
-            EncTicketPart encTicketPart = new EncTicketPart(temp);
-
-            // Record the Kerberos Principals
-            peerPrincipal =
-                new KerberosPrincipal(encTicketPart.cname.getName());
-            localPrincipal = new KerberosPrincipal(ticketSname.getName());
-
-            sessionKey = encTicketPart.key;
-
-            if (debug != null && Debug.isOn("handshake")) {
-                System.out.println("server principal: " + serverPrincipal);
-                System.out.println("realm: " + encTicketPart.crealm.toString());
-                System.out.println("cname: " + encTicketPart.cname.toString());
-            }
-        } catch (IOException e) {
-            throw e;
-        } catch (Exception e) {
-            if (debug != null && Debug.isOn("handshake")) {
-                System.out.println("KerberosWrapper error getting session key,"
-                        + " generating random secret (" + e.getMessage() + ")");
-            }
-            sessionKey = null;
-        }
-
-        input.getBytes16();   // XXX Read and ignore authenticator
-
-        if (sessionKey != null) {
-            preMaster = new KerberosPreMasterSecret(protocolVersion,
-                clientVersion, rand, input, sessionKey);
+        if (impl != null) {
+            init(protocolVersion, clientVersion, rand, input, serverKeys);
         } else {
-            // Generate bogus premaster secret
-            preMaster = new KerberosPreMasterSecret(protocolVersion, rand);
+            throw new IllegalStateException("Kerberos is unavailable");
         }
     }
 
@@ -229,138 +97,46 @@
         return ht_client_key_exchange;
     }
 
-    int messageLength() {
-        return (6 + encodedTicket.length + preMaster.getEncrypted().length);
+    public int  messageLength() {
+        return impl.messageLength();
+    }
+
+    public void send(HandshakeOutStream s) throws IOException {
+        impl.send(s);
     }
 
-    void send(HandshakeOutStream s) throws IOException {
-        s.putBytes16(encodedTicket);
-        s.putBytes16(null); // XXX no authenticator
-        s.putBytes16(preMaster.getEncrypted());
+    @Override
+    public void print(PrintStream p) throws IOException {
+        impl.print(p);
     }
 
-    void print(PrintStream s) throws IOException {
-        s.println("*** ClientKeyExchange, Kerberos");
+    public void init(String serverName, boolean isLoopback,
+        AccessControlContext acc, ProtocolVersion protocolVersion,
+        SecureRandom rand) throws IOException {
 
-        if (debug != null && Debug.isOn("verbose")) {
-            Debug.println(s, "Kerberos service ticket", encodedTicket);
-            Debug.println(s, "Random Secret", preMaster.getUnencrypted());
-            Debug.println(s, "Encrypted random Secret",
-                preMaster.getEncrypted());
+        if (impl != null) {
+            impl.init(serverName, isLoopback, acc, protocolVersion, rand);
         }
     }
 
-    // Similar to sun.security.jgss.krb5.Krb5InitCredenetial/Krb5Context
-    private static KerberosTicket getServiceTicket(String srvName,
-        boolean isLoopback, final AccessControlContext acc) throws IOException {
-
-        // get the local hostname if srvName is loopback address
-        String serverName = srvName;
-        if (isLoopback) {
-            String localHost = java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction<String>() {
-                public String run() {
-                    String hostname;
-                    try {
-                        hostname = InetAddress.getLocalHost().getHostName();
-                    } catch (java.net.UnknownHostException e) {
-                        hostname = "localhost";
-                    }
-                    return hostname;
-                }
-            });
-          serverName = localHost;
-        }
+    public void init(ProtocolVersion protocolVersion,
+        ProtocolVersion clientVersion, SecureRandom rand,
+        HandshakeInStream input, SecretKey[] serverKeys) throws IOException {
 
-        // Resolve serverName (possibly in IP addr form) to Kerberos principal
-        // name for service with hostname
-        String serviceName = "host/" + serverName;
-        PrincipalName principal;
-        try {
-            principal = new PrincipalName(serviceName,
-                                PrincipalName.KRB_NT_SRV_HST);
-        } catch (SecurityException se) {
-            throw se;
-        } catch (Exception e) {
-            IOException ioe = new IOException("Invalid service principal" +
-                                " name: " + serviceName);
-            ioe.initCause(e);
-            throw ioe;
-        }
-        String realm = principal.getRealmAsString();
-
-        final String serverPrincipal = principal.toString();
-        final String tgsPrincipal = "krbtgt/" + realm + "@" + realm;
-        final String clientPrincipal = null;  // use default
-
-
-        // check permission to obtain a service ticket to initiate a
-        // context with the "host" service
-        SecurityManager sm = System.getSecurityManager();
-        if (sm != null) {
-           sm.checkPermission(new ServicePermission(serverPrincipal,
-                                "initiate"), acc);
-        }
-
-        try {
-            KerberosTicket ticket = AccessController.doPrivileged(
-                new PrivilegedExceptionAction<KerberosTicket>() {
-                public KerberosTicket run() throws Exception {
-                    return Krb5Util.getTicketFromSubjectAndTgs(
-                        GSSCaller.CALLER_SSL_CLIENT,
-                        clientPrincipal, serverPrincipal,
-                        tgsPrincipal, acc);
-                        }});
-
-            if (ticket == null) {
-                throw new IOException("Failed to find any kerberos service" +
-                        " ticket for " + serverPrincipal);
-            }
-            return ticket;
-        } catch (PrivilegedActionException e) {
-            IOException ioe = new IOException(
-                "Attempt to obtain kerberos service ticket for " +
-                        serverPrincipal + " failed!");
-            ioe.initCause(e);
-            throw ioe;
+        if (impl != null) {
+            impl.init(protocolVersion, clientVersion, rand, input, serverKeys);
         }
     }
 
-    KerberosPreMasterSecret getPreMasterSecret() {
-        return preMaster;
-    }
-
-    KerberosPrincipal getPeerPrincipal() {
-        return peerPrincipal;
-    }
-
-    KerberosPrincipal getLocalPrincipal() {
-        return localPrincipal;
+    public byte[] getUnencryptedPreMasterSecret() {
+        return impl.getUnencryptedPreMasterSecret();
     }
 
-    private static KerberosKey findKey(int etype, KerberosKey[] keys) {
-        int ktype;
-        for (int i = 0; i < keys.length; i++) {
-            ktype = keys[i].getKeyType();
-            if (etype == ktype) {
-                return keys[i];
-            }
-        }
-        // Key not found.
-        // %%% kludge to allow DES keys to be used for diff etypes
-        if ((etype == EncryptedData.ETYPE_DES_CBC_CRC ||
-            etype == EncryptedData.ETYPE_DES_CBC_MD5)) {
-            for (int i = 0; i < keys.length; i++) {
-                ktype = keys[i].getKeyType();
-                if (ktype == EncryptedData.ETYPE_DES_CBC_CRC ||
-                    ktype == EncryptedData.ETYPE_DES_CBC_MD5) {
-                    return new KerberosKey(keys[i].getPrincipal(),
-                        keys[i].getEncoded(),
-                        etype,
-                        keys[i].getVersionNumber());
-                }
-            }
-        }
-        return null;
+    public Principal getPeerPrincipal(){
+        return impl.getPeerPrincipal();
+    }
+
+    public Principal getLocalPrincipal(){
+        return impl.getLocalPrincipal();
     }
 }
--- a/src/share/classes/sun/security/ssl/KerberosPreMasterSecret.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,223 +0,0 @@
-/*
- * Copyright 2003-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 sun.security.ssl;
-
-import java.io.*;
-import java.security.*;
-import java.security.interfaces.*;
-
-import javax.net.ssl.*;
-
-import sun.security.krb5.EncryptionKey;
-import sun.security.krb5.EncryptedData;
-import sun.security.krb5.KrbException;
-import sun.security.krb5.internal.crypto.KeyUsage;
-
-/**
- * This is the Kerberos premaster secret in the Kerberos client key
- * exchange message (CLIENT --> SERVER); it holds the
- * Kerberos-encrypted pre-master secret. The secret is encrypted using the
- * Kerberos session key.  The padding and size of the resulting message
- * depends on the session key type, but the pre-master secret is
- * always exactly 48 bytes.
- *
- */
-final class KerberosPreMasterSecret {
-
-    private ProtocolVersion protocolVersion; // preMaster [0,1]
-    private byte preMaster[];           // 48 bytes
-    private byte encrypted[];
-
-    /**
-     * Constructor used by client to generate premaster secret.
-     *
-     * Client randomly creates a pre-master secret and encrypts it
-     * using the Kerberos session key; only the server can decrypt
-     * it, using the session key available in the service ticket.
-     *
-     * @param protocolVersion used to set preMaster[0,1]
-     * @param generator random number generator for generating premaster secret
-     * @param sessionKey Kerberos session key for encrypting premaster secret
-     */
-    KerberosPreMasterSecret(ProtocolVersion protocolVersion,
-        SecureRandom generator, EncryptionKey sessionKey) throws IOException {
-
-        if (sessionKey.getEType() ==
-            EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
-            throw new IOException(
-               "session keys with des3-cbc-hmac-sha1-kd encryption type " +
-               "are not supported for TLS Kerberos cipher suites");
-        }
-
-        this.protocolVersion = protocolVersion;
-        preMaster = generatePreMaster(generator, protocolVersion);
-
-        // Encrypt premaster secret
-        try {
-            EncryptedData eData = new EncryptedData(sessionKey, preMaster,
-                KeyUsage.KU_UNKNOWN);
-            encrypted = eData.getBytes();  // not ASN.1 encoded.
-
-        } catch (KrbException e) {
-            throw (SSLKeyException)new SSLKeyException
-                ("Kerberos premaster secret error").initCause(e);
-        }
-    }
-
-    /*
-     * Constructor used by server to decrypt encrypted premaster secret.
-     * The protocol version in preMaster[0,1] must match either currentVersion
-     * or clientVersion, otherwise, the premaster secret is set to
-     * a random one to foil possible attack.
-     *
-     * @param currentVersion version of protocol being used
-     * @param clientVersion version requested by client
-     * @param generator random number generator used to generate
-     *        bogus premaster secret if premaster secret verification fails
-     * @param input input stream from which to read the encrypted
-     *        premaster secret
-     * @param sessionKey Kerberos session key to be used for decryption
-     */
-    KerberosPreMasterSecret(ProtocolVersion currentVersion,
-        ProtocolVersion clientVersion,
-        SecureRandom generator, HandshakeInStream input,
-        EncryptionKey sessionKey) throws IOException {
-
-         // Extract encrypted premaster secret from message
-         encrypted = input.getBytes16();
-
-         if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
-            if (encrypted != null) {
-                Debug.println(System.out,
-                     "encrypted premaster secret", encrypted);
-            }
-         }
-
-        if (sessionKey.getEType() ==
-            EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
-            throw new IOException(
-               "session keys with des3-cbc-hmac-sha1-kd encryption type " +
-               "are not supported for TLS Kerberos cipher suites");
-        }
-
-         // Decrypt premaster secret
-         try {
-            EncryptedData data = new EncryptedData(sessionKey.getEType(),
-                        null /* optional kvno */, encrypted);
-
-            byte[] temp = data.decrypt(sessionKey, KeyUsage.KU_UNKNOWN);
-            if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
-                 if (encrypted != null) {
-                     Debug.println(System.out,
-                         "decrypted premaster secret", temp);
-                 }
-            }
-
-            // Reset data stream after decryption, remove redundant bytes
-            preMaster =  data.reset(temp, false);
-
-            protocolVersion = ProtocolVersion.valueOf(preMaster[0],
-                 preMaster[1]);
-            if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
-                 System.out.println("Kerberos PreMasterSecret version: "
-                        + protocolVersion);
-            }
-        } catch (Exception e) {
-            // catch exception & process below
-            preMaster = null;
-            protocolVersion = currentVersion;
-        }
-
-        // check if the premaster secret version is ok
-        // the specification says that it must be the maximum version supported
-        // by the client from its ClientHello message. However, many
-        // implementations send the negotiated version, so accept both
-        // NOTE that we may be comparing two unsupported version numbers in
-        // the second case, which is why we cannot use object references
-        // equality in this special case
-        boolean versionMismatch = (protocolVersion != currentVersion) &&
-                                  (protocolVersion.v != clientVersion.v);
-
-
-        /*
-         * Bogus decrypted ClientKeyExchange? If so, conjure a
-         * a random preMaster secret that will fail later during
-         * Finished message processing. This is a countermeasure against
-         * the "interactive RSA PKCS#1 encryption envelop attack" reported
-         * in June 1998. Preserving the executation path will
-         * mitigate timing attacks and force consistent error handling
-         * that will prevent an attacking client from differentiating
-         * different kinds of decrypted ClientKeyExchange bogosities.
-         */
-         if ((preMaster == null) || (preMaster.length != 48)
-                || versionMismatch) {
-            if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
-                System.out.println("Kerberos PreMasterSecret error, "
-                                   + "generating random secret");
-                if (preMaster != null) {
-                    Debug.println(System.out, "Invalid secret", preMaster);
-                }
-            }
-            preMaster = generatePreMaster(generator, currentVersion);
-            protocolVersion = currentVersion;
-        }
-    }
-
-    /*
-     * Used by server to generate premaster secret in case of
-     * problem decoding ticket.
-     *
-     * @param protocolVersion used for preMaster[0,1]
-     * @param generator random number generator to use for generating secret.
-     */
-    KerberosPreMasterSecret(ProtocolVersion protocolVersion,
-        SecureRandom generator) {
-
-        this.protocolVersion = protocolVersion;
-        preMaster = generatePreMaster(generator, protocolVersion);
-    }
-
-    private static byte[] generatePreMaster(SecureRandom rand,
-        ProtocolVersion ver) {
-
-        byte[] pm = new byte[48];
-        rand.nextBytes(pm);
-        pm[0] = ver.major;
-        pm[1] = ver.minor;
-
-        return pm;
-    }
-
-    // Clone not needed; package internal use only
-    byte[] getUnencrypted() {
-        return preMaster;
-    }
-
-    // Clone not needed; package internal use only
-    byte[] getEncrypted() {
-        return encrypted;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/security/ssl/Krb5Helper.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,126 @@
+/*
+ * 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 sun.security.ssl;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.Permission;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import javax.crypto.SecretKey;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
+
+/**
+ * A helper class for Kerberos APIs.
+ */
+public final class Krb5Helper {
+
+    private Krb5Helper() { }
+
+    // loads Krb5Proxy implementation class if available
+    private static final String IMPL_CLASS =
+        "sun.security.ssl.krb5.Krb5ProxyImpl";
+
+    private static final Krb5Proxy proxy =
+        AccessController.doPrivileged(new PrivilegedAction<Krb5Proxy>() {
+            public Krb5Proxy run() {
+                try {
+                    Class<?> c = Class.forName(IMPL_CLASS, true, null);
+                    return (Krb5Proxy)c.newInstance();
+                } catch (ClassNotFoundException cnf) {
+                    return null;
+                } catch (InstantiationException e) {
+                    throw new AssertionError(e);
+                } catch (IllegalAccessException e) {
+                    throw new AssertionError(e);
+                }
+            }});
+
+    /**
+     * Returns true if Kerberos is available.
+     */
+    public static boolean isAvailable() {
+        return proxy != null;
+    }
+
+    private static void ensureAvailable() {
+        if (proxy == null)
+            throw new AssertionError("Kerberos should have been available");
+    }
+
+    /**
+     * Returns the Subject associated with client-side of the SSL socket.
+     */
+    public static Subject getClientSubject(AccessControlContext acc)
+            throws LoginException {
+        ensureAvailable();
+        return proxy.getClientSubject(acc);
+    }
+
+    /**
+     * Returns the Subject associated with server-side of the SSL socket.
+     */
+    public static Subject getServerSubject(AccessControlContext acc)
+            throws LoginException {
+        ensureAvailable();
+        return proxy.getServerSubject(acc);
+    }
+
+    /**
+     * Returns the KerberosKeys for the default server-side principal.
+     */
+    public static SecretKey[] getServerKeys(AccessControlContext acc)
+            throws LoginException {
+        ensureAvailable();
+        return proxy.getServerKeys(acc);
+    }
+
+    /**
+     * Returns the server-side principal name associated with the KerberosKey.
+     */
+    public static String getServerPrincipalName(SecretKey kerberosKey) {
+        ensureAvailable();
+        return proxy.getServerPrincipalName(kerberosKey);
+    }
+
+    /**
+     * Returns the hostname embedded in the principal name.
+     */
+    public static String getPrincipalHostName(Principal principal) {
+        ensureAvailable();
+        return proxy.getPrincipalHostName(principal);
+    }
+
+    /**
+     * Returns a ServicePermission for the principal name and action.
+     */
+    public static Permission getServicePermission(String principalName,
+            String action) {
+        ensureAvailable();
+        return proxy.getServicePermission(principalName, action);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/security/ssl/Krb5Proxy.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,71 @@
+/*
+ * 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 sun.security.ssl;
+
+import java.security.AccessControlContext;
+import java.security.Permission;
+import java.security.Principal;
+import javax.crypto.SecretKey;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
+
+/**
+ * An interface to a subset of the Kerberos APIs to avoid a static dependency
+ * on the types defined by these APIs.
+ */
+public interface Krb5Proxy {
+
+    /**
+     * Returns the Subject associated with the client-side of the SSL socket.
+     */
+    Subject getClientSubject(AccessControlContext acc) throws LoginException;
+
+    /**
+     * Returns the Subject associated with the server-side of the SSL socket.
+     */
+    Subject getServerSubject(AccessControlContext acc) throws LoginException;
+
+
+    /**
+     * Returns the KerberosKeys for the default server-side principal.
+     */
+    SecretKey[] getServerKeys(AccessControlContext acc) throws LoginException;
+
+    /**
+     * Returns the server-side principal name associated with the KerberosKey.
+     */
+    String getServerPrincipalName(SecretKey kerberosKey);
+
+    /**
+     * Returns the hostname embedded in the principal name.
+     */
+    String getPrincipalHostName(Principal principal);
+
+    /**
+     * Returns a ServicePermission for the principal name and action.
+     */
+    Permission getServicePermission(String principalName, String action);
+}
--- a/src/share/classes/sun/security/ssl/ProtocolVersion.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/ProtocolVersion.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2002-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
@@ -45,7 +45,7 @@
  * @author  Andreas Sterbenz
  * @since   1.4.1
  */
-final class ProtocolVersion {
+public final class ProtocolVersion {
 
     // dummy protocol version value for invalid SSLSession
     final static ProtocolVersion NONE = new ProtocolVersion(-1, "NONE");
@@ -80,10 +80,10 @@
 
     // version in 16 bit MSB format as it appears in records and
     // messages, i.e. 0x0301 for TLS 1.0
-    final int v;
+    public final int v;
 
     // major and minor version
-    final byte major, minor;
+    public final byte major, minor;
 
     // name used in JSSE (e.g. TLSv1 for TLS 1.0)
     final String name;
@@ -117,7 +117,7 @@
      * Return a ProtocolVersion with the specified major and minor version
      * numbers. Never throws exceptions.
      */
-    static ProtocolVersion valueOf(int major, int minor) {
+    public static ProtocolVersion valueOf(int major, int minor) {
         major &= 0xff;
         minor &= 0xff;
         int v = (major << 8) | minor;
--- a/src/share/classes/sun/security/ssl/SSLSessionImpl.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/SSLSessionImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -48,7 +48,6 @@
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLPermission;
 
-import javax.security.auth.kerberos.KerberosPrincipal;
 import javax.security.auth.x500.X500Principal;
 
 import static sun.security.ssl.CipherSuite.*;
@@ -469,8 +468,8 @@
      * defining the session.
      *
      * @return the peer's principal. Returns an X500Principal of the
-     * end-entity certiticate for X509-based cipher suites, and
-     * KerberosPrincipal for Kerberos cipher suites.
+     * end-entity certificate for X509-based cipher suites, and
+     * Principal for Kerberos cipher suites.
      *
      * @throws SSLPeerUnverifiedException if the peer's identity has not
      *          been verified
@@ -483,7 +482,8 @@
             if (peerPrincipal == null) {
                 throw new SSLPeerUnverifiedException("peer not authenticated");
             } else {
-                return (KerberosPrincipal)peerPrincipal;
+                // Eliminate dependency on KerberosPrincipal
+                return peerPrincipal;
             }
         }
         if (peerCerts == null) {
@@ -497,15 +497,15 @@
      *
      * @return the principal sent to the peer. Returns an X500Principal
      * of the end-entity certificate for X509-based cipher suites, and
-     * KerberosPrincipal for Kerberos cipher suites. If no principal was
+     * Principal for Kerberos cipher suites. If no principal was
      * sent, then null is returned.
      */
     public Principal getLocalPrincipal() {
 
         if ((cipherSuite.keyExchange == K_KRB5) ||
             (cipherSuite.keyExchange == K_KRB5_EXPORT)) {
-                return (localPrincipal == null ? null :
-                        (KerberosPrincipal)localPrincipal);
+                // Eliminate dependency on KerberosPrincipal
+                return (localPrincipal == null ? null : localPrincipal);
         }
         return (localCerts == null ? null :
                 localCerts[0].getSubjectX500Principal());
--- a/src/share/classes/sun/security/ssl/ServerHandshaker.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/ssl/ServerHandshaker.java	Wed Nov 25 11:08:25 2009 -0800
@@ -39,11 +39,6 @@
 import javax.net.ssl.*;
 
 import javax.security.auth.Subject;
-import javax.security.auth.kerberos.KerberosKey;
-import javax.security.auth.kerberos.KerberosPrincipal;
-import javax.security.auth.kerberos.ServicePermission;
-import sun.security.jgss.krb5.Krb5Util;
-import sun.security.jgss.GSSCaller;
 
 import com.sun.net.ssl.internal.ssl.X509ExtendedTrustManager;
 
@@ -69,7 +64,7 @@
     private X509Certificate[]   certs;
     private PrivateKey          privateKey;
 
-    private KerberosKey[]       kerberosKeys;
+    private SecretKey[]       kerberosKeys;
 
     // flag to check for clientCertificateVerify message
     private boolean             needClientVerify = false;
@@ -366,9 +361,8 @@
                             subject = AccessController.doPrivileged(
                                 new PrivilegedExceptionAction<Subject>() {
                                 public Subject run() throws Exception {
-                                    return Krb5Util.getSubject(
-                                        GSSCaller.CALLER_SSL_SERVER,
-                                        getAccSE());
+                                    return
+                                        Krb5Helper.getServerSubject(getAccSE());
                             }});
                         } catch (PrivilegedActionException e) {
                             subject = null;
@@ -379,8 +373,9 @@
                         }
 
                         if (subject != null) {
-                            Set<KerberosPrincipal> principals =
-                                subject.getPrincipals(KerberosPrincipal.class);
+                            // Eliminate dependency on KerberosPrincipal
+                            Set<Principal> principals =
+                                subject.getPrincipals(Principal.class);
                             if (!principals.contains(localPrincipal)) {
                                 resumingSession = false;
                                 if (debug != null && Debug.isOn("session")) {
@@ -914,11 +909,11 @@
         try {
             final AccessControlContext acc = getAccSE();
             kerberosKeys = AccessController.doPrivileged(
-                new PrivilegedExceptionAction<KerberosKey[]>() {
-                public KerberosKey[] run() throws Exception {
+                // Eliminate dependency on KerberosKey
+                new PrivilegedExceptionAction<SecretKey[]>() {
+                public SecretKey[] run() throws Exception {
                     // get kerberos key for the default principal
-                    return Krb5Util.getKeys(
-                        GSSCaller.CALLER_SSL_SERVER, null, acc);
+                    return Krb5Helper.getServerKeys(acc);
                         }});
 
             // check permission to access and use the secret key of the
@@ -931,12 +926,13 @@
                 }
 
                 String serverPrincipal =
-                    kerberosKeys[0].getPrincipal().getName();
+                    Krb5Helper.getServerPrincipalName(kerberosKeys[0]);
                 SecurityManager sm = System.getSecurityManager();
                 try {
                    if (sm != null) {
-                      sm.checkPermission(new ServicePermission(serverPrincipal,
-                                                "accept"), acc);
+                      // Eliminate dependency on ServicePermission
+                      sm.checkPermission(Krb5Helper.getServicePermission(
+                          serverPrincipal, "accept"), acc);
                    }
                 } catch (SecurityException se) {
                    kerberosKeys = null;
@@ -973,7 +969,7 @@
         session.setPeerPrincipal(mesg.getPeerPrincipal());
         session.setLocalPrincipal(mesg.getLocalPrincipal());
 
-        byte[] b = mesg.getPreMasterSecret().getUnencrypted();
+        byte[] b = mesg.getUnencryptedPreMasterSecret();
         return new SecretKeySpec(b, "TlsPremasterSecret");
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/security/ssl/krb5/KerberosClientKeyExchangeImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,383 @@
+/*
+ * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.security.ssl.krb5;
+
+import java.io.IOException;
+import java.io.PrintStream;
+import java.security.AccessController;
+import java.security.AccessControlContext;
+import java.security.PrivilegedExceptionAction;
+import java.security.PrivilegedActionException;
+import java.security.SecureRandom;
+import java.net.InetAddress;
+
+import javax.crypto.SecretKey;
+import javax.security.auth.kerberos.KerberosTicket;
+import javax.security.auth.kerberos.KerberosKey;
+import javax.security.auth.kerberos.KerberosPrincipal;
+import javax.security.auth.kerberos.ServicePermission;
+import sun.security.jgss.GSSCaller;
+
+import sun.security.krb5.EncryptionKey;
+import sun.security.krb5.EncryptedData;
+import sun.security.krb5.PrincipalName;
+import sun.security.krb5.Realm;
+import sun.security.krb5.internal.Ticket;
+import sun.security.krb5.internal.EncTicketPart;
+import sun.security.krb5.internal.crypto.KeyUsage;
+
+import sun.security.jgss.krb5.Krb5Util;
+
+import sun.security.ssl.Debug;
+import sun.security.ssl.HandshakeInStream;
+import sun.security.ssl.HandshakeOutStream;
+import sun.security.ssl.KerberosClientKeyExchange;
+import sun.security.ssl.ProtocolVersion;
+
+/**
+ * This is Kerberos option in the client key exchange message
+ * (CLIENT -> SERVER). It holds the Kerberos ticket and the encrypted
+ * premaster secret encrypted with the session key sealed in the ticket.
+ * From RFC 2712:
+ *  struct
+ *  {
+ *    opaque Ticket;
+ *    opaque authenticator;            // optional
+ *    opaque EncryptedPreMasterSecret; // encrypted with the session key
+ *                                     // which is sealed in the ticket
+ *  } KerberosWrapper;
+ *
+ *
+ * Ticket and authenticator are encrypted as per RFC 1510 (in ASN.1)
+ * Encrypted pre-master secret has the same structure as it does for RSA
+ * except for Kerberos, the encryption key is the session key instead of
+ * the RSA public key.
+ *
+ * XXX authenticator currently ignored
+ *
+ */
+public final class KerberosClientKeyExchangeImpl
+    extends sun.security.ssl.KerberosClientKeyExchange {
+
+    private KerberosPreMasterSecret preMaster;
+    private byte[] encodedTicket;
+    private KerberosPrincipal peerPrincipal;
+    private KerberosPrincipal localPrincipal;
+
+    public KerberosClientKeyExchangeImpl() {
+    }
+
+    /**
+     * Creates an instance of KerberosClientKeyExchange consisting of the
+     * Kerberos service ticket, authenticator and encrypted premaster secret.
+     * Called by client handshaker.
+     *
+     * @param serverName name of server with which to do handshake;
+     *             this is used to get the Kerberos service ticket
+     * @param protocolVersion Maximum version supported by client (i.e,
+     *          version it requested in client hello)
+     * @param rand random number generator to use for generating pre-master
+     *          secret
+     */
+    @Override
+    public void init(String serverName, boolean isLoopback,
+        AccessControlContext acc, ProtocolVersion protocolVersion,
+        SecureRandom rand) throws IOException {
+
+         // Get service ticket
+         KerberosTicket ticket = getServiceTicket(serverName, isLoopback, acc);
+         encodedTicket = ticket.getEncoded();
+
+         // Record the Kerberos principals
+         peerPrincipal = ticket.getServer();
+         localPrincipal = ticket.getClient();
+
+         // Optional authenticator, encrypted using session key,
+         // currently ignored
+
+         // Generate premaster secret and encrypt it using session key
+         EncryptionKey sessionKey = new EncryptionKey(
+                                        ticket.getSessionKeyType(),
+                                        ticket.getSessionKey().getEncoded());
+
+         preMaster = new KerberosPreMasterSecret(protocolVersion,
+             rand, sessionKey);
+    }
+
+    /**
+     * Creates an instance of KerberosClientKeyExchange from its ASN.1 encoding.
+     * Used by ServerHandshaker to verify and obtain premaster secret.
+     *
+     * @param protocolVersion current protocol version
+     * @param clientVersion version requested by client in its ClientHello;
+     *          used by premaster secret version check
+     * @param rand random number generator used for generating random
+     *          premaster secret if ticket and/or premaster verification fails
+     * @param input inputstream from which to get ASN.1-encoded KerberosWrapper
+     * @param serverKey server's master secret key
+     */
+    @Override
+    public void init(ProtocolVersion protocolVersion,
+        ProtocolVersion clientVersion,
+        SecureRandom rand, HandshakeInStream input, SecretKey[] secretKeys)
+        throws IOException {
+
+        KerberosKey[] serverKeys = (KerberosKey[])secretKeys;
+
+        // Read ticket
+        encodedTicket = input.getBytes16();
+
+        if (debug != null && Debug.isOn("verbose")) {
+            Debug.println(System.out,
+                "encoded Kerberos service ticket", encodedTicket);
+        }
+
+        EncryptionKey sessionKey = null;
+
+        try {
+            Ticket t = new Ticket(encodedTicket);
+
+            EncryptedData encPart = t.encPart;
+            PrincipalName ticketSname = t.sname;
+            Realm ticketRealm = t.realm;
+
+            String serverPrincipal = serverKeys[0].getPrincipal().getName();
+
+            /*
+             * permission to access and use the secret key of the Kerberized
+             * "host" service is done in ServerHandshaker.getKerberosKeys()
+             * to ensure server has the permission to use the secret key
+             * before promising the client
+             */
+
+            // Check that ticket Sname matches serverPrincipal
+            String ticketPrinc = ticketSname.toString().concat("@" +
+                                        ticketRealm.toString());
+            if (!ticketPrinc.equals(serverPrincipal)) {
+                if (debug != null && Debug.isOn("handshake"))
+                   System.out.println("Service principal in Ticket does not"
+                        + " match associated principal in KerberosKey");
+                throw new IOException("Server principal is " +
+                    serverPrincipal + " but ticket is for " +
+                    ticketPrinc);
+            }
+
+            // See if we have the right key to decrypt the ticket to get
+            // the session key.
+            int encPartKeyType = encPart.getEType();
+            KerberosKey dkey = findKey(encPartKeyType, serverKeys);
+            if (dkey == null) {
+                // %%% Should print string repr of etype
+                throw new IOException(
+        "Cannot find key of appropriate type to decrypt ticket - need etype " +
+                                   encPartKeyType);
+            }
+
+            EncryptionKey secretKey = new EncryptionKey(
+                encPartKeyType,
+                dkey.getEncoded());
+
+            // Decrypt encPart using server's secret key
+            byte[] bytes = encPart.decrypt(secretKey, KeyUsage.KU_TICKET);
+
+            // Reset data stream after decryption, remove redundant bytes
+            byte[] temp = encPart.reset(bytes, true);
+            EncTicketPart encTicketPart = new EncTicketPart(temp);
+
+            // Record the Kerberos Principals
+            peerPrincipal =
+                new KerberosPrincipal(encTicketPart.cname.getName());
+            localPrincipal = new KerberosPrincipal(ticketSname.getName());
+
+            sessionKey = encTicketPart.key;
+
+            if (debug != null && Debug.isOn("handshake")) {
+                System.out.println("server principal: " + serverPrincipal);
+                System.out.println("realm: " + encTicketPart.crealm.toString());
+                System.out.println("cname: " + encTicketPart.cname.toString());
+            }
+        } catch (IOException e) {
+            throw e;
+        } catch (Exception e) {
+            if (debug != null && Debug.isOn("handshake")) {
+                System.out.println("KerberosWrapper error getting session key,"
+                        + " generating random secret (" + e.getMessage() + ")");
+            }
+            sessionKey = null;
+        }
+
+        input.getBytes16();   // XXX Read and ignore authenticator
+
+        if (sessionKey != null) {
+            preMaster = new KerberosPreMasterSecret(protocolVersion,
+                clientVersion, rand, input, sessionKey);
+        } else {
+            // Generate bogus premaster secret
+            preMaster = new KerberosPreMasterSecret(protocolVersion, rand);
+        }
+    }
+
+    @Override
+    public int messageLength() {
+        return (6 + encodedTicket.length + preMaster.getEncrypted().length);
+    }
+
+    @Override
+    public void send(HandshakeOutStream s) throws IOException {
+        s.putBytes16(encodedTicket);
+        s.putBytes16(null); // XXX no authenticator
+        s.putBytes16(preMaster.getEncrypted());
+    }
+
+    @Override
+    public void print(PrintStream s) throws IOException {
+        s.println("*** ClientKeyExchange, Kerberos");
+
+        if (debug != null && Debug.isOn("verbose")) {
+            Debug.println(s, "Kerberos service ticket", encodedTicket);
+            Debug.println(s, "Random Secret", preMaster.getUnencrypted());
+            Debug.println(s, "Encrypted random Secret",
+                preMaster.getEncrypted());
+        }
+    }
+
+    // Similar to sun.security.jgss.krb5.Krb5InitCredenetial/Krb5Context
+    private static KerberosTicket getServiceTicket(String srvName,
+        boolean isLoopback, final AccessControlContext acc) throws IOException {
+
+        // get the local hostname if srvName is loopback address
+        String serverName = srvName;
+        if (isLoopback) {
+            String localHost = java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<String>() {
+                public String run() {
+                    String hostname;
+                    try {
+                        hostname = InetAddress.getLocalHost().getHostName();
+                    } catch (java.net.UnknownHostException e) {
+                        hostname = "localhost";
+                    }
+                    return hostname;
+                }
+            });
+          serverName = localHost;
+        }
+
+        // Resolve serverName (possibly in IP addr form) to Kerberos principal
+        // name for service with hostname
+        String serviceName = "host/" + serverName;
+        PrincipalName principal;
+        try {
+            principal = new PrincipalName(serviceName,
+                                PrincipalName.KRB_NT_SRV_HST);
+        } catch (SecurityException se) {
+            throw se;
+        } catch (Exception e) {
+            IOException ioe = new IOException("Invalid service principal" +
+                                " name: " + serviceName);
+            ioe.initCause(e);
+            throw ioe;
+        }
+        String realm = principal.getRealmAsString();
+
+        final String serverPrincipal = principal.toString();
+        final String tgsPrincipal = "krbtgt/" + realm + "@" + realm;
+        final String clientPrincipal = null;  // use default
+
+
+        // check permission to obtain a service ticket to initiate a
+        // context with the "host" service
+        SecurityManager sm = System.getSecurityManager();
+        if (sm != null) {
+           sm.checkPermission(new ServicePermission(serverPrincipal,
+                                "initiate"), acc);
+        }
+
+        try {
+            KerberosTicket ticket = AccessController.doPrivileged(
+                new PrivilegedExceptionAction<KerberosTicket>() {
+                public KerberosTicket run() throws Exception {
+                    return Krb5Util.getTicketFromSubjectAndTgs(
+                        GSSCaller.CALLER_SSL_CLIENT,
+                        clientPrincipal, serverPrincipal,
+                        tgsPrincipal, acc);
+                        }});
+
+            if (ticket == null) {
+                throw new IOException("Failed to find any kerberos service" +
+                        " ticket for " + serverPrincipal);
+            }
+            return ticket;
+        } catch (PrivilegedActionException e) {
+            IOException ioe = new IOException(
+                "Attempt to obtain kerberos service ticket for " +
+                        serverPrincipal + " failed!");
+            ioe.initCause(e);
+            throw ioe;
+        }
+    }
+
+    @Override
+    public byte[] getUnencryptedPreMasterSecret() {
+        return preMaster.getUnencrypted();
+    }
+
+    @Override
+    public KerberosPrincipal getPeerPrincipal() {
+        return peerPrincipal;
+    }
+
+    @Override
+    public KerberosPrincipal getLocalPrincipal() {
+        return localPrincipal;
+    }
+
+    private static KerberosKey findKey(int etype, KerberosKey[] keys) {
+        int ktype;
+        for (int i = 0; i < keys.length; i++) {
+            ktype = keys[i].getKeyType();
+            if (etype == ktype) {
+                return keys[i];
+            }
+        }
+        // Key not found.
+        // %%% kludge to allow DES keys to be used for diff etypes
+        if ((etype == EncryptedData.ETYPE_DES_CBC_CRC ||
+            etype == EncryptedData.ETYPE_DES_CBC_MD5)) {
+            for (int i = 0; i < keys.length; i++) {
+                ktype = keys[i].getKeyType();
+                if (ktype == EncryptedData.ETYPE_DES_CBC_CRC ||
+                    ktype == EncryptedData.ETYPE_DES_CBC_MD5) {
+                    return new KerberosKey(keys[i].getPrincipal(),
+                        keys[i].getEncoded(),
+                        etype,
+                        keys[i].getVersionNumber());
+                }
+            }
+        }
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/security/ssl/krb5/KerberosPreMasterSecret.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,228 @@
+/*
+ * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.security.ssl.krb5;
+
+import java.io.*;
+import java.security.*;
+import java.security.interfaces.*;
+
+import javax.net.ssl.*;
+
+import sun.security.krb5.EncryptionKey;
+import sun.security.krb5.EncryptedData;
+import sun.security.krb5.KrbException;
+import sun.security.krb5.internal.crypto.KeyUsage;
+
+import sun.security.ssl.Debug;
+import sun.security.ssl.HandshakeInStream;
+import sun.security.ssl.HandshakeMessage;
+import sun.security.ssl.ProtocolVersion;
+
+/**
+ * This is the Kerberos premaster secret in the Kerberos client key
+ * exchange message (CLIENT --> SERVER); it holds the
+ * Kerberos-encrypted pre-master secret. The secret is encrypted using the
+ * Kerberos session key.  The padding and size of the resulting message
+ * depends on the session key type, but the pre-master secret is
+ * always exactly 48 bytes.
+ *
+ */
+final class KerberosPreMasterSecret {
+
+    private ProtocolVersion protocolVersion; // preMaster [0,1]
+    private byte preMaster[];           // 48 bytes
+    private byte encrypted[];
+
+    /**
+     * Constructor used by client to generate premaster secret.
+     *
+     * Client randomly creates a pre-master secret and encrypts it
+     * using the Kerberos session key; only the server can decrypt
+     * it, using the session key available in the service ticket.
+     *
+     * @param protocolVersion used to set preMaster[0,1]
+     * @param generator random number generator for generating premaster secret
+     * @param sessionKey Kerberos session key for encrypting premaster secret
+     */
+    KerberosPreMasterSecret(ProtocolVersion protocolVersion,
+        SecureRandom generator, EncryptionKey sessionKey) throws IOException {
+
+        if (sessionKey.getEType() ==
+            EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
+            throw new IOException(
+               "session keys with des3-cbc-hmac-sha1-kd encryption type " +
+               "are not supported for TLS Kerberos cipher suites");
+        }
+
+        this.protocolVersion = protocolVersion;
+        preMaster = generatePreMaster(generator, protocolVersion);
+
+        // Encrypt premaster secret
+        try {
+            EncryptedData eData = new EncryptedData(sessionKey, preMaster,
+                KeyUsage.KU_UNKNOWN);
+            encrypted = eData.getBytes();  // not ASN.1 encoded.
+
+        } catch (KrbException e) {
+            throw (SSLKeyException)new SSLKeyException
+                ("Kerberos premaster secret error").initCause(e);
+        }
+    }
+
+    /*
+     * Constructor used by server to decrypt encrypted premaster secret.
+     * The protocol version in preMaster[0,1] must match either currentVersion
+     * or clientVersion, otherwise, the premaster secret is set to
+     * a random one to foil possible attack.
+     *
+     * @param currentVersion version of protocol being used
+     * @param clientVersion version requested by client
+     * @param generator random number generator used to generate
+     *        bogus premaster secret if premaster secret verification fails
+     * @param input input stream from which to read the encrypted
+     *        premaster secret
+     * @param sessionKey Kerberos session key to be used for decryption
+     */
+    KerberosPreMasterSecret(ProtocolVersion currentVersion,
+        ProtocolVersion clientVersion,
+        SecureRandom generator, HandshakeInStream input,
+        EncryptionKey sessionKey) throws IOException {
+
+         // Extract encrypted premaster secret from message
+         encrypted = input.getBytes16();
+
+         if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
+            if (encrypted != null) {
+                Debug.println(System.out,
+                     "encrypted premaster secret", encrypted);
+            }
+         }
+
+        if (sessionKey.getEType() ==
+            EncryptedData.ETYPE_DES3_CBC_HMAC_SHA1_KD) {
+            throw new IOException(
+               "session keys with des3-cbc-hmac-sha1-kd encryption type " +
+               "are not supported for TLS Kerberos cipher suites");
+        }
+
+         // Decrypt premaster secret
+         try {
+            EncryptedData data = new EncryptedData(sessionKey.getEType(),
+                        null /* optional kvno */, encrypted);
+
+            byte[] temp = data.decrypt(sessionKey, KeyUsage.KU_UNKNOWN);
+            if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
+                 if (encrypted != null) {
+                     Debug.println(System.out,
+                         "decrypted premaster secret", temp);
+                 }
+            }
+
+            // Reset data stream after decryption, remove redundant bytes
+            preMaster =  data.reset(temp, false);
+
+            protocolVersion = ProtocolVersion.valueOf(preMaster[0],
+                 preMaster[1]);
+            if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
+                 System.out.println("Kerberos PreMasterSecret version: "
+                        + protocolVersion);
+            }
+        } catch (Exception e) {
+            // catch exception & process below
+            preMaster = null;
+            protocolVersion = currentVersion;
+        }
+
+        // check if the premaster secret version is ok
+        // the specification says that it must be the maximum version supported
+        // by the client from its ClientHello message. However, many
+        // implementations send the negotiated version, so accept both
+        // NOTE that we may be comparing two unsupported version numbers in
+        // the second case, which is why we cannot use object references
+        // equality in this special case
+        boolean versionMismatch = (protocolVersion != currentVersion) &&
+                                  (protocolVersion.v != clientVersion.v);
+
+
+        /*
+         * Bogus decrypted ClientKeyExchange? If so, conjure a
+         * a random preMaster secret that will fail later during
+         * Finished message processing. This is a countermeasure against
+         * the "interactive RSA PKCS#1 encryption envelop attack" reported
+         * in June 1998. Preserving the executation path will
+         * mitigate timing attacks and force consistent error handling
+         * that will prevent an attacking client from differentiating
+         * different kinds of decrypted ClientKeyExchange bogosities.
+         */
+         if ((preMaster == null) || (preMaster.length != 48)
+                || versionMismatch) {
+            if (HandshakeMessage.debug != null && Debug.isOn("handshake")) {
+                System.out.println("Kerberos PreMasterSecret error, "
+                                   + "generating random secret");
+                if (preMaster != null) {
+                    Debug.println(System.out, "Invalid secret", preMaster);
+                }
+            }
+            preMaster = generatePreMaster(generator, currentVersion);
+            protocolVersion = currentVersion;
+        }
+    }
+
+    /*
+     * Used by server to generate premaster secret in case of
+     * problem decoding ticket.
+     *
+     * @param protocolVersion used for preMaster[0,1]
+     * @param generator random number generator to use for generating secret.
+     */
+    KerberosPreMasterSecret(ProtocolVersion protocolVersion,
+        SecureRandom generator) {
+
+        this.protocolVersion = protocolVersion;
+        preMaster = generatePreMaster(generator, protocolVersion);
+    }
+
+    private static byte[] generatePreMaster(SecureRandom rand,
+        ProtocolVersion ver) {
+
+        byte[] pm = new byte[48];
+        rand.nextBytes(pm);
+        pm[0] = ver.major;
+        pm[1] = ver.minor;
+
+        return pm;
+    }
+
+    // Clone not needed; internal use only
+    byte[] getUnencrypted() {
+        return preMaster;
+    }
+
+    // Clone not needed; internal use only
+    byte[] getEncrypted() {
+        return encrypted;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/security/ssl/krb5/Krb5ProxyImpl.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,99 @@
+/*
+ * 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 sun.security.ssl.krb5;
+
+import java.security.AccessControlContext;
+import java.security.Permission;
+import java.security.Principal;
+import javax.crypto.SecretKey;
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosKey;
+import javax.security.auth.kerberos.ServicePermission;
+import javax.security.auth.login.LoginException;
+
+import sun.security.jgss.GSSCaller;
+import sun.security.jgss.krb5.Krb5Util;
+import sun.security.krb5.PrincipalName;
+import sun.security.ssl.Krb5Proxy;
+
+/**
+ * An implementatin of Krb5Proxy that simply delegates to the appropriate
+ * Kerberos APIs.
+ */
+public class Krb5ProxyImpl implements Krb5Proxy {
+
+    public Krb5ProxyImpl() { }
+
+    @Override
+    public Subject getClientSubject(AccessControlContext acc)
+            throws LoginException {
+        return Krb5Util.getSubject(GSSCaller.CALLER_SSL_CLIENT, acc);
+    }
+
+    @Override
+    public Subject getServerSubject(AccessControlContext acc)
+            throws LoginException {
+        return Krb5Util.getSubject(GSSCaller.CALLER_SSL_SERVER, acc);
+    }
+
+    @Override
+    public SecretKey[] getServerKeys(AccessControlContext acc)
+            throws LoginException {
+        return Krb5Util.getKeys(GSSCaller.CALLER_SSL_SERVER, null, acc);
+    }
+
+    @Override
+    public String getServerPrincipalName(SecretKey kerberosKey) {
+        return ((KerberosKey)kerberosKey).getPrincipal().getName();
+    }
+
+    @Override
+    public String getPrincipalHostName(Principal principal) {
+        if (principal == null) {
+           return null;
+        }
+        String hostName = null;
+        try {
+            PrincipalName princName =
+                new PrincipalName(principal.getName(),
+                        PrincipalName.KRB_NT_SRV_HST);
+            String[] nameParts = princName.getNameStrings();
+            if (nameParts.length >= 2) {
+                hostName = nameParts[1];
+            }
+        } catch (Exception e) {
+            // ignore
+        }
+        return hostName;
+    }
+
+
+    @Override
+    public Permission getServicePermission(String principalName,
+            String action) {
+        return new ServicePermission(principalName, action);
+    }
+}
--- a/src/share/classes/sun/security/timestamp/HttpTimestamper.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/timestamp/HttpTimestamper.java	Wed Nov 25 11:08:25 2009 -0800
@@ -34,6 +34,7 @@
 import java.util.Set;
 import java.util.Arrays;
 
+import sun.misc.IOUtils;
 import sun.security.pkcs.*;
 
 /**
@@ -142,25 +143,7 @@
 
             int total = 0;
             int contentLength = connection.getContentLength();
-            if (contentLength != -1) {
-                replyBuffer = new byte[contentLength];
-            } else {
-                replyBuffer = new byte[2048];
-                contentLength = Integer.MAX_VALUE;
-            }
-
-            while (total < contentLength) {
-                int count = input.read(replyBuffer, total,
-                                        replyBuffer.length - total);
-                if (count < 0)
-                    break;
-
-                total += count;
-                if (total >= replyBuffer.length && total < contentLength) {
-                    replyBuffer = Arrays.copyOf(replyBuffer, total * 2);
-                }
-            }
-            replyBuffer = Arrays.copyOf(replyBuffer, total);
+            replyBuffer = IOUtils.readFully(input, contentLength, false);
 
             if (DEBUG) {
                 System.out.println("received timestamp response (length=" +
--- a/src/share/classes/sun/security/tools/JarSigner.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/tools/JarSigner.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1031,9 +1031,9 @@
         }
 
         if (sigfile.length() > 8) {
-            sigfile = sigfile.substring(0, 8).toUpperCase();
+            sigfile = sigfile.substring(0, 8).toUpperCase(Locale.ENGLISH);
         } else {
-            sigfile = sigfile.toUpperCase();
+            sigfile = sigfile.toUpperCase(Locale.ENGLISH);
         }
 
         StringBuilder tmpSigFile = new StringBuilder(sigfile.length());
@@ -1083,8 +1083,8 @@
         ZipOutputStream zos = new ZipOutputStream(ps);
 
         /* First guess at what they might be - we don't xclude RSA ones. */
-        String sfFilename = (META_INF + sigfile + ".SF").toUpperCase();
-        String bkFilename = (META_INF + sigfile + ".DSA").toUpperCase();
+        String sfFilename = (META_INF + sigfile + ".SF").toUpperCase(Locale.ENGLISH);
+        String bkFilename = (META_INF + sigfile + ".DSA").toUpperCase(Locale.ENGLISH);
 
         Manifest manifest = new Manifest();
         Map<String,Attributes> mfEntries = manifest.getEntries();
@@ -1447,9 +1447,10 @@
      * . META-INF/*.SF
      * . META-INF/*.DSA
      * . META-INF/*.RSA
+     * . META-INF/*.EC
      */
     private boolean signatureRelated(String name) {
-        String ucName = name.toUpperCase();
+        String ucName = name.toUpperCase(Locale.ENGLISH);
         if (ucName.equals(JarFile.MANIFEST_NAME) ||
             ucName.equals(META_INF) ||
             (ucName.startsWith(SIG_PREFIX) &&
@@ -1459,7 +1460,7 @@
 
         if (ucName.startsWith(META_INF) &&
             SignatureFileVerifier.isBlockOrSF(ucName)) {
-            // .SF/.DSA/.RSA files in META-INF subdirs
+            // .SF/.DSA/.RSA/.EC files in META-INF subdirs
             // are not considered signature-related
             return (ucName.indexOf("/") == ucName.lastIndexOf("/"));
         }
@@ -1482,6 +1483,7 @@
         Timestamp timestamp = signer.getTimestamp();
         if (timestamp != null) {
             s.append(printTimestamp(tab, timestamp));
+            s.append('\n');
         }
         // display the certificate(s)
         for (Certificate c : certs) {
@@ -2227,7 +2229,6 @@
             }
             BigInteger serial = certChain[0].getSerialNumber();
 
-            String digestAlgorithm;
             String signatureAlgorithm;
             String keyAlgorithm = privateKey.getAlgorithm();
             /*
@@ -2237,22 +2238,24 @@
             if (sigalg == null) {
 
                 if (keyAlgorithm.equalsIgnoreCase("DSA"))
-                    digestAlgorithm = "SHA1";
+                    signatureAlgorithm = "SHA1withDSA";
                 else if (keyAlgorithm.equalsIgnoreCase("RSA"))
-                    digestAlgorithm = "SHA256";
-                else {
+                    signatureAlgorithm = "SHA256withRSA";
+                else if (keyAlgorithm.equalsIgnoreCase("EC"))
+                    signatureAlgorithm = "SHA256withECDSA";
+                else
                     throw new RuntimeException("private key is not a DSA or "
                                                + "RSA key");
-                }
-                signatureAlgorithm = digestAlgorithm + "with" + keyAlgorithm;
             } else {
                 signatureAlgorithm = sigalg;
             }
 
             // check common invalid key/signature algorithm combinations
-            String sigAlgUpperCase = signatureAlgorithm.toUpperCase();
+            String sigAlgUpperCase = signatureAlgorithm.toUpperCase(Locale.ENGLISH);
             if ((sigAlgUpperCase.endsWith("WITHRSA") &&
                 !keyAlgorithm.equalsIgnoreCase("RSA")) ||
+                (sigAlgUpperCase.endsWith("WITHECDSA") &&
+                !keyAlgorithm.equalsIgnoreCase("EC")) ||
                 (sigAlgUpperCase.endsWith("WITHDSA") &&
                 !keyAlgorithm.equalsIgnoreCase("DSA"))) {
                 throw new SignatureException
--- a/src/share/classes/sun/security/tools/KeyTool.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/tools/KeyTool.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,7 @@
 package sun.security.tools;
 
 import java.io.*;
+import java.security.CodeSigner;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
 import java.security.MessageDigest;
@@ -34,6 +35,7 @@
 import java.security.PrivateKey;
 import java.security.Security;
 import java.security.Signature;
+import java.security.Timestamp;
 import java.security.UnrecoverableEntryException;
 import java.security.UnrecoverableKeyException;
 import java.security.Principal;
@@ -46,6 +48,8 @@
 import java.text.Collator;
 import java.text.MessageFormat;
 import java.util.*;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
 import java.lang.reflect.Constructor;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -130,6 +134,7 @@
     private File ksfile = null;
     private InputStream ksStream = null; // keystore stream
     private String sslserver = null;
+    private String jarfile = null;
     private KeyStore keyStore = null;
     private boolean token = false;
     private boolean nullStream = false;
@@ -206,7 +211,7 @@
             "-providername", "-providerclass", "-providerarg",
             "-providerpath", "-v", "-protected"),
         PRINTCERT("Prints the content of a certificate",
-            "-rfc", "-file", "-sslserver", "-v"),
+            "-rfc", "-file", "-sslserver", "-jarfile", "-v"),
         PRINTCERTREQ("Prints the content of a certificate request",
             "-file", "-v"),
         SELFCERT("Generates a self-signed certificate",
@@ -266,6 +271,7 @@
         {"-srcstorepass", "<arg>", "source keystore password"},
         {"-srcstoretype", "<srcstoretype>", "source keystore type"},
         {"-sslserver", "<server[:port]>", "SSL server host and port"},
+        {"-jarfile", "<filename>", "signed jar file"},
         {"-startdate", "<startdate>", "certificate validity start date/time"},
         {"-storepass", "<arg>", "keystore password"},
         {"-storetype", "<storetype>", "keystore type"},
@@ -453,6 +459,8 @@
                 outfilename = args[++i];
             } else if (collator.compare(flags, "-sslserver") == 0) {
                 sslserver = args[++i];
+            } else if (collator.compare(flags, "-jarfile") == 0) {
+                jarfile = args[++i];
             } else if (collator.compare(flags, "-srckeystore") == 0) {
                 srcksfname = args[++i];
             } else if ((collator.compare(flags, "-provider") == 0) ||
@@ -1407,7 +1415,7 @@
         } else if ("RSA".equalsIgnoreCase(keyAlgName)) {
             return "SHA256WithRSA";
         } else if ("EC".equalsIgnoreCase(keyAlgName)) {
-            return "SHA1withECDSA";
+            return "SHA256withECDSA";
         } else {
             throw new Exception(rb.getString
                     ("Cannot derive signature algorithm"));
@@ -2065,7 +2073,71 @@
     }
 
     private void doPrintCert(final PrintStream out) throws Exception {
-        if (sslserver != null) {
+        if (jarfile != null) {
+            JarFile jf = new JarFile(jarfile, true);
+            Enumeration<JarEntry> entries = jf.entries();
+            Set<CodeSigner> ss = new HashSet<CodeSigner>();
+            byte[] buffer = new byte[8192];
+            int pos = 0;
+            while (entries.hasMoreElements()) {
+                JarEntry je = entries.nextElement();
+                InputStream is = null;
+                try {
+                    is = jf.getInputStream(je);
+                    while (is.read(buffer) != -1) {
+                        // we just read. this will throw a SecurityException
+                        // if a signature/digest check fails. This also
+                        // populate the signers
+                    }
+                } finally {
+                    if (is != null) {
+                        is.close();
+                    }
+                }
+                CodeSigner[] signers = je.getCodeSigners();
+                if (signers != null) {
+                    for (CodeSigner signer: signers) {
+                        if (!ss.contains(signer)) {
+                            ss.add(signer);
+                            out.printf(rb.getString("Signer #%d:"), ++pos);
+                            out.println();
+                            out.println();
+                            out.println(rb.getString("Signature:"));
+                            out.println();
+                            for (Certificate cert: signer.getSignerCertPath().getCertificates()) {
+                                X509Certificate x = (X509Certificate)cert;
+                                if (rfc) {
+                                    out.println(rb.getString("Certificate owner: ") + x.getSubjectDN() + "\n");
+                                    dumpCert(x, out);
+                                } else {
+                                    printX509Cert(x, out);
+                                }
+                                out.println();
+                            }
+                            Timestamp ts = signer.getTimestamp();
+                            if (ts != null) {
+                                out.println(rb.getString("Timestamp:"));
+                                out.println();
+                                for (Certificate cert: ts.getSignerCertPath().getCertificates()) {
+                                    X509Certificate x = (X509Certificate)cert;
+                                    if (rfc) {
+                                        out.println(rb.getString("Certificate owner: ") + x.getSubjectDN() + "\n");
+                                        dumpCert(x, out);
+                                    } else {
+                                        printX509Cert(x, out);
+                                    }
+                                    out.println();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            jf.close();
+            if (ss.size() == 0) {
+                out.println(rb.getString("Not a signed jar file"));
+            }
+        } else if (sslserver != null) {
             SSLContext sc = SSLContext.getInstance("SSL");
             final boolean[] certPrinted = new boolean[1];
             sc.init(null, new TrustManager[] {
--- a/src/share/classes/sun/security/tools/TimestampedSigner.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/tools/TimestampedSigner.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright (c) 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
@@ -159,18 +159,10 @@
         //     "<digest>with<encryption>"
         // or  "<digest>with<encryption>and<mgf>"
         String signatureAlgorithm = parameters.getSignatureAlgorithm();
-        String digestAlgorithm = null;
-        String keyAlgorithm = null;
-        int with = signatureAlgorithm.indexOf("with");
-        if (with > 0) {
-            digestAlgorithm = signatureAlgorithm.substring(0, with);
-            int and = signatureAlgorithm.indexOf("and", with + 4);
-            if (and > 0) {
-                keyAlgorithm = signatureAlgorithm.substring(with + 4, and);
-            } else {
-                keyAlgorithm = signatureAlgorithm.substring(with + 4);
-            }
-        }
+        String keyAlgorithm =
+                AlgorithmId.getEncAlgFromSigAlg(signatureAlgorithm);
+        String digestAlgorithm =
+                AlgorithmId.getDigAlgFromSigAlg(signatureAlgorithm);
         AlgorithmId digestAlgorithmId = AlgorithmId.get(digestAlgorithm);
 
         // Examine signer's certificate
--- a/src/share/classes/sun/security/util/DerValue.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/util/DerValue.java	Wed Nov 25 11:08:25 2009 -0800
@@ -28,6 +28,7 @@
 import java.io.*;
 import java.math.BigInteger;
 import java.util.Date;
+import sun.misc.IOUtils;
 
 /**
  * Represents a single DER-encoded value.  DER encoding rules are a subset
@@ -382,12 +383,8 @@
         if (fullyBuffered && in.available() != length)
             throw new IOException("extra data given to DerValue constructor");
 
-        byte[] bytes = new byte[length];
+        byte[] bytes = IOUtils.readFully(in, length, true);
 
-        // n.b. readFully not needed in normal fullyBuffered case
-        DataInputStream dis = new DataInputStream(in);
-
-        dis.readFully(bytes);
         buffer = new DerInputBuffer(bytes);
         return new DerInputStream(buffer);
     }
--- a/src/share/classes/sun/security/util/HostnameChecker.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/util/HostnameChecker.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,10 +32,9 @@
 import java.security.cert.*;
 
 import javax.security.auth.x500.X500Principal;
-import javax.security.auth.kerberos.KerberosPrincipal;
 
+import sun.security.ssl.Krb5Helper;
 import sun.security.x509.X500Name;
-import sun.security.krb5.PrincipalName;
 
 import sun.net.util.IPAddressUtil;
 
@@ -98,8 +97,7 @@
     /**
      * Perform the check for Kerberos.
      */
-    public static boolean match(String expectedName,
-                        KerberosPrincipal principal) {
+    public static boolean match(String expectedName, Principal principal) {
         String hostName = getServerName(principal);
         return (expectedName.equalsIgnoreCase(hostName));
     }
@@ -107,23 +105,8 @@
     /**
      * Return the Server name from Kerberos principal.
      */
-    public static String getServerName(KerberosPrincipal principal) {
-        if (principal == null) {
-           return null;
-        }
-        String hostName = null;
-        try {
-            PrincipalName princName =
-                new PrincipalName(principal.getName(),
-                        PrincipalName.KRB_NT_SRV_HST);
-            String[] nameParts = princName.getNameStrings();
-            if (nameParts.length >= 2) {
-                hostName = nameParts[1];
-            }
-        } catch (Exception e) {
-            // ignore
-        }
-        return hostName;
+    public static String getServerName(Principal principal) {
+        return Krb5Helper.getPrincipalHostName(principal);
     }
 
     /**
--- a/src/share/classes/sun/security/util/Resources.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/util/Resources.java	Wed Nov 25 11:08:25 2009 -0800
@@ -162,6 +162,8 @@
                 "source keystore type"}, //-srcstoretype
         {"SSL server host and port",
                 "SSL server host and port"}, //-sslserver
+        {"signed jar file",
+                "signed jar file"}, //=jarfile
         {"certificate validity start date/time",
                 "certificate validity start date/time"}, //-startdate
         {"keystore password",
@@ -370,6 +372,13 @@
 
         {"*****************  WARNING WARNING WARNING  *****************",
             "*****************  WARNING WARNING WARNING  *****************"},
+        {"Signer #%d:", "Signer #%d:"},
+        {"Timestamp:", "Timestamp:"},
+        {"Signature:", "Signature:"},
+        {"Certificate owner: ", "Certificate owner: "},
+        {"Not a signed jar file", "Not a signed jar file"},
+        {"No certificate from the SSL server",
+                "No certificate from the SSL server"},
 
         // Translators of the following 5 pairs, ATTENTION:
         // the next 5 string pairs are meant to be combined into 2 paragraphs,
--- a/src/share/classes/sun/security/util/SignatureFileVerifier.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/util/SignatureFileVerifier.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -54,14 +54,14 @@
         ("-DIGEST-" + ManifestDigester.MF_MAIN_ATTRS).toUpperCase
         (Locale.ENGLISH);
 
-    /** the PKCS7 block for this .DSA/.RSA file */
+    /** the PKCS7 block for this .DSA/.RSA/.EC file */
     private PKCS7 block;
 
     /** the raw bytes of the .SF file */
     private byte sfBytes[];
 
     /** the name of the signature block file, uppercased and without
-     *  the extension (.DSA/.RSA)
+     *  the extension (.DSA/.RSA/.EC)
      */
     private String name;
 
@@ -80,7 +80,7 @@
     /**
      * Create the named SignatureFileVerifier.
      *
-     * @param name the name of the signature block file (.DSA/.RSA)
+     * @param name the name of the signature block file (.DSA/.RSA/.EC)
      *
      * @param rawBytes the raw bytes of the signature block file
      */
@@ -148,7 +148,8 @@
      */
     public static boolean isBlockOrSF(String s) {
         // we currently only support DSA and RSA PKCS7 blocks
-        if (s.endsWith(".SF") || s.endsWith(".DSA") || s.endsWith(".RSA")) {
+        if (s.endsWith(".SF") || s.endsWith(".DSA") ||
+                s.endsWith(".RSA") || s.endsWith(".EC")) {
             return true;
         }
         return false;
--- a/src/share/classes/sun/security/validator/SimpleValidator.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/validator/SimpleValidator.java	Wed Nov 25 11:08:25 2009 -0800
@@ -40,6 +40,8 @@
 import sun.security.util.DerOutputStream;
 import sun.security.util.ObjectIdentifier;
 
+import sun.security.provider.certpath.AlgorithmChecker;
+
 /**
  * A simple validator implementation. It is based on code from the JSSE
  * X509TrustManagerImpl. This implementation is designed for compatibility with
@@ -134,6 +136,13 @@
             X509Certificate issuerCert = chain[i + 1];
             X509Certificate cert = chain[i];
 
+            // check certificate algorithm
+            try {
+                AlgorithmChecker.check(cert);
+            } catch (CertPathValidatorException cpve) {
+                throw new ValidatorException
+                        (ValidatorException.T_ALGORITHM_DISABLED, cert, cpve);
+            }
 
             // no validity check for code signing certs
             if ((variant.equals(VAR_CODE_SIGNING) == false)
--- a/src/share/classes/sun/security/validator/ValidatorException.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/validator/ValidatorException.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2002-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
@@ -55,6 +55,9 @@
     public final static Object T_NAME_CHAINING =
         "Certificate chaining error";
 
+    public final static Object T_ALGORITHM_DISABLED =
+        "Certificate signature algorithm disabled";
+
     private Object type;
     private X509Certificate cert;
 
--- a/src/share/classes/sun/security/x509/AlgorithmId.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/security/x509/AlgorithmId.java	Wed Nov 25 11:08:25 2009 -0800
@@ -883,4 +883,53 @@
         nameTable.put(pbeWithSHA1AndDESede_oid, "PBEWithSHA1AndDESede");
         nameTable.put(pbeWithSHA1AndRC2_40_oid, "PBEWithSHA1AndRC2_40");
     }
+
+    /**
+     * Creates a signature algorithm name from a digest algorithm
+     * name and a encryption algorithm name.
+     */
+    public static String makeSigAlg(String digAlg, String encAlg) {
+        digAlg = digAlg.replace("-", "").toUpperCase(Locale.ENGLISH);
+        if (digAlg.equalsIgnoreCase("SHA")) digAlg = "SHA1";
+
+        encAlg = encAlg.toUpperCase(Locale.ENGLISH);
+        if (encAlg.equals("EC")) encAlg = "ECDSA";
+
+        return digAlg + "with" + encAlg;
+    }
+
+    /**
+     * Extracts the encryption algorithm name from a signature
+     * algorithm name.
+      */
+    public static String getEncAlgFromSigAlg(String signatureAlgorithm) {
+        signatureAlgorithm = signatureAlgorithm.toUpperCase(Locale.ENGLISH);
+        int with = signatureAlgorithm.indexOf("WITH");
+        String keyAlgorithm = null;
+        if (with > 0) {
+            int and = signatureAlgorithm.indexOf("AND", with + 4);
+            if (and > 0) {
+                keyAlgorithm = signatureAlgorithm.substring(with + 4, and);
+            } else {
+                keyAlgorithm = signatureAlgorithm.substring(with + 4);
+            }
+            if (keyAlgorithm.equalsIgnoreCase("ECDSA")) {
+                keyAlgorithm = "EC";
+            }
+        }
+        return keyAlgorithm;
+    }
+
+    /**
+     * Extracts the digest algorithm name from a signature
+     * algorithm name.
+      */
+    public static String getDigAlgFromSigAlg(String signatureAlgorithm) {
+        signatureAlgorithm = signatureAlgorithm.toUpperCase(Locale.ENGLISH);
+        int with = signatureAlgorithm.indexOf("WITH");
+        if (with > 0) {
+            return signatureAlgorithm.substring(0, with);
+        }
+        return null;
+    }
 }
--- a/src/share/classes/sun/swing/SwingLazyValue.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/swing/SwingLazyValue.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,9 @@
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
+import java.lang.reflect.AccessibleObject;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import javax.swing.UIDefaults;
 
 /**
@@ -65,13 +68,15 @@
             if (methodName != null) {
                 Class[] types = getClassArray(args);
                 Method m = c.getMethod(methodName, types);
+                makeAccessible(m);
                 return m.invoke(c, args);
             } else {
                 Class[] types = getClassArray(args);
                 Constructor constructor = c.getConstructor(types);
+                makeAccessible(constructor);
                 return constructor.newInstance(args);
             }
-        } catch(Exception e) {
+        } catch (Exception e) {
             // Ideally we would throw an exception, unfortunately
             // often times there are errors as an initial look and
             // feel is loaded before one can be switched. Perhaps a
@@ -81,6 +86,15 @@
         return null;
     }
 
+    private void makeAccessible(final AccessibleObject object) {
+        AccessController.doPrivileged(new PrivilegedAction<Void>() {
+            public Void run() {
+                object.setAccessible(true);
+                return null;
+            }
+        });
+    }
+
     private Class[] getClassArray(Object[] args) {
         Class[] types = null;
         if (args!=null) {
--- a/src/share/classes/sun/swing/SwingUtilities2.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/swing/SwingUtilities2.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1807,22 +1807,4 @@
                                          boolean three) {
         return liesIn(rect, p, false, false, three);
     }
-
-    /**
-     * Returns the {@code JViewport} instance for the {@code component}
-     * or {@code null}.
-     *
-     * @return the {@code JViewport} instance for the {@code component}
-     * or {@code null}
-     * @throws NullPointerException if {@code component} is {@code null}
-     */
-    public static JViewport getViewport(Component component) {
-        do {
-            component = component.getParent();
-            if (component instanceof JViewport) {
-                return (JViewport) component;
-            }
-        } while(component instanceof JLayer);
-        return null;
-    }
 }
--- a/src/share/classes/sun/text/bidi/BidiBase.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/text/bidi/BidiBase.java	Wed Nov 25 11:08:25 2009 -0800
@@ -52,10 +52,11 @@
 
 package sun.text.bidi;
 
-import java.awt.font.TextAttribute;
-import java.awt.font.NumericShaper;
 import java.io.IOException;
 import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
 import java.text.AttributedCharacterIterator;
 import java.text.Bidi;
 import java.util.Arrays;
@@ -2689,12 +2690,13 @@
     public void setPara(AttributedCharacterIterator paragraph)
     {
         byte paraLvl;
-        Boolean runDirection = (Boolean) paragraph.getAttribute(TextAttribute.RUN_DIRECTION);
-        NumericShaper shaper = (NumericShaper) paragraph.getAttribute(TextAttribute.NUMERIC_SHAPING);
+        Boolean runDirection =
+            (Boolean) paragraph.getAttribute(TextAttributeConstants.RUN_DIRECTION);
+        Object shaper = paragraph.getAttribute(TextAttributeConstants.NUMERIC_SHAPING);
         if (runDirection == null) {
             paraLvl = INTERNAL_LEVEL_DEFAULT_LTR;
         } else {
-            paraLvl = (runDirection.equals(TextAttribute.RUN_DIRECTION_LTR)) ?
+            paraLvl = (runDirection.equals(TextAttributeConstants.RUN_DIRECTION_LTR)) ?
                         (byte)Bidi.DIRECTION_LEFT_TO_RIGHT : (byte)Bidi.DIRECTION_RIGHT_TO_LEFT;
         }
 
@@ -2706,7 +2708,8 @@
         char ch = paragraph.first();
         while (ch != AttributedCharacterIterator.DONE) {
             txt[i] = ch;
-            Integer embedding = (Integer) paragraph.getAttribute(TextAttribute.BIDI_EMBEDDING);
+            Integer embedding =
+                (Integer) paragraph.getAttribute(TextAttributeConstants.BIDI_EMBEDDING);
             if (embedding != null) {
                 byte level = embedding.byteValue();
                 if (level == 0) {
@@ -2724,7 +2727,7 @@
         }
 
         if (shaper != null) {
-            shaper.shape(txt, 0, len);
+            NumericShapings.shape(shaper, txt, 0, len);
         }
         setPara(txt, paraLvl, lvls);
     }
@@ -3441,4 +3444,106 @@
         return buf.toString();
     }
 
+    /**
+     * A class that provides access to constants defined by
+     * java.awt.font.TextAttribute without creating a static dependency.
+     */
+    private static class TextAttributeConstants {
+        private static final Class<?> clazz = getClass("java.awt.font.TextAttribute");
+
+        /**
+         * TextAttribute instances (or a fake Attribute type if
+         * java.awt.font.TextAttribute is not present)
+         */
+        static final AttributedCharacterIterator.Attribute RUN_DIRECTION =
+            getTextAttribute("RUN_DIRECTION");
+        static final Boolean RUN_DIRECTION_LTR =
+            (Boolean)getStaticField(clazz, "RUN_DIRECTION_LTR");
+        static final AttributedCharacterIterator.Attribute NUMERIC_SHAPING =
+            getTextAttribute("NUMERIC_SHAPING");
+        static final AttributedCharacterIterator.Attribute BIDI_EMBEDDING =
+            getTextAttribute("BIDI_EMBEDDING");
+
+        private static Class<?> getClass(String name) {
+            try {
+                return Class.forName(name, true, null);
+            } catch (ClassNotFoundException e) {
+                return null;
+            }
+        }
+
+        private static Object getStaticField(Class<?> clazz, String name) {
+            if (clazz == null) {
+                // fake attribute
+                return new AttributedCharacterIterator.Attribute(name) { };
+            } else {
+                try {
+                    Field f = clazz.getField(name);
+                    return f.get(null);
+                } catch (NoSuchFieldException x) {
+                    throw new AssertionError(x);
+                } catch (IllegalAccessException x) {
+                    throw new AssertionError(x);
+                }
+            }
+        }
+
+        private static AttributedCharacterIterator.Attribute
+            getTextAttribute(String name)
+        {
+            return (AttributedCharacterIterator.Attribute)getStaticField(clazz, name);
+        }
+    }
+
+    /**
+     * A class that provides access to java.awt.font.NumericShaping without
+     * creating a static dependency.
+     */
+    private static class NumericShapings {
+        private static final Class<?> clazz =
+            getClass("java.awt.font.NumericShaper");
+        private static final Method shapeMethod =
+            getMethod(clazz, "shape", char[].class, int.class, int.class);
+
+        private static Class<?> getClass(String name) {
+            try {
+                return Class.forName(name, true, null);
+            } catch (ClassNotFoundException e) {
+                return null;
+            }
+        }
+
+        private static Method getMethod(Class<?> clazz,
+                                        String name,
+                                        Class<?>... paramTypes)
+        {
+            if (clazz != null) {
+                try {
+                    return clazz.getMethod(name, paramTypes);
+                } catch (NoSuchMethodException e) {
+                    throw new AssertionError(e);
+                }
+            } else {
+                return null;
+            }
+        }
+
+        /**
+         * Invokes NumericShaping shape(text,start,count) method.
+         */
+        static void shape(Object shaper, char[] text, int start, int count) {
+            if (shapeMethod == null)
+                throw new AssertionError("Should not get here");
+            try {
+                shapeMethod.invoke(shaper, text, start, count);
+            } catch (InvocationTargetException e) {
+                Throwable cause = e.getCause();
+                if (cause instanceof RuntimeException)
+                    throw (RuntimeException)cause;
+                throw new AssertionError(e);
+            } catch (IllegalAccessException iae) {
+                throw new AssertionError(iae);
+            }
+        }
+    }
 }
--- a/src/share/classes/sun/tools/jar/SignatureFile.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/tools/jar/SignatureFile.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1996-2003 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1996-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
@@ -34,6 +34,7 @@
 import sun.misc.BASE64Decoder;
 
 import sun.security.pkcs.*;
+import sun.security.x509.AlgorithmId;
 
 /**
  * <p>A signature file as defined in the <a
@@ -103,7 +104,7 @@
             if (name.length() > 8 || name.indexOf('.') != -1) {
                 throw new JarException("invalid file name");
             }
-            rawName = name.toUpperCase();
+            rawName = name.toUpperCase(Locale.ENGLISH);
         }
     }
 
@@ -217,7 +218,8 @@
         if (signatureBlock != null) {
             SignerInfo info = signatureBlock.getSignerInfos()[0];
             suffix = info.getDigestEncryptionAlgorithmId().getName();
-            suffix = suffix.substring(suffix.length() - 3);
+            String temp = AlgorithmId.getEncAlgFromSigAlg(suffix);
+            if (temp != null) suffix = temp;
         }
         return "META-INF/" + rawName + "." + suffix;
     }
--- a/src/share/classes/sun/util/calendar/ZoneInfoFile.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/calendar/ZoneInfoFile.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2000-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
@@ -472,6 +472,18 @@
 
     private static Map<String, ZoneInfo> zoneInfoObjects = null;
 
+    private static final String ziDir;
+    static {
+        String zi = (String) AccessController.doPrivileged(
+                         new sun.security.action.GetPropertyAction("java.home"))
+                    + File.separator + "lib" + File.separator + "zi";
+        try {
+            zi = new File(zi).getCanonicalPath();
+        } catch (Exception e) {
+        }
+        ziDir = zi;
+    }
+
     /**
      * Converts the given time zone ID to a platform dependent path
      * name. For example, "America/Los_Angeles" is converted to
@@ -576,20 +588,7 @@
             return null;
         }
 
-        int index;
-        for (index = 0; index < JAVAZI_LABEL.length; index++) {
-            if (buf[index] != JAVAZI_LABEL[index]) {
-                System.err.println("ZoneInfo: wrong magic number: " + id);
-                return null;
-            }
-        }
-
-        if (buf[index++] > JAVAZI_VERSION) {
-            System.err.println("ZoneInfo: incompatible version ("
-                               + buf[index - 1] + "): " + id);
-            return null;
-        }
-
+        int index = 0;
         int filesize = buf.length;
         int rawOffset = 0;
         int dstSavings = 0;
@@ -600,6 +599,18 @@
         int[] simpleTimeZoneParams = null;
 
         try {
+            for (index = 0; index < JAVAZI_LABEL.length; index++) {
+                if (buf[index] != JAVAZI_LABEL[index]) {
+                    System.err.println("ZoneInfo: wrong magic number: " + id);
+                    return null;
+                }
+            }
+            if (buf[index++] > JAVAZI_VERSION) {
+                System.err.println("ZoneInfo: incompatible version ("
+                                   + buf[index - 1] + "): " + id);
+                return null;
+            }
+
             while (index < filesize) {
                 byte tag = buf[index++];
                 int  len = ((buf[index++] & 0xFF) << 8) + (buf[index++] & 0xFF);
@@ -1017,30 +1028,33 @@
      * Reads the specified file under &lt;java.home&gt;/lib/zi into a buffer.
      * @return the buffer, or null if any I/O error occurred.
      */
-    private static byte[] readZoneInfoFile(String fileName) {
+    private static byte[] readZoneInfoFile(final String fileName) {
         byte[] buffer = null;
 
         try {
-            String homeDir = AccessController.doPrivileged(
-                new sun.security.action.GetPropertyAction("java.home"));
-            final String fname = homeDir + File.separator + "lib" + File.separator
-                                 + "zi" + File.separator + fileName;
             buffer = (byte[]) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                 public Object run() throws IOException {
-                    File file = new File(fname);
-                    if (!file.canRead()) {
+                    File file = new File(ziDir, fileName);
+                    if (!file.exists() || !file.isFile()) {
                         return null;
                     }
-                    int filesize = (int)file.length();
-                    byte[] buf = new byte[filesize];
-
-                    FileInputStream fis = new FileInputStream(file);
-
-                    if (fis.read(buf) != filesize) {
-                        fis.close();
-                        throw new IOException("read error on " + fname);
+                    file = file.getCanonicalFile();
+                    String path = file.getCanonicalPath();
+                    byte[] buf = null;
+                    if (path != null && path.startsWith(ziDir)) {
+                        int filesize = (int)file.length();
+                        if (filesize > 0) {
+                            FileInputStream fis = new FileInputStream(file);
+                            buf = new byte[filesize];
+                            try {
+                                if (fis.read(buf) != filesize) {
+                                    throw new IOException("read error on " + fileName);
+                                }
+                            } finally {
+                                fis.close();
+                            }
+                        }
                     }
-                    fis.close();
                     return buf;
                 }
             });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/util/logging/LoggingProxy.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,63 @@
+/*
+ * 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 sun.util.logging;
+
+/**
+ * A proxy interface for the java.util.logging support.
+ *
+ * @see sun.util.logging.LoggingSupport
+ */
+public interface LoggingProxy {
+    // Methods to bridge java.util.logging.Logger methods
+    public Object getLogger(String name);
+
+    public Object getLevel(Object logger);
+
+    public void setLevel(Object logger, Object newLevel);
+
+    public boolean isLoggable(Object logger, Object level);
+
+    public void log(Object logger, Object level, String msg);
+
+    public void log(Object logger, Object level, String msg, Throwable t);
+
+    public void log(Object logger, Object level, String msg, Object... params);
+
+    // Methods to bridge java.util.logging.LoggingMXBean methods
+    public java.util.List<String> getLoggerNames();
+
+    public String getLoggerLevel(String loggerName);
+
+    public void setLoggerLevel(String loggerName, String levelName);
+
+    public String getParentLoggerName(String loggerName);
+
+    // Methods to bridge Level.parse() and Level.getName() method
+    public Object parseLevel(String levelName);
+
+    public String getLevelName(Object level);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/sun/util/logging/LoggingSupport.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,141 @@
+/*
+ * 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 sun.util.logging;
+
+import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Internal API to support JRE implementation to detect if the java.util.logging
+ * support is available but with no dependency on the java.util.logging
+ * classes.  This LoggingSupport class provides several static methods to
+ * access the java.util.logging functionality that requires the caller
+ * to ensure that the logging support is {@linkplain #isAvailable available}
+ * before invoking it.
+ *
+ * @see sun.util.logging.PlatformLogger if you want to log messages even
+ * if the logging support is not available
+ */
+public class LoggingSupport {
+    private LoggingSupport() { }
+
+    private static final LoggingProxy proxy =
+        AccessController.doPrivileged(new PrivilegedAction<LoggingProxy>() {
+            public LoggingProxy run() {
+                try {
+                    // create a LoggingProxyImpl instance when
+                    // java.util.logging classes exist
+                    Class<?> c = Class.forName("java.util.logging.LoggingProxyImpl", true, null);
+                    Field f = c.getDeclaredField("INSTANCE");
+                    f.setAccessible(true);
+                    return (LoggingProxy) f.get(null);
+                } catch (ClassNotFoundException cnf) {
+                    return null;
+                } catch (NoSuchFieldException e) {
+                    throw new AssertionError(e);
+                } catch (IllegalAccessException e) {
+                    throw new AssertionError(e);
+                }
+            }});
+
+    /**
+     * Returns true if java.util.logging support is available.
+     */
+    public static boolean isAvailable() {
+        return proxy != null;
+    }
+
+    private static void ensureAvailable() {
+        if (proxy == null)
+            throw new AssertionError("Should not here");
+    }
+
+    public static java.util.List<String> getLoggerNames() {
+        ensureAvailable();
+        return proxy.getLoggerNames();
+    }
+    public static String getLoggerLevel(String loggerName) {
+        ensureAvailable();
+        return proxy.getLoggerLevel(loggerName);
+    }
+
+    public static void setLoggerLevel(String loggerName, String levelName) {
+        ensureAvailable();
+        proxy.setLoggerLevel(loggerName, levelName);
+    }
+
+    public static String getParentLoggerName(String loggerName) {
+        ensureAvailable();
+        return proxy.getParentLoggerName(loggerName);
+    }
+
+    public static Object getLogger(String name) {
+        ensureAvailable();
+        return proxy.getLogger(name);
+    }
+
+    public static Object getLevel(Object logger) {
+        ensureAvailable();
+        return proxy.getLevel(logger);
+    }
+
+    public static void setLevel(Object logger, Object newLevel) {
+        ensureAvailable();
+        proxy.setLevel(logger, newLevel);
+    }
+
+    public static boolean isLoggable(Object logger, Object level) {
+        ensureAvailable();
+        return proxy.isLoggable(logger,level);
+    }
+
+    public static void log(Object logger, Object level, String msg) {
+        ensureAvailable();
+        proxy.log(logger, level, msg);
+    }
+
+    public static void log(Object logger, Object level, String msg, Throwable t) {
+        ensureAvailable();
+        proxy.log(logger, level, msg, t);
+    }
+
+    public static void log(Object logger, Object level, String msg, Object... params) {
+        ensureAvailable();
+        proxy.log(logger, level, msg, params);
+    }
+
+    public static Object parseLevel(String levelName) {
+        ensureAvailable();
+        return proxy.parseLevel(levelName);
+    }
+
+    public static String getLevelName(Object level) {
+        ensureAvailable();
+        return proxy.getLevelName(level);
+    }
+}
--- a/src/share/classes/sun/util/logging/PlatformLogger.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/logging/PlatformLogger.java	Wed Nov 25 11:08:25 2009 -0800
@@ -136,7 +136,7 @@
      * This method is called from LogManager.readPrimordialConfiguration().
      */
     public static synchronized void redirectPlatformLoggers() {
-        if (loggingEnabled || !JavaLogger.supported) return;
+        if (loggingEnabled || !LoggingSupport.isAvailable()) return;
 
         loggingEnabled = true;
         for (Map.Entry<String, WeakReference<PlatformLogger>> entry : loggers.entrySet()) {
@@ -487,73 +487,22 @@
      * java.util.logging.Logger object.
      */
     static class JavaLogger extends LoggerProxy {
-        private static final boolean supported;
-        private static final Class<?> loggerClass;
-        private static final Class<?> levelClass;
-        private static final Method getLoggerMethod;
-        private static final Method setLevelMethod;
-        private static final Method getLevelMethod;
-        private static final Method isLoggableMethod;
-        private static final Method logMethod;
-        private static final Method logThrowMethod;
-        private static final Method logParamsMethod;
         private static final Map<Integer, Object> levelObjects =
             new HashMap<Integer, Object>();
 
         static {
-            loggerClass = getClass("java.util.logging.Logger");
-            levelClass = getClass("java.util.logging.Level");
-            getLoggerMethod = getMethod(loggerClass, "getLogger", String.class);
-            setLevelMethod = getMethod(loggerClass, "setLevel", levelClass);
-            getLevelMethod = getMethod(loggerClass, "getLevel");
-            isLoggableMethod = getMethod(loggerClass, "isLoggable", levelClass);
-            logMethod = getMethod(loggerClass, "log", levelClass, String.class);
-            logThrowMethod = getMethod(loggerClass, "log", levelClass, String.class, Throwable.class);
-            logParamsMethod = getMethod(loggerClass, "log", levelClass, String.class, Object[].class);
-            supported = (loggerClass != null && levelClass != null && getLoggerMethod != null &&
-                         getLevelMethod != null && setLevelMethod != null &&
-                         logMethod != null && logThrowMethod != null && logParamsMethod != null);
-            if (supported) {
+            if (LoggingSupport.isAvailable()) {
                 // initialize the map to Level objects
                 getLevelObjects();
             }
         }
 
-        private static Class<?> getClass(String name) {
-            try {
-                return Class.forName(name, true, null);
-            } catch (ClassNotFoundException e) {
-                return null;
-            }
-        }
-
-        private static Method getMethod(Class<?> cls, String name, Class<?>... parameterTypes) {
-            if (cls == null) return null;
-
-            try {
-                return cls.getMethod(name, parameterTypes);
-            } catch (NoSuchMethodException e) {
-                throw new AssertionError(e);
-            }
-        }
-
-        private static Object invoke(Method m, Object obj, Object... params) {
-            try {
-                return m.invoke(obj, params);
-            } catch (IllegalAccessException e) {
-                throw new AssertionError(e);
-            } catch (InvocationTargetException e) {
-                throw new AssertionError(e);
-            }
-        }
-
         private static void getLevelObjects() {
             // get all java.util.logging.Level objects
-            Method parseLevelMethod = getMethod(levelClass, "parse", String.class);
             int[] levelArray = new int[] {OFF, SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST, ALL};
             for (int l : levelArray) {
-                Object o = invoke(parseLevelMethod, null, getLevelName(l));
-                levelObjects.put(l, o);
+                Object level = LoggingSupport.parseLevel(getLevelName(l));
+                levelObjects.put(l, level);
             }
         }
 
@@ -564,10 +513,10 @@
 
         JavaLogger(String name, int level) {
             super(name, level);
-            this.javaLogger = invoke(getLoggerMethod, null, name);
+            this.javaLogger = LoggingSupport.getLogger(name);
             if (level != 0) {
                 // level has been updated and so set the Logger's level
-                invoke(setLevelMethod, javaLogger, levelObjects.get(level));
+                LoggingSupport.setLevel(javaLogger, levelObjects.get(level));
             }
         }
 
@@ -578,24 +527,24 @@
         * not be updated.
         */
         void doLog(int level, String msg) {
-            invoke(logMethod, javaLogger, levelObjects.get(level), msg);
+            LoggingSupport.log(javaLogger, levelObjects.get(level), msg);
         }
 
         void doLog(int level, String msg, Throwable t) {
-            invoke(logThrowMethod, javaLogger, levelObjects.get(level), msg, t);
+            LoggingSupport.log(javaLogger, levelObjects.get(level), msg, t);
         }
 
         void doLog(int level, String msg, Object... params) {
-            invoke(logParamsMethod, javaLogger, levelObjects.get(level), msg, params);
+            LoggingSupport.log(javaLogger, levelObjects.get(level), msg, params);
         }
 
         boolean isEnabled() {
-            Object level = invoke(getLevelMethod, javaLogger);
+            Object level = LoggingSupport.getLevel(javaLogger);
             return level == null || level.equals(levelObjects.get(OFF)) == false;
         }
 
         int getLevel() {
-            Object level = invoke(getLevelMethod, javaLogger);
+            Object level = LoggingSupport.getLevel(javaLogger);
             if (level != null) {
                 for (Map.Entry<Integer, Object> l : levelObjects.entrySet()) {
                     if (level == l.getValue()) {
@@ -608,15 +557,14 @@
 
         void setLevel(int newLevel) {
             levelValue = newLevel;
-            invoke(setLevelMethod, javaLogger, levelObjects.get(newLevel));
+            LoggingSupport.setLevel(javaLogger, levelObjects.get(newLevel));
         }
 
         public boolean isLoggable(int level) {
-            return (Boolean) invoke(isLoggableMethod, javaLogger, levelObjects.get(level));
+            return LoggingSupport.isLoggable(javaLogger, levelObjects.get(level));
         }
     }
 
-
     private static String getLevelName(int level) {
         switch (level) {
             case OFF     : return "OFF";
--- a/src/share/classes/sun/util/resources/TimeZoneNames.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "Malaysia Summer Time", "MYST"};
         String NORONHA[] = new String[] {"Fernando de Noronha Time", "FNT",
                                          "Fernando de Noronha Summer Time", "FNST"};
+        String NOVT[] = new String[] {"Novosibirsk Time", "NOVT",
+                                      "Novosibirsk Summer Time", "NOVST"};
         String NPT[] = new String[] {"Nepal Time", "NPT",
                                      "Nepal Summer Time", "NPST"};
         String NST[] = new String[] {"Newfoundland Standard Time", "NST",
@@ -441,7 +443,8 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
+            {"Antarctica/Casey", new String[] {"Casey Time", "CAST",
+                                               "Casey Summer Time", "CAST"}},
             {"Antarctica/Davis", new String[] {"Davis Time", "DAVT",
                                                "Davis Summer Time", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Dumont-d'Urville Time", "DDUT",
@@ -529,8 +532,8 @@
                                           "Philippines Summer Time", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Novosibirsk Time", "NOVT",
-                                               "Novosibirsk Summer Time", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Oral Time", "ORAT",
                                         "Oral Summer Time", "ORAST"}},
             {"Asia/Omsk", new String[] {"Omsk Time", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_de.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "Malaysische Sommerzeit", "MYST"};
         String NORONHA[] = new String[] {"Fernando de Noronha Zeit", "FNT",
                                          "Fernando de Noronha Sommerzeit", "FNST"};
+        String NOVT[] = new String[] {"Nowosibirsker Zeit", "NOVT",
+                                      "Nowosibirsker Sommerzeit", "NOVST"};
         String NPT[] = new String[] {"Nepalesische Zeit", "NPT",
                                      "Nepalesische Sommerzeit", "NPST"};
         String NST[] = new String[] {"Neufundland Normalzeit", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"Davis Zeit", "DAVT",
                                                "Davis Sommerzeit", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Dumont-d'Urville Zeit", "DDUT",
@@ -529,8 +530,8 @@
                                           "Philippinische Sommerzeit", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Nowosibirsker Zeit", "NOVT",
-                                               "Nowosibirsker Sommerzeit", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Oral Zeit", "ORAT",
                                         "Oral Sommerzeit", "ORAST"}},
             {"Asia/Omsk", new String[] {"Omsk Zeit", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_es.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "Hora de verano de Malasia", "MYST"};
         String NORONHA[] = new String[] {"Hora de Fernando de Noronha", "FNT",
                                          "Hora de verano de Fernando de Noronha", "FNST"};
+        String NOVT[] = new String[] {"Hora de Novosibirsk", "NOVT",
+                                      "Hora de verano de Novosibirsk", "NOVST"};
         String NPT[] = new String[] {"Hora de Nepal", "NPT",
                                      "Hora de verano de Nepal", "NPST"};
         String NST[] = new String[] {"Hora est\u00e1ndar de Terranova", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"Hora de Davis", "DAVT",
                                                "Hora de verano de Davis", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Hora de Dumont-d'Urville", "DDUT",
@@ -529,8 +530,9 @@
                                           "Hora de verano de Filipinas", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Hora de Novosibirsk", "NOVT",
-                                               "Hora de verano de Novosibirsk", "NOVST"}},
+
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Hora de Uralsk", "ORAT",
                                         "Hora de verano de Uralsk", "ORAST"}},
             {"Asia/Omsk", new String[] {"Hora de Omsk", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_fr.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "Heure d'\u00e9t\u00e9 de Malaisie", "MYST"};
         String NORONHA[] = new String[] {"Heure de Fernando de Noronha", "FNT",
                                          "Heure d'\u00e9t\u00e9 de Fernando de Noronha", "FNST"};
+        String NOVT[] = new String[] {"Heure de Novossibirsk", "NOVT",
+                                      "Heure d'\u00e9t\u00e9 de Novossibirsk", "NOVST"};
         String NPT[] = new String[] {"Heure du N\u00e9pal", "NPT",
                                      "Heure d'\u00e9t\u00e9 du N\u00e9pal", "NPST"};
         String NST[] = new String[] {"Heure normale de Terre-Neuve", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"Heure de Davis", "DAVT",
                                                "Heure d'\u00e9t\u00e9 de Davis", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Heure de Dumont-d'Urville", "DDUT",
@@ -529,8 +530,8 @@
                                           "Heure d'\u00e9t\u00e9 des Philippines", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Heure de Novossibirsk", "NOVT",
-                                               "Heure d'\u00e9t\u00e9 de Novossibirsk", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Heure d'Oral", "ORAT",
                                         "Heure d'\u00e9t\u00e9 d'Oral", "ORAST"}},
             {"Asia/Omsk", new String[] {"Heure d'Omsk", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_it.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "Ora estiva della Malaysia", "MYST"};
         String NORONHA[] = new String[] {"Ora di Fernando de Noronha", "FNT",
                                          "Ora estiva di Fernando de Noronha", "FNST"};
+        String NOVT[] = new String[] {"Ora di Novosibirsk", "NOVT",
+                                      "Ora estiva di Novosibirsk", "NOVST"};
         String NPT[] = new String[] {"Ora del Nepal", "NPT",
                                      "Ora estiva del Nepal", "NPST"};
         String NST[] = new String[] {"Ora solare di Terranova", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"Ora di Davis", "DAVT",
                                                "Ora estiva di Davis", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Ora di Dumont-d'Urville", "DDUT",
@@ -529,8 +530,8 @@
                                           "Ora estiva delle Filippine", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Ora di Novosibirsk", "NOVT",
-                                               "Ora estiva di Novosibirsk", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Ora di Oral", "ORAT",
                                         "Ora estiva di Oral", "ORAST"}},
             {"Asia/Omsk", new String[] {"Ora di Omsk", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_ja.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "\u30de\u30ec\u30fc\u30b7\u30a2\u590f\u6642\u9593", "MYST"};
         String NORONHA[] = new String[] {"\u30d5\u30a7\u30eb\u30ca\u30f3\u30c9\u30fb\u30c7\u30fb\u30ce\u30ed\u30fc\u30cb\u30e3\u6642\u9593", "FNT",
                                          "\u30d5\u30a7\u30eb\u30ca\u30f3\u30c9\u30fb\u30c7\u30fb\u30ce\u30ed\u30fc\u30cb\u30e3\u590f\u6642\u9593", "FNST"};
+        String NOVT[] = new String[] {"\u30ce\u30dc\u30b7\u30d3\u30eb\u30b9\u30af\u6642\u9593", "NOVT",
+                                      "\u30ce\u30dc\u30b7\u30d3\u30eb\u30b9\u30af\u590f\u6642\u9593", "NOVST"};
         String NPT[] = new String[] {"\u30cd\u30d1\u30fc\u30eb\u6642\u9593", "NPT",
                                       "\u30cd\u30d1\u30fc\u30eb\u590f\u6642\u9593", "NPST"};
         String NST[] = new String[] {"\u30cb\u30e5\u30fc\u30d5\u30a1\u30f3\u30c9\u30e9\u30f3\u30c9\u6a19\u6e96\u6642", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"\u30c7\u30a4\u30d3\u30b9\u6642\u9593", "DAVT",
                                                "\u30c7\u30a4\u30d3\u30b9\u590f\u6642\u9593", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"\u30c7\u30e5\u30e2\u30f3\u30c7\u30e5\u30eb\u30f4\u30a3\u30eb\u6642\u9593", "DDUT",
@@ -529,8 +530,8 @@
                                           "\u30d5\u30a3\u30ea\u30d4\u30f3\u590f\u6642\u9593", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"\u30ce\u30dc\u30b7\u30d3\u30eb\u30b9\u30af\u6642\u9593", "NOVT",
-                                               "\u30ce\u30dc\u30b7\u30d3\u30eb\u30b9\u30af\u590f\u6642\u9593", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"\u30aa\u30e9\u30eb\u6642\u9593", "ORAT",
                                         "\u30aa\u30e9\u30eb\u590f\u6642\u9593", "ORAST"}},
             {"Asia/Omsk", new String[] {"\u30aa\u30e0\u30b9\u30af\u6642\u9593", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_ko.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "\ub9d0\ub808\uc774\uc2dc\uc544 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "MYST"};
         String NORONHA[] = new String[] {"Fernando de Noronha \uc2dc\uac04", "FNT",
                                          "Fernando de Noronha \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "FNST"};
+        String NOVT[] = new String[] {"\ub178\ube0c\uc2dc\ube4c\uc2a4\ud06c \uc2dc\uac04", "NOVT",
+                                      "\ub178\ube0c\uc2dc\ube4c\uc2a4\ud06c \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "NOVST"};
         String NPT[] = new String[] {"\ub124\ud314 \uc2dc\uac04", "NPT",
                                       "\ub124\ud314 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "NPST"};
         String NST[] = new String[] {"\ub274\ud380\ub4e4\ub79c\ub4dc \ud45c\uc900\uc2dc", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"Davis \uc2dc\uac04", "DAVT",
                                                "Davis \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"\ub4a4\ubabd \ub4a4\ub974\ube4c \uc2dc\uac04", "DDUT",
@@ -529,8 +530,8 @@
                                           "\ud544\ub9ac\ud540 \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"\ub178\ube0c\uc2dc\ube4c\uc2a4\ud06c \uc2dc\uac04", "NOVT",
-                                               "\ub178\ube0c\uc2dc\ube4c\uc2a4\ud06c \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Oral \ud45c\uc900\uc2dc", "ORAT",
                                         "Oral \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "ORAST"}},
             {"Asia/Omsk", new String[] {"Omsk \uc2dc\uac04", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_sv.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "Malaysia, sommartid", "MYST"};
         String NORONHA[] = new String[] {"Fernando de Noronha, normaltid", "FNT",
                                          "Fernando de Noronha, sommartid", "FNST"};
+        String NOVT[] = new String[] {"Novosibirsk, normaltid", "NOVT",
+                                      "Novosibirsk, sommartid", "NOVST"};
         String NPT[] = new String[] {"Nepal, normaltid", "NPT",
                                      "Nepal, sommartid", "NPST"};
         String NST[] = new String[] {"Newfoundland, normaltid", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"Davis, normaltid", "DAVT",
                                                "Davis, sommartid", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Dumont-d'Urville, normaltid", "DDUT",
@@ -529,8 +530,8 @@
                                           "Filippinerna, sommartid", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Novosibirsk, normaltid", "NOVT",
-                                               "Novosibirsk, sommartid", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Oral, normaltid", "ORAT",
                                         "Oral, sommartid", "ORAST"}},
             {"Asia/Omsk", new String[] {"Omsk, normaltid", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "\u9a6c\u6765\u897f\u4e9a\u590f\u4ee4\u65f6", "MYST"};
         String NORONHA[] = new String[] {"\u8d39\u5c14\u5357\u591a\u5fb7\u8bfa\u7f57\u5c3c\u4e9a\u65f6\u95f4", "FNT",
                                          "\u8d39\u5c14\u5357\u591a\u5fb7\u8bfa\u7f57\u5c3c\u4e9a\u590f\u4ee4\u65f6", "FNST"};
+        String NOVT[] = new String[] {"Novosibirsk \u65f6\u95f4", "NOVT",
+                                      "Novosibirsk \u590f\u4ee4\u65f6", "NOVST"};
         String NPT[] = new String[] {"\u5c3c\u6cca\u5c14\u65f6\u95f4", "NPT",
                                      "\u5c3c\u6cca\u5c14\u590f\u4ee4\u65f6", "NPST"};
         String NST[] = new String[] {"\u7ebd\u82ac\u5170\u6807\u51c6\u65f6\u95f4", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"\u6234\u7ef4\u65af\u65f6\u95f4", "DAVT",
                                                "\u6234\u7ef4\u65af\u590f\u4ee4\u65f6", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Dumont-d'Urville \u65f6\u95f4", "DDUT",
@@ -529,8 +530,8 @@
                                           "\u83f2\u5f8b\u5bbe\u590f\u4ee4\u65f6", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Novosibirsk \u65f6\u95f4", "NOVT",
-                                               "Novosibirsk \u590f\u4ee4\u65f6", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"Oral \u65f6\u95f4", "ORAT",
                                         "Oral \u590f\u4ee4\u65f6", "ORAST"}},
             {"Asia/Omsk", new String[] {"\u9102\u6728\u65af\u514b\u65f6\u95f4", "OMST",
--- a/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java	Wed Nov 25 11:08:25 2009 -0800
@@ -141,6 +141,8 @@
                                      "\u99ac\u4f86\u897f\u4e9e\u590f\u4ee4\u6642\u9593", "MYST"};
         String NORONHA[] = new String[] {"\u8cbb\u723e\u5357\u591a-\u8fea\u8afe\u7f85\u5c3c\u4e9e\u6642\u9593", "FNT",
                                          "\u8cbb\u723e\u5357\u591a-\u8fea\u8afe\u7f85\u5c3c\u4e9e\u590f\u4ee4\u6642\u9593", "FNST"};
+        String NOVT[] = new String[] {"Novosibirsk \u6642\u9593", "NOVT",
+                                      "Novosibirsk \u590f\u4ee4\u6642\u9593", "NOVST"};
         String NPT[] = new String[] {"\u5c3c\u6cca\u723e\u6642\u9593", "NPT",
                                      "\u5c3c\u6cca\u723e\u590f\u4ee4\u6642\u9593", "NPST"};
         String NST[] = new String[] {"\u7d10\u82ac\u862d\u6a19\u6e96\u6642\u9593", "NST",
@@ -441,7 +443,6 @@
             {"America/Winnipeg", CST},
             {"America/Yakutat", AKST},
             {"America/Yellowknife", MST},
-            {"Antarctica/Casey", WST_AUS},
             {"Antarctica/Davis", new String[] {"\u81fa\u7dad\u65af\u6642\u9593", "DAVT",
                                                "\u81fa\u7dad\u65af\u590f\u4ee4\u6642\u9593", "DAVST"}},
             {"Antarctica/DumontDUrville", new String[] {"Dumont-d'Urville \u6642\u9593", "DDUT",
@@ -529,8 +530,8 @@
                                           "\u83f2\u5f8b\u8cd3\u590f\u4ee4\u6642\u9593", "PHST"}},
             {"Asia/Muscat", GST},
             {"Asia/Nicosia", EET},
-            {"Asia/Novosibirsk", new String[] {"Novosibirsk \u6642\u9593", "NOVT",
-                                               "Novosibirsk \u590f\u4ee4\u6642\u9593", "NOVST"}},
+            {"Asia/Novokuznetsk", NOVT},
+            {"Asia/Novosibirsk", NOVT},
             {"Asia/Oral", new String[] {"\u6b50\u4f5b\u6642\u9593", "ORAT",
                                         "\u6b50\u4f5b\u590f\u4ee4\u6642\u9593", "ORAST"}},
             {"Asia/Omsk", new String[] {"\u6b50\u59c6\u65af\u514b (Omsk) \u6642\u9593", "OMST",
--- a/src/share/native/java/util/zip/Deflater.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/native/java/util/zip/Deflater.c	Wed Nov 25 11:08:25 2009 -0800
@@ -118,7 +118,7 @@
 
 JNIEXPORT jint JNICALL
 Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this,
-                                         jarray b, jint off, jint len)
+                                         jarray b, jint off, jint len, jint flush)
 {
     z_stream *strm = jlong_to_ptr((*env)->GetLongField(env, this, strmID));
 
@@ -197,7 +197,7 @@
             strm->next_out = (Bytef *) out_buf;
             strm->avail_in = this_len;
             strm->avail_out = len;
-            res = deflate(strm, finish ? Z_FINISH : Z_NO_FLUSH);
+            res = deflate(strm, finish ? Z_FINISH : flush);
 
             if (res == Z_STREAM_END || res == Z_OK) {
                 (*env)->SetByteArrayRegion(env, b, off, len - strm->avail_out, out_buf);
--- a/src/share/native/sun/awt/image/awt_ImageRep.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/native/sun/awt/image/awt_ImageRep.c	Wed Nov 25 11:08:25 2009 -0800
@@ -142,84 +142,6 @@
 
 }
 
-JNIEXPORT void JNICALL
-Java_sun_awt_image_ImageRepresentation_setBytePixels(JNIEnv *env, jclass cls,
-                                                     jint x, jint y, jint w,
-                                                     jint h, jbyteArray jpix,
-                                                     jint off, jint scansize,
-                                                     jobject jbct,
-                                                     jint chanOffs)
-{
-    int sStride;
-    int pixelStride;
-    jobject jdata;
-    unsigned char *srcData;
-    unsigned char *dstData;
-    unsigned char *dataP;
-    unsigned char *pixP;
-    int i;
-    int j;
-
-
-    if (JNU_IsNull(env, jpix)) {
-        JNU_ThrowNullPointerException(env, "NullPointerException");
-        return;
-    }
-
-    sStride = (*env)->GetIntField(env, jbct, g_BCRscanstrID);
-    pixelStride = (*env)->GetIntField(env, jbct, g_BCRpixstrID);
-    jdata = (*env)->GetObjectField(env, jbct, g_BCRdataID);
-
-    srcData = (unsigned char *) (*env)->GetPrimitiveArrayCritical(env, jpix,
-                                                                  NULL);
-    if (srcData == NULL) {
-        /* out of memory error already thrown */
-        return;
-    }
-
-    dstData = (unsigned char *) (*env)->GetPrimitiveArrayCritical(env, jdata,
-                                                                  NULL);
-    if (dstData == NULL) {
-        /* out of memory error already thrown */
-        (*env)->ReleasePrimitiveArrayCritical(env, jpix, srcData, JNI_ABORT);
-        return;
-    }
-
-    dataP = dstData + chanOffs + y*sStride + x*pixelStride;
-    pixP  = srcData + off;
-    if (pixelStride == 1) {
-        if (sStride == scansize && scansize == w) {
-            memcpy(dataP, pixP, w*h);
-        }
-        else {
-            for (i=0; i < h; i++) {
-                memcpy(dataP, pixP, w);
-                dataP += sStride;
-                pixP  += scansize;
-            }
-        }
-    }
-    else {
-        unsigned char *ydataP = dataP;
-        unsigned char *ypixP  = pixP;
-
-        for (i=0; i < h; i++) {
-            dataP = ydataP;
-            pixP = ypixP;
-            for (j=0; j < w; j++) {
-                *dataP = *pixP++;
-                dataP += pixelStride;
-            }
-            ydataP += sStride;
-            ypixP  += scansize;
-        }
-    }
-
-    (*env)->ReleasePrimitiveArrayCritical(env, jpix, srcData, JNI_ABORT);
-    (*env)->ReleasePrimitiveArrayCritical(env, jdata, dstData, JNI_ABORT);
-
-}
-
 JNIEXPORT jint JNICALL
 Java_sun_awt_image_ImageRepresentation_setDiffICM(JNIEnv *env, jclass cls,
                                                   jint x, jint y, jint w,
@@ -266,6 +188,13 @@
     jnewlut = (*env)->GetObjectField(env, jicm, g_ICMrgbID);
     mapSize = (*env)->GetIntField(env, jicm, g_ICMmapSizeID);
 
+    if (numLut < 0 || numLut > 256 || mapSize < 0 || mapSize > 256) {
+        /* Ether old or new ICM has a palette that exceeds capacity
+           of byte data type, so we have to convert the image data
+           to default representation.
+        */
+        return 0;
+    }
     srcLUT = (unsigned int *) (*env)->GetPrimitiveArrayCritical(env, jlut,
                                                                 NULL);
     if (srcLUT == NULL) {
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c	Wed Nov 25 11:08:25 2009 -0800
@@ -676,6 +676,10 @@
 #ifdef DEBUG_IIO_JPEG
     printf("in setQTables, qlen = %d, write is %d\n", qlen, write);
 #endif
+    if (qlen > NUM_QUANT_TBLS) {
+        /* Ignore extra qunterization tables. */
+        qlen = NUM_QUANT_TBLS;
+    }
     for (i = 0; i < qlen; i++) {
         table = (*env)->GetObjectArrayElement(env, qtables, i);
         qdata = (*env)->GetObjectField(env, table, JPEGQTable_tableID);
@@ -727,6 +731,11 @@
     hlensBody = (*env)->GetShortArrayElements(env,
                                               huffLens,
                                               NULL);
+    if (hlensLen > 16) {
+        /* Ignore extra elements of bits array. Only 16 elements can be
+           stored. 0-th element is not used. (see jpeglib.h, line 107)  */
+        hlensLen = 16;
+    }
     for (i = 1; i <= hlensLen; i++) {
         huff_ptr->bits[i] = (UINT8)hlensBody[i-1];
     }
@@ -743,6 +752,11 @@
                                               huffValues,
                                               NULL);
 
+    if (hvalsLen > 256) {
+        /* Ignore extra elements of hufval array. Only 256 elements
+           can be stored. (see jpeglib.h, line 109)                  */
+        hlensLen = 256;
+    }
     for (i = 0; i < hvalsLen; i++) {
         huff_ptr->huffval[i] = (UINT8)hvalsBody[i];
     }
@@ -763,6 +777,11 @@
     j_compress_ptr comp;
     j_decompress_ptr decomp;
     jsize hlen = (*env)->GetArrayLength(env, DCHuffmanTables);
+
+    if (hlen > NUM_HUFF_TBLS) {
+        /* Ignore extra DC huffman tables. */
+        hlen = NUM_HUFF_TBLS;
+    }
     for (i = 0; i < hlen; i++) {
         if (cinfo->is_decompressor) {
             decomp = (j_decompress_ptr) cinfo;
@@ -784,6 +803,10 @@
         huff_ptr->sent_table = !write;
     }
     hlen = (*env)->GetArrayLength(env, ACHuffmanTables);
+    if (hlen > NUM_HUFF_TBLS) {
+        /* Ignore extra AC huffman tables. */
+        hlen = NUM_HUFF_TBLS;
+    }
     for (i = 0; i < hlen; i++) {
         if (cinfo->is_decompressor) {
             decomp = (j_decompress_ptr) cinfo;
@@ -1437,6 +1460,7 @@
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Reader");
+        free(cinfo);
         return 0;
     }
 
@@ -1473,6 +1497,7 @@
         JNU_ThrowByName(env,
                         "java/lang/OutOfMemoryError",
                         "Initializing Reader");
+        imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
     cinfo->src->bytes_in_buffer = 0;
@@ -1489,6 +1514,7 @@
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Reader");
+        imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
     return (jlong) ret;
@@ -1833,6 +1859,13 @@
         return JNI_FALSE;
     }
 
+    if (stepX > cinfo->image_width) {
+        stepX = cinfo->image_width;
+    }
+    if (stepY > cinfo->image_height) {
+        stepY = cinfo->image_height;
+    }
+
     /*
      * First get the source bands array and copy it to our local array
      * so we don't have to worry about pinning and unpinning it again.
@@ -2420,8 +2453,7 @@
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Writer");
-        free(cinfo);
-        free(jerr);
+        imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
 
@@ -2439,8 +2471,7 @@
         JNU_ThrowByName( env,
                          "java/lang/OutOfMemoryError",
                          "Initializing Writer");
-        free(cinfo);
-        free(jerr);
+        imageio_dispose((j_common_ptr)cinfo);
         return 0;
     }
     return (jlong) ret;
--- a/src/share/native/sun/awt/medialib/awt_ImagingLib.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/native/sun/awt/medialib/awt_ImagingLib.c	Wed Nov 25 11:08:25 2009 -0800
@@ -960,21 +960,15 @@
     mlib_filter filter;
     unsigned int *dP;
 
-    if ((srcRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "Out of memory");
-        return -1;
-    }
-
-    if ((dstRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
-        JNU_ThrowOutOfMemoryError(env, "Out of memory");
-        free(srcRasterP);
-        return -1;
-    }
-
     /* This function requires a lot of local refs ??? Is 64 enough ??? */
     if ((*env)->EnsureLocalCapacity(env, 64) < 0)
         return 0;
 
+    if (s_nomlib) return 0;
+    if (s_timeIt) {
+        (*start_timer)(3600);
+    }
+
     switch(interpType) {
     case java_awt_image_AffineTransformOp_TYPE_BILINEAR:
         filter = MLIB_BILINEAR;
@@ -990,9 +984,15 @@
         return -1;
     }
 
-    if (s_nomlib) return 0;
-    if (s_timeIt) {
-        (*start_timer)(3600);
+    if ((srcRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "Out of memory");
+        return -1;
+    }
+
+    if ((dstRasterP = (RasterS_t *) calloc(1, sizeof(RasterS_t))) == NULL) {
+        JNU_ThrowOutOfMemoryError(env, "Out of memory");
+        free(srcRasterP);
+        return -1;
     }
 
     if ((*env)->GetArrayLength(env, jmatrix) < 6) {
@@ -1215,6 +1215,9 @@
     }
 
     if (tbl == NULL || table == NULL || jtable == NULL) {
+        if (tbl != NULL) free(tbl);
+        if (table != NULL) free(table);
+        if (jtable != NULL) free(jtable);
         awt_freeParsedImage(srcImageP, TRUE);
         awt_freeParsedImage(dstImageP, TRUE);
         JNU_ThrowNullPointerException(env, "NULL LUT");
@@ -1224,6 +1227,11 @@
     for (i=0; i < jlen; i++) {
         jtable[i] = (*env)->GetObjectArrayElement(env, jtableArrays, i);
         if (jtable[i] == NULL) {
+            free(tbl);
+            free(table);
+            free(jtable);
+            awt_freeParsedImage(srcImageP, TRUE);
+            awt_freeParsedImage(dstImageP, TRUE);
             return 0;
         }
     }
@@ -1232,6 +1240,9 @@
                         FALSE, &hint);
     if (nbands < 1) {
         /* Can't handle any custom images */
+        free(tbl);
+        free(table);
+        free(jtable);
         awt_freeParsedImage(srcImageP, TRUE);
         awt_freeParsedImage(dstImageP, TRUE);
         return 0;
@@ -1240,12 +1251,18 @@
     /* Allocate the arrays */
     if (allocateArray(env, srcImageP, &src, &sdata, TRUE, FALSE, FALSE) < 0) {
         /* Must be some problem */
+        free(tbl);
+        free(table);
+        free(jtable);
         awt_freeParsedImage(srcImageP, TRUE);
         awt_freeParsedImage(dstImageP, TRUE);
         return 0;
     }
     if (allocateArray(env, dstImageP, &dst, &ddata, FALSE, FALSE, FALSE) < 0) {
         /* Must be some problem */
+        free(tbl);
+        free(table);
+        free(jtable);
         freeArray(env, srcImageP, src, sdata, NULL, NULL, NULL);
         awt_freeParsedImage(srcImageP, TRUE);
         awt_freeParsedImage(dstImageP, TRUE);
@@ -1284,6 +1301,9 @@
                                                       (jbyte *) table[j],
                                                       JNI_ABORT);
             }
+            free(tbl);
+            free(table);
+            free(jtable);
             freeArray(env, srcImageP, src, sdata, NULL, NULL, NULL);
             awt_freeParsedImage(srcImageP, TRUE);
             awt_freeParsedImage(dstImageP, TRUE);
@@ -1413,12 +1433,15 @@
 
     /* Parse the source raster - reject custom images */
     if ((status = awt_parseRaster(env, jsrc, srcRasterP)) <= 0) {
+        free(srcRasterP);
+        free(dstRasterP);
         return 0;
     }
 
     /* Parse the destination image - reject custom images */
     if ((status = awt_parseRaster(env, jdst, dstRasterP)) <= 0) {
         awt_freeParsedRaster(srcRasterP, TRUE);
+        free(dstRasterP);
         return 0;
     }
 
--- a/src/share/native/sun/font/freetypeScaler.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/share/native/sun/font/freetypeScaler.c	Wed Nov 25 11:08:25 2009 -0800
@@ -102,9 +102,21 @@
 }
 
 static void freeNativeResources(JNIEnv *env, FTScalerInfo* scalerInfo) {
+    void *stream;
+
     if (scalerInfo == NULL)
         return;
 
+    //apparently Done_Face will only close the stream
+    // but will not relase the memory of stream structure.
+    // We need to free it explicitly to avoid leak.
+    //Direct access to the stream field might be not ideal solution as
+    // it is considred to be "private".
+    //Alternatively we could have stored pointer to the structure
+    // in the scalerInfo but this will increase size of the structure
+    // for no good reason
+    stream = scalerInfo->face->stream;
+
     FT_Done_Face(scalerInfo->face);
     FT_Done_FreeType(scalerInfo->library);
 
@@ -116,6 +128,10 @@
         free(scalerInfo->fontData);
     }
 
+   if (stream != NULL) {
+        free(stream);
+   }
+
     free(scalerInfo);
 }
 
--- a/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/java/util/prefs/FileSystemPreferences.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,12 +26,12 @@
 package java.util.prefs;
 import java.util.*;
 import java.io.*;
-import java.util.logging.Logger;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedActionException;
 
+import sun.util.logging.PlatformLogger;
 
 /**
  * Preferences implementation for Unix.  Preferences are stored in the file
@@ -61,8 +61,8 @@
      * Returns logger for error messages. Backing store exceptions are logged at
      * WARNING level.
      */
-    private static Logger getLogger() {
-        return Logger.getLogger("java.util.prefs");
+    private static PlatformLogger getLogger() {
+        return PlatformLogger.getLogger("java.util.prefs");
     }
 
     /**
--- a/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/awt/X11/XDropTargetRegistry.java	Wed Nov 25 11:08:25 2009 -0800
@@ -534,71 +534,71 @@
         return entry.getSite(x, y);
     }
 
+    /*
+     * Note: this method should be called under AWT lock.
+     */
     public void registerDropSite(long window) {
+        assert XToolkit.isAWTLockHeldByCurrentThread();
+
         if (window == 0) {
             throw new IllegalArgumentException();
         }
 
         XDropTargetEventProcessor.activate();
 
-        XToolkit.awtLock();
-        try {
-            long toplevel = getToplevelWindow(window);
+        long toplevel = getToplevelWindow(window);
 
-            /*
-             * No window with WM_STATE property is found.
-             * Since the window can be a plugin window reparented to the browser
-             * toplevel, we cannot determine which window will eventually have
-             * WM_STATE property set. So we schedule a timer callback that will
-             * periodically attempt to find an ancestor with WM_STATE and
-             * register the drop site appropriately.
-             */
-            if (toplevel == 0) {
-                addDelayedRegistrationEntry(window);
-                return;
+        /*
+         * No window with WM_STATE property is found.
+         * Since the window can be a plugin window reparented to the browser
+         * toplevel, we cannot determine which window will eventually have
+         * WM_STATE property set. So we schedule a timer callback that will
+         * periodically attempt to find an ancestor with WM_STATE and
+         * register the drop site appropriately.
+         */
+        if (toplevel == 0) {
+            addDelayedRegistrationEntry(window);
+            return;
+        }
+
+        if (toplevel == window) {
+            Iterator dropTargetProtocols =
+                XDragAndDropProtocols.getDropTargetProtocols();
+
+            while (dropTargetProtocols.hasNext()) {
+                XDropTargetProtocol dropTargetProtocol =
+                    (XDropTargetProtocol)dropTargetProtocols.next();
+                dropTargetProtocol.registerDropTarget(toplevel);
             }
-
-            if (toplevel == window) {
-                Iterator dropTargetProtocols =
-                    XDragAndDropProtocols.getDropTargetProtocols();
-
-                while (dropTargetProtocols.hasNext()) {
-                    XDropTargetProtocol dropTargetProtocol =
-                        (XDropTargetProtocol)dropTargetProtocols.next();
-                    dropTargetProtocol.registerDropTarget(toplevel);
-                }
-            } else {
-                registerEmbeddedDropSite(toplevel, window);
-            }
-        } finally {
-            XToolkit.awtUnlock();
+        } else {
+            registerEmbeddedDropSite(toplevel, window);
         }
     }
 
+    /*
+     * Note: this method should be called under AWT lock.
+     */
     public void unregisterDropSite(long window) {
+        assert XToolkit.isAWTLockHeldByCurrentThread();
+
         if (window == 0) {
             throw new IllegalArgumentException();
         }
 
-        XToolkit.awtLock();
-        try {
-            long toplevel = getToplevelWindow(window);
+        long toplevel = getToplevelWindow(window);
 
-            if (toplevel == window) {
-                Iterator dropProtocols =
-                    XDragAndDropProtocols.getDropTargetProtocols();
-
-                removeDelayedRegistrationEntry(window);
+        if (toplevel == window) {
+            Iterator dropProtocols =
+                XDragAndDropProtocols.getDropTargetProtocols();
 
-                while (dropProtocols.hasNext()) {
-                    XDropTargetProtocol dropProtocol = (XDropTargetProtocol)dropProtocols.next();
-                    dropProtocol.unregisterDropTarget(window);
-                }
-            } else {
-                unregisterEmbeddedDropSite(toplevel, window);
+            removeDelayedRegistrationEntry(window);
+
+            while (dropProtocols.hasNext()) {
+                XDropTargetProtocol dropProtocol = (XDropTargetProtocol)dropProtocols.next();
+                dropProtocol.unregisterDropTarget(window);
             }
-        } finally {
-            XToolkit.awtUnlock();
+        } else {
+            unregisterEmbeddedDropSite(toplevel, window);
         }
     }
 
--- a/src/solaris/classes/sun/awt/X11/XWindow.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/awt/X11/XWindow.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1509,4 +1509,24 @@
         return new XAtomList();
     }
 
+    /**
+     * Indicates if the window is currently in the FSEM.
+     * Synchronization: state lock.
+     */
+    private boolean fullScreenExclusiveModeState = false;
+
+    // Implementation of the X11ComponentPeer
+    @Override
+    public void setFullScreenExclusiveModeState(boolean state) {
+        synchronized (getStateLock()) {
+            fullScreenExclusiveModeState = state;
+        }
+    }
+
+    public final boolean isFullScreenExclusiveMode() {
+        synchronized (getStateLock()) {
+            return fullScreenExclusiveModeState;
+        }
+    }
+
 }
--- a/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/awt/X11/XWindowPeer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1079,31 +1079,39 @@
         updateSecurityWarningVisibility();
     }
 
+    @Override
+    public void setFullScreenExclusiveModeState(boolean state) {
+        super.setFullScreenExclusiveModeState(state);
+        updateSecurityWarningVisibility();
+    }
+
     public void updateSecurityWarningVisibility() {
         if (warningWindow == null) {
             return;
         }
 
-        boolean show = false;
-
-        int state = getWMState();
-
         if (!isVisible()) {
             return; // The warning window should already be hidden.
         }
 
-        // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
-        // we ignore the state for such windows.
-        if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
-            if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() ==
-                    getTarget())
-            {
-                show = true;
-            }
+        boolean show = false;
+
+        if (!isFullScreenExclusiveMode()) {
+            int state = getWMState();
 
-            if (isMouseAbove() || warningWindow.isMouseAbove())
-            {
-                show = true;
+            // getWMState() always returns 0 (Withdrawn) for simple windows. Hence
+            // we ignore the state for such windows.
+            if (isVisible() && (state == XUtilConstants.NormalState || isSimpleWindow())) {
+                if (XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow() ==
+                        getTarget())
+                {
+                    show = true;
+                }
+
+                if (isMouseAbove() || warningWindow.isMouseAbove())
+                {
+                    show = true;
+                }
             }
         }
 
@@ -1756,25 +1764,36 @@
         }
     }
 
+    // should be synchronized on awtLock
     private int dropTargetCount = 0;
 
-    public synchronized void addDropTarget() {
-        if (dropTargetCount == 0) {
-            long window = getWindow();
-            if (window != 0) {
-                XDropTargetRegistry.getRegistry().registerDropSite(window);
+    public void addDropTarget() {
+        XToolkit.awtLock();
+        try {
+            if (dropTargetCount == 0) {
+                long window = getWindow();
+                if (window != 0) {
+                    XDropTargetRegistry.getRegistry().registerDropSite(window);
+                }
             }
+            dropTargetCount++;
+        } finally {
+            XToolkit.awtUnlock();
         }
-        dropTargetCount++;
     }
 
-    public synchronized void removeDropTarget() {
-        dropTargetCount--;
-        if (dropTargetCount == 0) {
-            long window = getWindow();
-            if (window != 0) {
-                XDropTargetRegistry.getRegistry().unregisterDropSite(window);
+    public void removeDropTarget() {
+        XToolkit.awtLock();
+        try {
+            dropTargetCount--;
+            if (dropTargetCount == 0) {
+                long window = getWindow();
+                if (window != 0) {
+                    XDropTargetRegistry.getRegistry().unregisterDropSite(window);
+                }
             }
+        } finally {
+            XToolkit.awtUnlock();
         }
     }
     void addRootPropertyEventDispatcher() {
@@ -1837,13 +1856,18 @@
         }
     }
 
-    protected synchronized void updateDropTarget() {
-        if (dropTargetCount > 0) {
-            long window = getWindow();
-            if (window != 0) {
-                XDropTargetRegistry.getRegistry().unregisterDropSite(window);
-                XDropTargetRegistry.getRegistry().registerDropSite(window);
+    protected void updateDropTarget() {
+        XToolkit.awtLock();
+        try {
+            if (dropTargetCount > 0) {
+                long window = getWindow();
+                if (window != 0) {
+                    XDropTargetRegistry.getRegistry().unregisterDropSite(window);
+                    XDropTargetRegistry.getRegistry().registerDropSite(window);
+                }
             }
+        } finally {
+            XToolkit.awtUnlock();
         }
     }
 
--- a/src/solaris/classes/sun/awt/X11ComponentPeer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/awt/X11ComponentPeer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -39,4 +39,5 @@
     Rectangle getBounds();
     Graphics getGraphics();
     Object getTarget();
+    void setFullScreenExclusiveModeState(boolean state);
 }
--- a/src/solaris/classes/sun/awt/X11GraphicsDevice.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/awt/X11GraphicsDevice.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 1997-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
@@ -134,7 +134,7 @@
                 makeConfigurations();
             }
         }
-        return configs;
+        return configs.clone();
     }
 
     private void makeConfigurations() {
@@ -306,12 +306,14 @@
         X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
         if (peer != null) {
             enterFullScreenExclusive(peer.getContentWindow());
+            peer.setFullScreenExclusiveModeState(true);
         }
     }
 
     private static void exitFullScreenExclusive(Window w) {
         X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
         if (peer != null) {
+            peer.setFullScreenExclusiveModeState(false);
             exitFullScreenExclusive(peer.getContentWindow());
         }
     }
--- a/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/java2d/x11/X11SurfaceData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -388,7 +388,10 @@
             // if a GlyphVector overrides the AA setting.
             // We use getRenderLoops() rather than setting solidloops
             // directly so that we get the appropriate loops in XOR mode.
-            sg2d.loops = getRenderLoops(sg2d);
+            if (sg2d.loops == null) {
+                // assert(some pipe will always be a LoopBasedPipe)
+                sg2d.loops = getRenderLoops(sg2d);
+            }
         } else {
             super.validatePipe(sg2d);
         }
--- a/src/solaris/classes/sun/net/NetHooks.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/net/NetHooks.java	Wed Nov 25 11:08:25 2009 -0800
@@ -81,7 +81,7 @@
                     try {
                         c = (Class<Provider>)Class.forName(cn, true, null);
                     } catch (ClassNotFoundException x) {
-                        throw new AssertionError(x);
+                        return null;
                     }
                     try {
                         return c.newInstance();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/solaris/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,423 @@
+/*
+ * Copyright 2005-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 sun.net.www.protocol.http.ntlm;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.InetAddress;
+import java.net.PasswordAuthentication;
+import java.net.UnknownHostException;
+import java.net.URL;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import javax.crypto.Cipher;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.SecretKey;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.DESKeySpec;
+
+import sun.net.www.HeaderParser;
+import sun.net.www.protocol.http.AuthenticationInfo;
+import sun.net.www.protocol.http.AuthScheme;
+import sun.net.www.protocol.http.HttpURLConnection;
+
+/**
+ * NTLMAuthentication:
+ *
+ * @author Michael McMahon
+ */
+
+/*
+ * NTLM authentication is nominally based on the framework defined in RFC2617,
+ * but differs from the standard (Basic & Digest) schemes as follows:
+ *
+ * 1. A complete authentication requires three request/response transactions
+ *    as shown below:
+ *            REQ ------------------------------->
+ *            <---- 401 (signalling NTLM) --------
+ *
+ *            REQ (with type1 NTLM msg) --------->
+ *            <---- 401 (with type 2 NTLM msg) ---
+ *
+ *            REQ (with type3 NTLM msg) --------->
+ *            <---- OK ---------------------------
+ *
+ * 2. The scope of the authentication is the TCP connection (which must be kept-alive)
+ *    after the type2 response is received. This means that NTLM does not work end-to-end
+ *    through a proxy, rather between client and proxy, or between client and server (with no proxy)
+ */
+
+public class NTLMAuthentication extends AuthenticationInfo {
+    private static final long serialVersionUID = -2403849171106437142L;
+
+    private byte[] type1;
+    private byte[] type3;
+
+    private SecretKeyFactory fac;
+    private Cipher cipher;
+    private MessageDigest md4;
+    private String hostname;
+    private static String defaultDomain; /* Domain to use if not specified by user */
+
+    static {
+        defaultDomain = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("http.auth.ntlm.domain",
+                                                      "domain"));
+    };
+
+    public static boolean supportsTransparentAuth () {
+        return false;
+    }
+
+    private void init0() {
+        type1 = new byte[256];
+        type3 = new byte[256];
+        System.arraycopy (new byte[] {'N','T','L','M','S','S','P',0,1}, 0, type1, 0, 9);
+        type1[12] = (byte) 3;
+        type1[13] = (byte) 0xb2;
+        type1[28] = (byte) 0x20;
+        System.arraycopy (new byte[] {'N','T','L','M','S','S','P',0,3}, 0, type3, 0, 9);
+        type3[12] = (byte) 0x18;
+        type3[14] = (byte) 0x18;
+        type3[20] = (byte) 0x18;
+        type3[22] = (byte) 0x18;
+        type3[32] = (byte) 0x40;
+        type3[60] = (byte) 1;
+        type3[61] = (byte) 0x82;
+
+        try {
+            hostname = java.security.AccessController.doPrivileged(
+                new java.security.PrivilegedAction<String>() {
+                public String run() {
+                    String localhost;
+                    try {
+                        localhost = InetAddress.getLocalHost().getHostName().toUpperCase();
+                    } catch (UnknownHostException e) {
+                         localhost = "localhost";
+                    }
+                    return localhost;
+                }
+            });
+            int x = hostname.indexOf ('.');
+            if (x != -1) {
+                hostname = hostname.substring (0, x);
+            }
+            fac = SecretKeyFactory.getInstance ("DES");
+            cipher = Cipher.getInstance ("DES/ECB/NoPadding");
+            md4 = sun.security.provider.MD4.getInstance();
+        } catch (NoSuchPaddingException e) {
+            assert false;
+        } catch (NoSuchAlgorithmException e) {
+            assert false;
+        }
+    };
+
+    PasswordAuthentication pw;
+    String username;
+    String ntdomain;
+    String password;
+
+    /**
+     * Create a NTLMAuthentication:
+     * Username may be specified as domain<BACKSLASH>username in the application Authenticator.
+     * If this notation is not used, then the domain will be taken
+     * from a system property: "http.auth.ntlm.domain".
+     */
+    public NTLMAuthentication(boolean isProxy, URL url, PasswordAuthentication pw) {
+        super(isProxy ? PROXY_AUTHENTICATION : SERVER_AUTHENTICATION,
+                AuthScheme.NTLM,
+                url,
+                "");
+        init (pw);
+    }
+
+    private void init (PasswordAuthentication pw) {
+        this.pw = pw;
+        String s = pw.getUserName();
+        int i = s.indexOf ('\\');
+        if (i == -1) {
+            username = s;
+            ntdomain = defaultDomain;
+        } else {
+            ntdomain = s.substring (0, i).toUpperCase();
+            username = s.substring (i+1);
+        }
+        password = new String (pw.getPassword());
+        init0();
+    }
+
+   /**
+    * Constructor used for proxy entries
+    */
+    public NTLMAuthentication(boolean isProxy, String host, int port,
+                                PasswordAuthentication pw) {
+        super(isProxy ? PROXY_AUTHENTICATION : SERVER_AUTHENTICATION,
+                AuthScheme.NTLM,
+                host,
+                port,
+                "");
+        init (pw);
+    }
+
+    /**
+     * @return true if this authentication supports preemptive authorization
+     */
+    @Override
+    public boolean supportsPreemptiveAuthorization() {
+        return false;
+    }
+
+    /**
+     * Not supported. Must use the setHeaders() method
+     */
+    @Override
+    public String getHeaderValue(URL url, String method) {
+        throw new RuntimeException ("getHeaderValue not supported");
+    }
+
+    /**
+     * Check if the header indicates that the current auth. parameters are stale.
+     * If so, then replace the relevant field with the new value
+     * and return true. Otherwise return false.
+     * returning true means the request can be retried with the same userid/password
+     * returning false means we have to go back to the user to ask for a new
+     * username password.
+     */
+    @Override
+    public boolean isAuthorizationStale (String header) {
+        return false; /* should not be called for ntlm */
+    }
+
+    /**
+     * Set header(s) on the given connection.
+     * @param conn The connection to apply the header(s) to
+     * @param p A source of header values for this connection, not used because
+     *          HeaderParser converts the fields to lower case, use raw instead
+     * @param raw The raw header field.
+     * @return true if all goes well, false if no headers were set.
+     */
+    @Override
+    public synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
+
+        try {
+            String response;
+            if (raw.length() < 6) { /* NTLM<sp> */
+                response = buildType1Msg ();
+            } else {
+                String msg = raw.substring (5); /* skip NTLM<sp> */
+                response = buildType3Msg (msg);
+            }
+            conn.setAuthenticationProperty(getHeaderName(), response);
+            return true;
+        } catch (IOException e) {
+            return false;
+        } catch (GeneralSecurityException e) {
+            return false;
+        }
+    }
+
+    private void copybytes (byte[] dest, int destpos, String src, String enc) {
+        try {
+            byte[] x = src.getBytes(enc);
+            System.arraycopy (x, 0, dest, destpos, x.length);
+        } catch (UnsupportedEncodingException e) {
+            assert false;
+        }
+    }
+
+    private String buildType1Msg () {
+        int dlen = ntdomain.length();
+        type1[16]= (byte) (dlen % 256);
+        type1[17]= (byte) (dlen / 256);
+        type1[18] = type1[16];
+        type1[19] = type1[17];
+
+        int hlen = hostname.length();
+        type1[24]= (byte) (hlen % 256);
+        type1[25]= (byte) (hlen / 256);
+        type1[26] = type1[24];
+        type1[27] = type1[25];
+
+        copybytes (type1, 32, hostname, "ISO8859_1");
+        copybytes (type1, hlen+32, ntdomain, "ISO8859_1");
+        type1[20] = (byte) ((hlen+32) % 256);
+        type1[21] = (byte) ((hlen+32) / 256);
+
+        byte[] msg = new byte [32 + hlen + dlen];
+        System.arraycopy (type1, 0, msg, 0, 32 + hlen + dlen);
+        String result = "NTLM " + (new B64Encoder()).encode (msg);
+        return result;
+    }
+
+
+    /* Convert a 7 byte array to an 8 byte array (for a des key with parity)
+     * input starts at offset off
+     */
+    private byte[] makeDesKey (byte[] input, int off) {
+        int[] in = new int [input.length];
+        for (int i=0; i<in.length; i++ ) {
+            in[i] = input[i]<0 ? input[i]+256: input[i];
+        }
+        byte[] out = new byte[8];
+        out[0] = (byte)in[off+0];
+        out[1] = (byte)(((in[off+0] << 7) & 0xFF) | (in[off+1] >> 1));
+        out[2] = (byte)(((in[off+1] << 6) & 0xFF) | (in[off+2] >> 2));
+        out[3] = (byte)(((in[off+2] << 5) & 0xFF) | (in[off+3] >> 3));
+        out[4] = (byte)(((in[off+3] << 4) & 0xFF) | (in[off+4] >> 4));
+        out[5] = (byte)(((in[off+4] << 3) & 0xFF) | (in[off+5] >> 5));
+        out[6] = (byte)(((in[off+5] << 2) & 0xFF) | (in[off+6] >> 6));
+        out[7] = (byte)((in[off+6] << 1) & 0xFF);
+        return out;
+    }
+
+    private byte[] calcLMHash () throws GeneralSecurityException {
+        byte[] magic = {0x4b, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25};
+        byte[] pwb = password.toUpperCase ().getBytes();
+        byte[] pwb1 = new byte [14];
+        int len = password.length();
+        if (len > 14)
+            len = 14;
+        System.arraycopy (pwb, 0, pwb1, 0, len); /* Zero padded */
+
+        DESKeySpec dks1 = new DESKeySpec (makeDesKey (pwb1, 0));
+        DESKeySpec dks2 = new DESKeySpec (makeDesKey (pwb1, 7));
+
+        SecretKey key1 = fac.generateSecret (dks1);
+        SecretKey key2 = fac.generateSecret (dks2);
+        cipher.init (Cipher.ENCRYPT_MODE, key1);
+        byte[] out1 = cipher.doFinal (magic, 0, 8);
+        cipher.init (Cipher.ENCRYPT_MODE, key2);
+        byte[] out2 = cipher.doFinal (magic, 0, 8);
+
+        byte[] result = new byte [21];
+        System.arraycopy (out1, 0, result, 0, 8);
+        System.arraycopy (out2, 0, result, 8, 8);
+        return result;
+    }
+
+    private byte[] calcNTHash () throws GeneralSecurityException {
+        byte[] pw = null;
+        try {
+            pw = password.getBytes ("UnicodeLittleUnmarked");
+        } catch (UnsupportedEncodingException e) {
+            assert false;
+        }
+        byte[] out = md4.digest (pw);
+        byte[] result = new byte [21];
+        System.arraycopy (out, 0, result, 0, 16);
+        return result;
+    }
+
+    /* key is a 21 byte array. Split it into 3 7 byte chunks,
+     * Convert each to 8 byte DES keys, encrypt the text arg with
+     * each key and return the three results in a sequential []
+     */
+    private byte[] calcResponse (byte[] key, byte[] text)
+    throws GeneralSecurityException {
+        assert key.length == 21;
+        DESKeySpec dks1 = new DESKeySpec (makeDesKey (key, 0));
+        DESKeySpec dks2 = new DESKeySpec (makeDesKey (key, 7));
+        DESKeySpec dks3 = new DESKeySpec (makeDesKey (key, 14));
+        SecretKey key1 = fac.generateSecret (dks1);
+        SecretKey key2 = fac.generateSecret (dks2);
+        SecretKey key3 = fac.generateSecret (dks3);
+        cipher.init (Cipher.ENCRYPT_MODE, key1);
+        byte[] out1 = cipher.doFinal (text, 0, 8);
+        cipher.init (Cipher.ENCRYPT_MODE, key2);
+        byte[] out2 = cipher.doFinal (text, 0, 8);
+        cipher.init (Cipher.ENCRYPT_MODE, key3);
+        byte[] out3 = cipher.doFinal (text, 0, 8);
+        byte[] result = new byte [24];
+        System.arraycopy (out1, 0, result, 0, 8);
+        System.arraycopy (out2, 0, result, 8, 8);
+        System.arraycopy (out3, 0, result, 16, 8);
+        return result;
+    }
+
+    private String buildType3Msg (String challenge) throws GeneralSecurityException,
+                                                           IOException  {
+        /* First decode the type2 message to get the server nonce */
+        /* nonce is located at type2[24] for 8 bytes */
+
+        byte[] type2 = (new sun.misc.BASE64Decoder()).decodeBuffer (challenge);
+        byte[] nonce = new byte [8];
+        System.arraycopy (type2, 24, nonce, 0, 8);
+
+        int ulen = username.length()*2;
+        type3[36] = type3[38] = (byte) (ulen % 256);
+        type3[37] = type3[39] = (byte) (ulen / 256);
+        int dlen = ntdomain.length()*2;
+        type3[28] = type3[30] = (byte) (dlen % 256);
+        type3[29] = type3[31] = (byte) (dlen / 256);
+        int hlen = hostname.length()*2;
+        type3[44] = type3[46] = (byte) (hlen % 256);
+        type3[45] = type3[47] = (byte) (hlen / 256);
+
+        int l = 64;
+        copybytes (type3, l, ntdomain, "UnicodeLittleUnmarked");
+        type3[32] = (byte) (l % 256);
+        type3[33] = (byte) (l / 256);
+        l += dlen;
+        copybytes (type3, l, username, "UnicodeLittleUnmarked");
+        type3[40] = (byte) (l % 256);
+        type3[41] = (byte) (l / 256);
+        l += ulen;
+        copybytes (type3, l, hostname, "UnicodeLittleUnmarked");
+        type3[48] = (byte) (l % 256);
+        type3[49] = (byte) (l / 256);
+        l += hlen;
+
+        byte[] lmhash = calcLMHash();
+        byte[] lmresponse = calcResponse (lmhash, nonce);
+        byte[] nthash = calcNTHash();
+        byte[] ntresponse = calcResponse (nthash, nonce);
+        System.arraycopy (lmresponse, 0, type3, l, 24);
+        type3[16] = (byte) (l % 256);
+        type3[17] = (byte) (l / 256);
+        l += 24;
+        System.arraycopy (ntresponse, 0, type3, l, 24);
+        type3[24] = (byte) (l % 256);
+        type3[25] = (byte) (l / 256);
+        l += 24;
+        type3[56] = (byte) (l % 256);
+        type3[57] = (byte) (l / 256);
+
+        byte[] msg = new byte [l];
+        System.arraycopy (type3, 0, msg, 0, l);
+        String result = "NTLM " + (new B64Encoder()).encode (msg);
+        return result;
+    }
+
+}
+
+
+class B64Encoder extends sun.misc.BASE64Encoder {
+    /* to force it to to the entire encoding in one line */
+    protected int bytesPerLine () {
+        return 1024;
+    }
+}
--- a/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/classes/sun/nio/ch/EPollArrayWrapper.java	Wed Nov 25 11:08:25 2009 -0800
@@ -28,6 +28,7 @@
 import java.io.IOException;
 import java.util.LinkedList;
 import java.util.HashSet;
+import java.util.Iterator;
 
 /**
  * Manipulates a native array of epoll_event structs on Linux:
@@ -200,12 +201,9 @@
     void release(SelChImpl channel) {
         synchronized (updateList) {
             // flush any pending updates
-            int i = 0;
-            while (i < updateList.size()) {
-                if (updateList.get(i).channel == channel) {
-                    updateList.remove(i);
-                } else {
-                    i++;
+            for (Iterator<Updator> it = updateList.iterator(); it.hasNext();) {
+                if (it.next().channel == channel) {
+                    it.remove();
                 }
             }
 
--- a/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.c	Wed Nov 25 11:08:25 2009 -0800
@@ -1654,6 +1654,7 @@
 #ifndef HEADLESS
 
 #define BIT_DEPTH_MULTI java_awt_DisplayMode_BIT_DEPTH_MULTI
+#define REFRESH_RATE_UNKNOWN java_awt_DisplayMode_REFRESH_RATE_UNKNOWN
 
 typedef Status
     (*XRRQueryVersionType) (Display *dpy, int *major_versionp, int *minor_versionp);
@@ -1680,6 +1681,9 @@
                                      Rotation rotation,
                                      short rate,
                                      Time timestamp);
+typedef Rotation
+    (*XRRConfigRotationsType)(XRRScreenConfiguration *config,
+                              Rotation *current_rotation);
 
 static XRRQueryVersionType               awt_XRRQueryVersion;
 static XRRGetScreenInfoType              awt_XRRGetScreenInfo;
@@ -1689,6 +1693,7 @@
 static XRRConfigSizesType                awt_XRRConfigSizes;
 static XRRConfigCurrentConfigurationType awt_XRRConfigCurrentConfiguration;
 static XRRSetScreenConfigAndRateType     awt_XRRSetScreenConfigAndRate;
+static XRRConfigRotationsType            awt_XRRConfigRotations;
 
 #define LOAD_XRANDR_FUNC(f) \
     do { \
@@ -1755,6 +1760,7 @@
     LOAD_XRANDR_FUNC(XRRConfigSizes);
     LOAD_XRANDR_FUNC(XRRConfigCurrentConfiguration);
     LOAD_XRANDR_FUNC(XRRSetScreenConfigAndRate);
+    LOAD_XRANDR_FUNC(XRRConfigRotations);
 
     return JNI_TRUE;
 }
@@ -1765,6 +1771,7 @@
 {
     jclass displayModeClass;
     jmethodID cid;
+    jint validRefreshRate = refreshRate;
 
     displayModeClass = (*env)->FindClass(env, "java/awt/DisplayMode");
     if (JNU_IsNull(env, displayModeClass)) {
@@ -1780,8 +1787,13 @@
         return NULL;
     }
 
+    // early versions of xrandr may report "empty" rates (6880694)
+    if (validRefreshRate <= 0) {
+        validRefreshRate = REFRESH_RATE_UNKNOWN;
+    }
+
     return (*env)->NewObject(env, displayModeClass, cid,
-                             width, height, bitDepth, refreshRate);
+                             width, height, bitDepth, validRefreshRate);
 }
 
 static void
@@ -1926,8 +1938,7 @@
         curRate = awt_XRRConfigCurrentRate(config);
 
         if ((sizes != NULL) &&
-            (curSizeIndex < nsizes) &&
-            (curRate > 0))
+            (curSizeIndex < nsizes))
         {
             XRRScreenSize curSize = sizes[curSizeIndex];
             displayMode = X11GD_CreateDisplayMode(env,
@@ -2004,6 +2015,7 @@
     jboolean success = JNI_FALSE;
     XRRScreenConfiguration *config;
     Drawable root;
+    Rotation currentRotation = RR_Rotate_0;
 
     AWT_LOCK();
 
@@ -2015,6 +2027,7 @@
         short chosenRate = -1;
         int nsizes;
         XRRScreenSize *sizes = awt_XRRConfigSizes(config, &nsizes);
+        awt_XRRConfigRotations(config, &currentRotation);
 
         if (sizes != NULL) {
             int i, j;
@@ -2048,7 +2061,7 @@
             Status status =
                 awt_XRRSetScreenConfigAndRate(awt_display, config, root,
                                               chosenSizeIndex,
-                                              RR_Rotate_0,
+                                              currentRotation,
                                               chosenRate,
                                               CurrentTime);
 
--- a/src/solaris/native/sun/awt/awt_GraphicsEnv.h	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/native/sun/awt/awt_GraphicsEnv.h	Wed Nov 25 11:08:25 2009 -0800
@@ -42,6 +42,10 @@
 #include <sys/ipc.h>
 #include <sys/shm.h>
 #include <X11/extensions/XShm.h>
+#ifndef X_ShmAttach
+#include <X11/Xmd.h>
+#include <X11/extensions/shmproto.h>
+#endif
 
 extern int XShmQueryExtension();
 
--- a/src/solaris/native/sun/awt/gtk2_interface.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/native/sun/awt/gtk2_interface.c	Wed Nov 25 11:08:25 2009 -0800
@@ -637,13 +637,13 @@
     if (gtk_modules_env && strstr (gtk_modules_env, "atk-bridge") ||
         gtk_modules_env && strstr (gtk_modules_env, "gail"))
     {
-        gchar *tmp_env = strdup (gtk_modules_env);
         /* the new env will be smaller than the old one */
         gchar *s, *new_env = malloc (sizeof(ENV_PREFIX)+strlen (gtk_modules_env));
 
         if (new_env != NULL )
         {
             /* careful, strtok modifies its args */
+            gchar *tmp_env = strdup (gtk_modules_env);
             strcpy(new_env, ENV_PREFIX);
 
             /* strip out 'atk-bridge' and 'gail' */
--- a/src/solaris/native/sun/xawt/XToolkit.c	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/solaris/native/sun/xawt/XToolkit.c	Wed Nov 25 11:08:25 2009 -0800
@@ -677,7 +677,7 @@
     jstring ret = NULL;
 
     keystr = JNU_GetStringPlatformChars(env, key, NULL);
-    if (key) {
+    if (keystr) {
         ptr = getenv(keystr);
         if (ptr) {
             ret = JNU_NewStringPlatform(env, (const char *) ptr);
--- a/src/windows/classes/sun/awt/Win32GraphicsDevice.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/classes/sun/awt/Win32GraphicsDevice.java	Wed Nov 25 11:08:25 2009 -0800
@@ -165,7 +165,7 @@
                 if (defaultConfig != null) {
                     configs = new GraphicsConfiguration[1];
                     configs[0] = defaultConfig;
-                    return configs;
+                    return configs.clone();
                 }
             }
 
@@ -196,7 +196,7 @@
             configs = new GraphicsConfiguration[v.size()];
             v.copyInto(configs);
         }
-        return configs;
+        return configs.clone();
     }
 
     /**
@@ -353,6 +353,7 @@
             }
             WWindowPeer peer = (WWindowPeer)old.getPeer();
             if (peer != null) {
+                peer.setFullScreenExclusiveModeState(false);
                 // we used to destroy the buffers on exiting fs mode, this
                 // is no longer needed since fs change will cause a surface
                 // data replacement
@@ -370,12 +371,15 @@
             addFSWindowListener(w);
             // Enter full screen exclusive mode.
             WWindowPeer peer = (WWindowPeer)w.getPeer();
-            synchronized(peer) {
-                enterFullScreenExclusive(screen, peer);
-                // Note: removed replaceSurfaceData() call because
-                // changing the window size or making it visible
-                // will cause this anyway, and both of these events happen
-                // as part of switching into fullscreen mode.
+            if (peer != null) {
+                synchronized(peer) {
+                    enterFullScreenExclusive(screen, peer);
+                    // Note: removed replaceSurfaceData() call because
+                    // changing the window size or making it visible
+                    // will cause this anyway, and both of these events happen
+                    // as part of switching into fullscreen mode.
+                }
+                peer.setFullScreenExclusiveModeState(true);
             }
 
             // fix for 4868278
--- a/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/classes/sun/awt/shell/Win32ShellFolder2.java	Wed Nov 25 11:08:25 2009 -0800
@@ -524,7 +524,7 @@
     // NOTE: this method uses COM and must be called on the 'COM thread'. See ComInvoker for the details
     private static native int compareIDs(long pParentIShellFolder, long pidl1, long pidl2);
 
-    private Boolean cachedIsFileSystem;
+    private volatile Boolean cachedIsFileSystem;
 
     /**
      * @return Whether this is a file system shell folder
@@ -693,29 +693,32 @@
                     ArrayList<Win32ShellFolder2> list = new ArrayList<Win32ShellFolder2>();
                     long pEnumObjects = getEnumObjects(includeHiddenFiles);
                     if (pEnumObjects != 0) {
-                        long childPIDL;
-                        int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
-                        do {
-                            childPIDL = getNextChild(pEnumObjects);
-                            boolean releasePIDL = true;
-                            if (childPIDL != 0 &&
-                                    (getAttributes0(pIShellFolder, childPIDL, testedAttrs) & testedAttrs) != 0) {
-                                Win32ShellFolder2 childFolder;
-                                if (Win32ShellFolder2.this.equals(desktop)
-                                        && personal != null
-                                        && pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) {
-                                    childFolder = personal;
-                                } else {
-                                    childFolder = new Win32ShellFolder2(Win32ShellFolder2.this, childPIDL);
-                                    releasePIDL = false;
+                        try {
+                            long childPIDL;
+                            int testedAttrs = ATTRIB_FILESYSTEM | ATTRIB_FILESYSANCESTOR;
+                            do {
+                                childPIDL = getNextChild(pEnumObjects);
+                                boolean releasePIDL = true;
+                                if (childPIDL != 0 &&
+                                        (getAttributes0(pIShellFolder, childPIDL, testedAttrs) & testedAttrs) != 0) {
+                                    Win32ShellFolder2 childFolder;
+                                    if (Win32ShellFolder2.this.equals(desktop)
+                                            && personal != null
+                                            && pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) {
+                                        childFolder = personal;
+                                    } else {
+                                        childFolder = new Win32ShellFolder2(Win32ShellFolder2.this, childPIDL);
+                                        releasePIDL = false;
+                                    }
+                                    list.add(childFolder);
                                 }
-                                list.add(childFolder);
-                            }
-                            if (releasePIDL) {
-                                releasePIDL(childPIDL);
-                            }
-                        } while (childPIDL != 0 && !Thread.currentThread().isInterrupted());
-                        releaseEnumObjects(pEnumObjects);
+                                if (releasePIDL) {
+                                    releasePIDL(childPIDL);
+                                }
+                            } while (childPIDL != 0 && !Thread.currentThread().isInterrupted());
+                        } finally {
+                            releaseEnumObjects(pEnumObjects);
+                        }
                     }
                     return Thread.currentThread().isInterrupted()
                         ? new File[0]
@@ -759,7 +762,7 @@
         }, InterruptedException.class);
     }
 
-    private Boolean cachedIsLink;
+    private volatile Boolean cachedIsLink;
 
     /**
      * @return Whether this shell folder is a link
--- a/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java	Wed Nov 25 11:08:25 2009 -0800
@@ -79,9 +79,12 @@
             // Shouldn't happen but watch for it anyway
             throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found");
         }
-        Win32ShellFolder2 folder = createShellFolderFromRelativePIDL(parent, pIDL);
-        Win32ShellFolder2.releasePIDL(pIDL);
-        return folder;
+
+        try {
+            return createShellFolderFromRelativePIDL(parent, pIDL);
+        } finally {
+            Win32ShellFolder2.releasePIDL(pIDL);
+        }
     }
 
     static Win32ShellFolder2 createShellFolderFromRelativePIDL(Win32ShellFolder2 parent, long pIDL)
@@ -269,7 +272,7 @@
                 Arrays.sort(secondLevelFolders);
                 for (File secondLevelFolder : secondLevelFolders) {
                     Win32ShellFolder2 folder = (Win32ShellFolder2) secondLevelFolder;
-                    if (!folder.isFileSystem() || folder.isDirectory()) {
+                    if (!folder.isFileSystem() || (folder.isDirectory() && !folder.isLink())) {
                         folders.add(folder);
                         // Add third level for "My Computer"
                         if (folder.equals(drives)) {
--- a/src/windows/classes/sun/awt/windows/WComponentPeer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/classes/sun/awt/windows/WComponentPeer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -550,8 +550,34 @@
     final static Font defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
 
     public Graphics getGraphics() {
+        if (isDisposed()) {
+            return null;
+        }
+
+        Component target = (Component)getTarget();
+        Window window = SunToolkit.getContainingWindow(target);
+        if (window != null && !window.isOpaque()) {
+            // Non-opaque windows do not support heavyweight children.
+            // Redirect all painting to the Window's Graphics instead.
+            // The caller is responsible for calling the
+            // WindowPeer.updateWindow() after painting has finished.
+            int x = 0, y = 0;
+            for (Component c = target; c != window; c = c.getParent()) {
+                x += c.getX();
+                y += c.getY();
+            }
+
+            Graphics g =
+                ((WWindowPeer)window.getPeer()).getTranslucentGraphics();
+
+            g.translate(x, y);
+            g.clipRect(0, 0, target.getWidth(), target.getHeight());
+
+            return g;
+        }
+
         SurfaceData surfaceData = this.surfaceData;
-        if (!isDisposed() && surfaceData != null) {
+        if (surfaceData != null) {
             /* Fix for bug 4746122. Color and Font shouldn't be null */
             Color bgColor = background;
             if (bgColor == null) {
--- a/src/windows/classes/sun/awt/windows/WWindowPeer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/classes/sun/awt/windows/WWindowPeer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -510,6 +510,9 @@
 
     private native int getScreenImOn();
 
+    // Used in Win32GraphicsDevice.
+    public final native void setFullScreenExclusiveModeState(boolean state);
+
 /*
  * ----END DISPLAY CHANGE SUPPORT----
  */
@@ -575,11 +578,17 @@
         }
     }
 
+    public final Graphics getTranslucentGraphics() {
+        synchronized (getStateLock()) {
+            return isOpaque ? null : painter.getBackBuffer(false).getGraphics();
+        }
+    }
+
     @Override
     public Graphics getGraphics() {
         synchronized (getStateLock()) {
             if (!isOpaque) {
-                return painter.getBackBuffer(false).getGraphics();
+                return getTranslucentGraphics();
             }
         }
         return super.getGraphics();
--- a/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java	Wed Nov 25 11:08:25 2009 -0800
@@ -429,7 +429,7 @@
                 if (defaultConfig != null) {
                     configs = new GraphicsConfiguration[1];
                     configs[0] = defaultConfig;
-                    return configs;
+                    return configs.clone();
                 }
             }
         }
--- a/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/classes/sun/java2d/windows/GDIWindowSurfaceData.java	Wed Nov 25 11:08:25 2009 -0800
@@ -210,7 +210,10 @@
             // if a GlyphVector overrides the AA setting.
             // We use getRenderLoops() rather than setting solidloops
             // directly so that we get the appropriate loops in XOR mode.
-            sg2d.loops = getRenderLoops(sg2d);
+            if (sg2d.loops == null) {
+                // assert(some pipe will always be a LoopBasedPipe)
+                sg2d.loops = getRenderLoops(sg2d);
+            }
         } else {
             super.validatePipe(sg2d);
         }
--- a/src/windows/classes/sun/net/www/protocol/http/NTLMAuthSequence.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.net.www.protocol.http;
-
-import java.io.IOException;
-import sun.misc.BASE64Encoder;
-import sun.misc.BASE64Decoder;
-
-/*
- * Hooks into Windows implementation of NTLM.
- * This class will be replaced if a cross-platform version of NTLM
- * is implemented in the future.
- */
-
-public class NTLMAuthSequence {
-
-    private String username;
-    private String password;
-    private String ntdomain;
-    private int state;
-    private long crdHandle;
-    private long ctxHandle;
-
-    static {
-        initFirst();
-    }
-
-    NTLMAuthSequence (String username, String password, String ntdomain)
-    throws IOException
-    {
-        this.username = username;
-        this.password = password;
-        this.ntdomain = ntdomain;
-        state = 0;
-        crdHandle = getCredentialsHandle (username, ntdomain, password);
-        if (crdHandle == 0) {
-            throw new IOException ("could not get credentials handle");
-        }
-    }
-
-    public String getAuthHeader (String token) throws IOException {
-        byte[] input = null;
-        if (token != null)
-            input = (new BASE64Decoder()).decodeBuffer(token);
-        byte[] b = getNextToken (crdHandle, input);
-        if (b == null)
-            throw new IOException ("Internal authentication error");
-        return (new B64Encoder()).encode (b);
-    }
-
-    private native static void initFirst ();
-
-    private native long getCredentialsHandle (String user, String domain, String password);
-
-    private native byte[] getNextToken (long crdHandle, byte[] lastToken);
-}
-
-class B64Encoder extends BASE64Encoder {
-    protected int bytesPerLine () {
-        return 1024;
-    }
-}
--- a/src/windows/classes/sun/net/www/protocol/http/NTLMAuthentication.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,195 +0,0 @@
-/*
- * Copyright 2002-2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.net.www.protocol.http;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.PasswordAuthentication;
-import java.net.UnknownHostException;
-import java.net.URL;
-import sun.net.www.HeaderParser;
-
-/**
- * NTLMAuthentication:
- *
- * @author Michael McMahon
- */
-
-class NTLMAuthentication extends AuthenticationInfo {
-
-    private static final long serialVersionUID = 100L;
-
-    private String hostname;
-    private static String defaultDomain; /* Domain to use if not specified by user */
-
-    static {
-        defaultDomain = java.security.AccessController.doPrivileged(
-            new sun.security.action.GetPropertyAction("http.auth.ntlm.domain",
-                                                      "domain"));
-    };
-
-    private void init0() {
-
-        hostname = java.security.AccessController.doPrivileged(
-            new java.security.PrivilegedAction<String>() {
-            public String run() {
-                String localhost;
-                try {
-                    localhost = InetAddress.getLocalHost().getHostName().toUpperCase();
-                } catch (UnknownHostException e) {
-                     localhost = "localhost";
-                }
-                return localhost;
-            }
-        });
-        int x = hostname.indexOf ('.');
-        if (x != -1) {
-            hostname = hostname.substring (0, x);
-        }
-    }
-
-    String username;
-    String ntdomain;
-    String password;
-
-    /**
-     * Create a NTLMAuthentication:
-     * Username may be specified as domain<BACKSLASH>username in the application Authenticator.
-     * If this notation is not used, then the domain will be taken
-     * from a system property: "http.auth.ntlm.domain".
-     */
-    public NTLMAuthentication(boolean isProxy, URL url, PasswordAuthentication pw) {
-        super(isProxy ? PROXY_AUTHENTICATION : SERVER_AUTHENTICATION,
-              AuthScheme.NTLM,
-              url,
-              "");
-        init (pw);
-    }
-
-    private void init (PasswordAuthentication pw) {
-        this.pw = pw;
-        if (pw != null) {
-            String s = pw.getUserName();
-            int i = s.indexOf ('\\');
-            if (i == -1) {
-                username = s;
-                ntdomain = defaultDomain;
-            } else {
-                ntdomain = s.substring (0, i).toUpperCase();
-                username = s.substring (i+1);
-            }
-            password = new String (pw.getPassword());
-        } else {
-            /* credentials will be acquired from OS */
-            username = null;
-            ntdomain = null;
-            password = null;
-        }
-        init0();
-    }
-
-   /**
-    * Constructor used for proxy entries
-    */
-    public NTLMAuthentication(boolean isProxy, String host, int port,
-                                PasswordAuthentication pw) {
-        super(isProxy?PROXY_AUTHENTICATION:SERVER_AUTHENTICATION,
-              AuthScheme.NTLM,
-              host,
-              port,
-              "");
-        init (pw);
-    }
-
-    /**
-     * @return true if this authentication supports preemptive authorization
-     */
-    boolean supportsPreemptiveAuthorization() {
-        return false;
-    }
-
-    /**
-     * @return true if NTLM supported transparently (no password needed, SSO)
-     */
-    static boolean supportsTransparentAuth() {
-        return true;
-    }
-
-    /**
-     * @return the name of the HTTP header this authentication wants set
-     */
-    String getHeaderName() {
-        if (type == SERVER_AUTHENTICATION) {
-            return "Authorization";
-        } else {
-            return "Proxy-authorization";
-        }
-    }
-
-    /**
-     * Not supported. Must use the setHeaders() method
-     */
-    String getHeaderValue(URL url, String method) {
-        throw new RuntimeException ("getHeaderValue not supported");
-    }
-
-    /**
-     * Check if the header indicates that the current auth. parameters are stale.
-     * If so, then replace the relevant field with the new value
-     * and return true. Otherwise return false.
-     * returning true means the request can be retried with the same userid/password
-     * returning false means we have to go back to the user to ask for a new
-     * username password.
-     */
-    boolean isAuthorizationStale (String header) {
-        return false; /* should not be called for ntlm */
-    }
-
-    /**
-     * Set header(s) on the given connection.
-     * @param conn The connection to apply the header(s) to
-     * @param p A source of header values for this connection, not used because
-     *          HeaderParser converts the fields to lower case, use raw instead
-     * @param raw The raw header field.
-     * @return true if all goes well, false if no headers were set.
-     */
-    synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
-
-        try {
-            NTLMAuthSequence seq = (NTLMAuthSequence)conn.authObj;
-            if (seq == null) {
-                seq = new NTLMAuthSequence (username, password, ntdomain);
-                conn.authObj = seq;
-            }
-            String response = "NTLM " + seq.getAuthHeader (raw.length()>6?raw.substring(5):null);
-            conn.setAuthenticationProperty(getHeaderName(), response);
-            return true;
-        } catch (IOException e) {
-            return false;
-        }
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.net.www.protocol.http.ntlm;
+
+import java.io.IOException;
+import sun.misc.BASE64Encoder;
+import sun.misc.BASE64Decoder;
+
+/*
+ * Hooks into Windows implementation of NTLM.
+ * This class will be replaced if a cross-platform version of NTLM
+ * is implemented in the future.
+ */
+
+public class NTLMAuthSequence {
+
+    private String username;
+    private String password;
+    private String ntdomain;
+    private int state;
+    private long crdHandle;
+    private long ctxHandle;
+
+    static {
+        initFirst();
+    }
+
+    NTLMAuthSequence (String username, String password, String ntdomain)
+    throws IOException
+    {
+        this.username = username;
+        this.password = password;
+        this.ntdomain = ntdomain;
+        state = 0;
+        crdHandle = getCredentialsHandle (username, ntdomain, password);
+        if (crdHandle == 0) {
+            throw new IOException ("could not get credentials handle");
+        }
+    }
+
+    public String getAuthHeader (String token) throws IOException {
+        byte[] input = null;
+        if (token != null)
+            input = (new BASE64Decoder()).decodeBuffer(token);
+        byte[] b = getNextToken (crdHandle, input);
+        if (b == null)
+            throw new IOException ("Internal authentication error");
+        return (new B64Encoder()).encode (b);
+    }
+
+    private native static void initFirst ();
+
+    private native long getCredentialsHandle (String user, String domain, String password);
+
+    private native byte[] getNextToken (long crdHandle, byte[] lastToken);
+}
+
+class B64Encoder extends BASE64Encoder {
+    protected int bytesPerLine () {
+        return 1024;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthentication.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2002-2005 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.net.www.protocol.http.ntlm;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.PasswordAuthentication;
+import java.net.UnknownHostException;
+import java.net.URL;
+import sun.net.www.HeaderParser;
+import sun.net.www.protocol.http.AuthenticationInfo;
+import sun.net.www.protocol.http.AuthScheme;
+import sun.net.www.protocol.http.HttpURLConnection;
+
+/**
+ * NTLMAuthentication:
+ *
+ * @author Michael McMahon
+ */
+
+public class NTLMAuthentication extends AuthenticationInfo {
+
+    private static final long serialVersionUID = 100L;
+
+    private String hostname;
+    private static String defaultDomain; /* Domain to use if not specified by user */
+
+    static {
+        defaultDomain = java.security.AccessController.doPrivileged(
+            new sun.security.action.GetPropertyAction("http.auth.ntlm.domain",
+                                                      "domain"));
+    };
+
+    private void init0() {
+
+        hostname = java.security.AccessController.doPrivileged(
+            new java.security.PrivilegedAction<String>() {
+            public String run() {
+                String localhost;
+                try {
+                    localhost = InetAddress.getLocalHost().getHostName().toUpperCase();
+                } catch (UnknownHostException e) {
+                     localhost = "localhost";
+                }
+                return localhost;
+            }
+        });
+        int x = hostname.indexOf ('.');
+        if (x != -1) {
+            hostname = hostname.substring (0, x);
+        }
+    }
+
+    String username;
+    String ntdomain;
+    String password;
+
+    /**
+     * Create a NTLMAuthentication:
+     * Username may be specified as domain<BACKSLASH>username in the application Authenticator.
+     * If this notation is not used, then the domain will be taken
+     * from a system property: "http.auth.ntlm.domain".
+     */
+    public NTLMAuthentication(boolean isProxy, URL url, PasswordAuthentication pw) {
+        super(isProxy ? PROXY_AUTHENTICATION : SERVER_AUTHENTICATION,
+              AuthScheme.NTLM,
+              url,
+              "");
+        init (pw);
+    }
+
+    private void init (PasswordAuthentication pw) {
+        this.pw = pw;
+        if (pw != null) {
+            String s = pw.getUserName();
+            int i = s.indexOf ('\\');
+            if (i == -1) {
+                username = s;
+                ntdomain = defaultDomain;
+            } else {
+                ntdomain = s.substring (0, i).toUpperCase();
+                username = s.substring (i+1);
+            }
+            password = new String (pw.getPassword());
+        } else {
+            /* credentials will be acquired from OS */
+            username = null;
+            ntdomain = null;
+            password = null;
+        }
+        init0();
+    }
+
+   /**
+    * Constructor used for proxy entries
+    */
+    public NTLMAuthentication(boolean isProxy, String host, int port,
+                                PasswordAuthentication pw) {
+        super(isProxy?PROXY_AUTHENTICATION:SERVER_AUTHENTICATION,
+              AuthScheme.NTLM,
+              host,
+              port,
+              "");
+        init (pw);
+    }
+
+    /**
+     * @return true if this authentication supports preemptive authorization
+     */
+    @Override
+    public boolean supportsPreemptiveAuthorization() {
+        return false;
+    }
+
+    /**
+     * @return true if NTLM supported transparently (no password needed, SSO)
+     */
+    public static boolean supportsTransparentAuth() {
+        return true;
+    }
+
+    /**
+     * Not supported. Must use the setHeaders() method
+     */
+    @Override
+    public String getHeaderValue(URL url, String method) {
+        throw new RuntimeException ("getHeaderValue not supported");
+    }
+
+    /**
+     * Check if the header indicates that the current auth. parameters are stale.
+     * If so, then replace the relevant field with the new value
+     * and return true. Otherwise return false.
+     * returning true means the request can be retried with the same userid/password
+     * returning false means we have to go back to the user to ask for a new
+     * username password.
+     */
+    @Override
+    public boolean isAuthorizationStale (String header) {
+        return false; /* should not be called for ntlm */
+    }
+
+    /**
+     * Set header(s) on the given connection.
+     * @param conn The connection to apply the header(s) to
+     * @param p A source of header values for this connection, not used because
+     *          HeaderParser converts the fields to lower case, use raw instead
+     * @param raw The raw header field.
+     * @return true if all goes well, false if no headers were set.
+     */
+    @Override
+    public synchronized boolean setHeaders(HttpURLConnection conn, HeaderParser p, String raw) {
+
+        try {
+            NTLMAuthSequence seq = (NTLMAuthSequence)conn.authObj();
+            if (seq == null) {
+                seq = new NTLMAuthSequence (username, password, ntdomain);
+                conn.authObj(seq);
+            }
+            String response = "NTLM " + seq.getAuthHeader (raw.length()>6?raw.substring(5):null);
+            conn.setAuthenticationProperty(getHeaderName(), response);
+            return true;
+        } catch (IOException e) {
+            return false;
+        }
+    }
+
+}
--- a/src/windows/native/sun/net/www/protocol/http/NTLMAuthSequence.c	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-/*
- * Copyright 2002-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.
- */
-
-#include <jni.h>
-#include <windows.h>
-#include <rpc.h>
-#include <winsock.h>
-#include <lm.h>
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <string.h>
-#include <tchar.h>
-#include <fcntl.h>
-
-#include "jni_util.h"
-
-#define SECURITY_WIN32
-#include "sspi.h"
-
-
-/*
- * OS calls loaded from DLL on intialization
- */
-
-static FREE_CREDENTIALS_HANDLE_FN pFreeCredentialsHandle;
-static ACQUIRE_CREDENTIALS_HANDLE_FN pAcquireCredentialsHandle;
-static FREE_CONTEXT_BUFFER_FN pFreeContextBuffer;
-static INITIALIZE_SECURITY_CONTEXT_FN pInitializeSecurityContext;
-static COMPLETE_AUTH_TOKEN_FN pCompleteAuthToken;
-static DELETE_SECURITY_CONTEXT_FN pDeleteSecurityContext;
-
-static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle);
-
-static jfieldID ntlm_ctxHandleID;
-static jfieldID ntlm_crdHandleID;
-
-static HINSTANCE lib = NULL;
-
-JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_initFirst
-(JNIEnv *env, jclass clazz)
-{
-    OSVERSIONINFO   version;
-    UCHAR libName[MAX_PATH];
-
-    ntlm_ctxHandleID = (*env)->GetFieldID(env, clazz, "ctxHandle", "J");
-    ntlm_crdHandleID = (*env)->GetFieldID(env, clazz, "crdHandle", "J");
-
-    version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
-    GetVersionEx (&version);
-
-    if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
-        strcpy (libName, "security.dll" );
-    }
-    else if (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
-        strcpy (libName, "secur32.dll" );
-    }
-
-    lib = LoadLibrary (libName);
-
-    pFreeCredentialsHandle
-        = (FREE_CREDENTIALS_HANDLE_FN) GetProcAddress(
-        lib, "FreeCredentialsHandle" );
-
-    pAcquireCredentialsHandle
-        = (ACQUIRE_CREDENTIALS_HANDLE_FN) GetProcAddress(
-        lib, "AcquireCredentialsHandleA" );
-
-    pFreeContextBuffer
-        = (FREE_CONTEXT_BUFFER_FN) GetProcAddress(
-        lib, "FreeContextBuffer" );
-
-    pInitializeSecurityContext
-        = (INITIALIZE_SECURITY_CONTEXT_FN) GetProcAddress(
-        lib, "InitializeSecurityContextA" );
-
-    pCompleteAuthToken
-        = (COMPLETE_AUTH_TOKEN_FN) GetProcAddress(
-        lib, "CompleteAuthToken" );
-
-    pDeleteSecurityContext
-        = (DELETE_SECURITY_CONTEXT_FN) GetProcAddress(
-        lib, "DeleteSecurityContext" );
-
-}
-
-/*
- * Class:     sun_net_www_protocol_http_NTLMAuthSequence
- * Method:    getCredentialsHandle
- * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J
- */
-
-JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_getCredentialsHandle
-(JNIEnv *env, jobject this, jstring user, jstring domain, jstring password)
-{
-    SEC_WINNT_AUTH_IDENTITY   AuthId;
-    SEC_WINNT_AUTH_IDENTITY * pAuthId;
-    const CHAR        *pUser = 0;
-    const CHAR        *pDomain = 0;
-    const CHAR        *pPassword = 0;
-    CredHandle      *pCred;
-    TimeStamp            ltime;
-    jboolean         isCopy;
-    SECURITY_STATUS      ss;
-
-    if (user != 0) {
-        pUser = JNU_GetStringPlatformChars(env, user, &isCopy);
-        if (pUser == NULL)
-            return 0;  // pending Exception
-    }
-    if (domain != 0) {
-        pDomain = JNU_GetStringPlatformChars(env, domain, &isCopy);
-        if (pDomain == NULL) {
-            if (pUser != NULL)
-                JNU_ReleaseStringPlatformChars(env, user, pUser);
-            return 0;  // pending Exception
-        }
-    }
-    if (password != 0) {
-        pPassword = JNU_GetStringPlatformChars(env, password, &isCopy);
-        if (pPassword == NULL) {
-            if(pUser != NULL)
-                JNU_ReleaseStringPlatformChars(env, user, pUser);
-            if(pDomain != NULL)
-                JNU_ReleaseStringPlatformChars(env, domain, pDomain);
-            return 0;  // pending Exception
-        }
-    }
-    pCred = (CredHandle *)malloc(sizeof (CredHandle));
-
-    if ( ((pUser != NULL) || (pPassword != NULL)) || (pDomain != NULL)) {
-        pAuthId = &AuthId;
-
-        memset( &AuthId, 0, sizeof( AuthId ));
-
-        if ( pUser != NULL ) {
-            AuthId.User       = (unsigned char *) pUser;
-            AuthId.UserLength = strlen( pUser );
-        }
-
-        if ( pPassword != NULL ) {
-            AuthId.Password       = (unsigned char *) pPassword;
-            AuthId.PasswordLength = strlen( pPassword );
-        }
-
-        if ( pDomain != NULL ) {
-            AuthId.Domain       = (unsigned char *) pDomain;
-            AuthId.DomainLength = strlen( pDomain );
-        }
-
-        AuthId.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
-    } else {
-        pAuthId = NULL;
-    }
-
-    ss = pAcquireCredentialsHandle(
-        NULL, "NTLM", SECPKG_CRED_OUTBOUND,
-        NULL, pAuthId, NULL, NULL,
-        pCred, &ltime
-        );
-
-    /* Release resources held by JNU_GetStringPlatformChars */
-    if (pUser != NULL)
-        JNU_ReleaseStringPlatformChars(env, user, pUser);
-    if (pPassword != NULL)
-        JNU_ReleaseStringPlatformChars(env, password, pPassword);
-    if (pDomain != NULL)
-        JNU_ReleaseStringPlatformChars(env, domain, pDomain);
-
-    if (ss == 0) {
-        return (jlong) pCred;
-    } else {
-        return 0;
-    }
-}
-
-JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_NTLMAuthSequence_getNextToken
-(JNIEnv *env, jobject this, jlong crdHandle, jbyteArray lastToken)
-{
-
-    VOID        *pInput = 0;
-    DWORD            inputLen;
-    CHAR         buffOut[512];
-    jboolean         isCopy;
-    SECURITY_STATUS      ss;
-    SecBufferDesc        OutBuffDesc;
-    SecBuffer            OutSecBuff;
-    SecBufferDesc        InBuffDesc;
-    SecBuffer            InSecBuff;
-    ULONG                ContextAttributes;
-    CredHandle      *pCred = (CredHandle *)crdHandle;
-    CtxtHandle      *pCtx;
-    CtxtHandle      *newContext;
-    TimeStamp            ltime;
-    jbyteArray       result;
-
-
-    pCtx = (CtxtHandle *) (*env)->GetLongField (env, this, ntlm_ctxHandleID);
-    if (pCtx == 0) { /* first call */
-        newContext = (CtxtHandle *)malloc(sizeof(CtxtHandle));
-        (*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext);
-    } else {
-        newContext = pCtx;
-    }
-
-    OutBuffDesc.ulVersion = 0;
-    OutBuffDesc.cBuffers  = 1;
-    OutBuffDesc.pBuffers  = &OutSecBuff;
-
-    OutSecBuff.cbBuffer   = 512;
-    OutSecBuff.BufferType = SECBUFFER_TOKEN;
-    OutSecBuff.pvBuffer   = buffOut;
-
-    /*
-     *  Prepare our Input buffer - Note the server is expecting the client's
-     *  negotiation packet on the first call
-     */
-
-    if (lastToken != 0)
-    {
-        pInput = (VOID *)(*env)->GetByteArrayElements(env, lastToken, &isCopy);
-        inputLen = (*env)->GetArrayLength(env, lastToken);
-
-        InBuffDesc.ulVersion = 0;
-        InBuffDesc.cBuffers  = 1;
-        InBuffDesc.pBuffers  = &InSecBuff;
-
-        InSecBuff.cbBuffer       = inputLen;
-        InSecBuff.BufferType = SECBUFFER_TOKEN;
-        InSecBuff.pvBuffer       = pInput;
-    }
-
-    /*
-     *  will return success when its done but we still
-     *  need to send the out buffer if there are bytes to send
-     */
-
-    ss = pInitializeSecurityContext(
-        pCred, pCtx, NULL, 0, 0, SECURITY_NATIVE_DREP,
-        lastToken ? &InBuffDesc : NULL, 0, newContext, &OutBuffDesc,
-        &ContextAttributes, &ltime
-    );
-
-    if (pInput != 0) {
-        (*env)->ReleaseByteArrayElements(env, lastToken, pInput, JNI_ABORT);
-    }
-
-    if (ss < 0) {
-        endSequence (pCred, pCtx);
-        return 0;
-    }
-
-    if ((ss == SEC_I_COMPLETE_NEEDED) || (ss == SEC_I_COMPLETE_AND_CONTINUE) ) {
-        ss = pCompleteAuthToken( pCtx, &OutBuffDesc );
-
-        if (ss < 0) {
-            endSequence (pCred, pCtx);
-            return 0;
-        }
-    }
-
-    if ( OutSecBuff.cbBuffer > 0 ) {
-        jbyteArray ret = (*env)->NewByteArray(env, OutSecBuff.cbBuffer);
-        (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
-                OutSecBuff.pvBuffer);
-        if (lastToken != 0) // 2nd stage
-            endSequence (pCred, pCtx);
-        result = ret;
-    }
-
-    if ((ss != SEC_I_CONTINUE_NEEDED) && (ss == SEC_I_COMPLETE_AND_CONTINUE)) {
-        endSequence (pCred, pCtx);
-    }
-
-    return result;
-}
-
-static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle) {
-    if (credHand != 0) {
-        pFreeCredentialsHandle (credHand);
-        free (credHand);
-    }
-
-    if (ctxHandle != 0) {
-        pDeleteSecurityContext(ctxHandle);
-        free (ctxHandle);
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/windows/native/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.c	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,311 @@
+/*
+ * Copyright 2002-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.
+ */
+
+#include <jni.h>
+#include <windows.h>
+#include <rpc.h>
+#include <winsock.h>
+#include <lm.h>
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <tchar.h>
+#include <fcntl.h>
+
+#include "jni_util.h"
+
+#define SECURITY_WIN32
+#include "sspi.h"
+
+
+/*
+ * OS calls loaded from DLL on intialization
+ */
+
+static FREE_CREDENTIALS_HANDLE_FN pFreeCredentialsHandle;
+static ACQUIRE_CREDENTIALS_HANDLE_FN pAcquireCredentialsHandle;
+static FREE_CONTEXT_BUFFER_FN pFreeContextBuffer;
+static INITIALIZE_SECURITY_CONTEXT_FN pInitializeSecurityContext;
+static COMPLETE_AUTH_TOKEN_FN pCompleteAuthToken;
+static DELETE_SECURITY_CONTEXT_FN pDeleteSecurityContext;
+
+static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle);
+
+static jfieldID ntlm_ctxHandleID;
+static jfieldID ntlm_crdHandleID;
+
+static HINSTANCE lib = NULL;
+
+JNIEXPORT void JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_initFirst
+(JNIEnv *env, jclass clazz)
+{
+    OSVERSIONINFO   version;
+    UCHAR libName[MAX_PATH];
+
+    ntlm_ctxHandleID = (*env)->GetFieldID(env, clazz, "ctxHandle", "J");
+    ntlm_crdHandleID = (*env)->GetFieldID(env, clazz, "crdHandle", "J");
+
+    version.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+    GetVersionEx (&version);
+
+    if (version.dwPlatformId == VER_PLATFORM_WIN32_NT) {
+        strcpy (libName, "security.dll" );
+    }
+    else if (version.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+        strcpy (libName, "secur32.dll" );
+    }
+
+    lib = LoadLibrary (libName);
+
+    pFreeCredentialsHandle
+        = (FREE_CREDENTIALS_HANDLE_FN) GetProcAddress(
+        lib, "FreeCredentialsHandle" );
+
+    pAcquireCredentialsHandle
+        = (ACQUIRE_CREDENTIALS_HANDLE_FN) GetProcAddress(
+        lib, "AcquireCredentialsHandleA" );
+
+    pFreeContextBuffer
+        = (FREE_CONTEXT_BUFFER_FN) GetProcAddress(
+        lib, "FreeContextBuffer" );
+
+    pInitializeSecurityContext
+        = (INITIALIZE_SECURITY_CONTEXT_FN) GetProcAddress(
+        lib, "InitializeSecurityContextA" );
+
+    pCompleteAuthToken
+        = (COMPLETE_AUTH_TOKEN_FN) GetProcAddress(
+        lib, "CompleteAuthToken" );
+
+    pDeleteSecurityContext
+        = (DELETE_SECURITY_CONTEXT_FN) GetProcAddress(
+        lib, "DeleteSecurityContext" );
+
+}
+
+/*
+ * Class:     sun_net_www_protocol_http_NTLMAuthSequence
+ * Method:    getCredentialsHandle
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)J
+ */
+
+JNIEXPORT jlong JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_getCredentialsHandle
+(JNIEnv *env, jobject this, jstring user, jstring domain, jstring password)
+{
+    SEC_WINNT_AUTH_IDENTITY   AuthId;
+    SEC_WINNT_AUTH_IDENTITY * pAuthId;
+    const CHAR        *pUser = 0;
+    const CHAR        *pDomain = 0;
+    const CHAR        *pPassword = 0;
+    CredHandle      *pCred;
+    TimeStamp            ltime;
+    jboolean         isCopy;
+    SECURITY_STATUS      ss;
+
+    if (user != 0) {
+        pUser = JNU_GetStringPlatformChars(env, user, &isCopy);
+        if (pUser == NULL)
+            return 0;  // pending Exception
+    }
+    if (domain != 0) {
+        pDomain = JNU_GetStringPlatformChars(env, domain, &isCopy);
+        if (pDomain == NULL) {
+            if (pUser != NULL)
+                JNU_ReleaseStringPlatformChars(env, user, pUser);
+            return 0;  // pending Exception
+        }
+    }
+    if (password != 0) {
+        pPassword = JNU_GetStringPlatformChars(env, password, &isCopy);
+        if (pPassword == NULL) {
+            if(pUser != NULL)
+                JNU_ReleaseStringPlatformChars(env, user, pUser);
+            if(pDomain != NULL)
+                JNU_ReleaseStringPlatformChars(env, domain, pDomain);
+            return 0;  // pending Exception
+        }
+    }
+    pCred = (CredHandle *)malloc(sizeof (CredHandle));
+
+    if ( ((pUser != NULL) || (pPassword != NULL)) || (pDomain != NULL)) {
+        pAuthId = &AuthId;
+
+        memset( &AuthId, 0, sizeof( AuthId ));
+
+        if ( pUser != NULL ) {
+            AuthId.User       = (unsigned char *) pUser;
+            AuthId.UserLength = strlen( pUser );
+        }
+
+        if ( pPassword != NULL ) {
+            AuthId.Password       = (unsigned char *) pPassword;
+            AuthId.PasswordLength = strlen( pPassword );
+        }
+
+        if ( pDomain != NULL ) {
+            AuthId.Domain       = (unsigned char *) pDomain;
+            AuthId.DomainLength = strlen( pDomain );
+        }
+
+        AuthId.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI;
+    } else {
+        pAuthId = NULL;
+    }
+
+    ss = pAcquireCredentialsHandle(
+        NULL, "NTLM", SECPKG_CRED_OUTBOUND,
+        NULL, pAuthId, NULL, NULL,
+        pCred, &ltime
+        );
+
+    /* Release resources held by JNU_GetStringPlatformChars */
+    if (pUser != NULL)
+        JNU_ReleaseStringPlatformChars(env, user, pUser);
+    if (pPassword != NULL)
+        JNU_ReleaseStringPlatformChars(env, password, pPassword);
+    if (pDomain != NULL)
+        JNU_ReleaseStringPlatformChars(env, domain, pDomain);
+
+    if (ss == 0) {
+        return (jlong) pCred;
+    } else {
+        return 0;
+    }
+}
+
+JNIEXPORT jbyteArray JNICALL Java_sun_net_www_protocol_http_ntlm_NTLMAuthSequence_getNextToken
+(JNIEnv *env, jobject this, jlong crdHandle, jbyteArray lastToken)
+{
+
+    VOID        *pInput = 0;
+    DWORD            inputLen;
+    CHAR         buffOut[512];
+    jboolean         isCopy;
+    SECURITY_STATUS      ss;
+    SecBufferDesc        OutBuffDesc;
+    SecBuffer            OutSecBuff;
+    SecBufferDesc        InBuffDesc;
+    SecBuffer            InSecBuff;
+    ULONG                ContextAttributes;
+    CredHandle      *pCred = (CredHandle *)crdHandle;
+    CtxtHandle      *pCtx;
+    CtxtHandle      *newContext;
+    TimeStamp            ltime;
+    jbyteArray       result;
+
+
+    pCtx = (CtxtHandle *) (*env)->GetLongField (env, this, ntlm_ctxHandleID);
+    if (pCtx == 0) { /* first call */
+        newContext = (CtxtHandle *)malloc(sizeof(CtxtHandle));
+        (*env)->SetLongField (env, this, ntlm_ctxHandleID, (jlong)newContext);
+    } else {
+        newContext = pCtx;
+    }
+
+    OutBuffDesc.ulVersion = 0;
+    OutBuffDesc.cBuffers  = 1;
+    OutBuffDesc.pBuffers  = &OutSecBuff;
+
+    OutSecBuff.cbBuffer   = 512;
+    OutSecBuff.BufferType = SECBUFFER_TOKEN;
+    OutSecBuff.pvBuffer   = buffOut;
+
+    /*
+     *  Prepare our Input buffer - Note the server is expecting the client's
+     *  negotiation packet on the first call
+     */
+
+    if (lastToken != 0)
+    {
+        pInput = (VOID *)(*env)->GetByteArrayElements(env, lastToken, &isCopy);
+        inputLen = (*env)->GetArrayLength(env, lastToken);
+
+        InBuffDesc.ulVersion = 0;
+        InBuffDesc.cBuffers  = 1;
+        InBuffDesc.pBuffers  = &InSecBuff;
+
+        InSecBuff.cbBuffer       = inputLen;
+        InSecBuff.BufferType = SECBUFFER_TOKEN;
+        InSecBuff.pvBuffer       = pInput;
+    }
+
+    /*
+     *  will return success when its done but we still
+     *  need to send the out buffer if there are bytes to send
+     */
+
+    ss = pInitializeSecurityContext(
+        pCred, pCtx, NULL, 0, 0, SECURITY_NATIVE_DREP,
+        lastToken ? &InBuffDesc : NULL, 0, newContext, &OutBuffDesc,
+        &ContextAttributes, &ltime
+    );
+
+    if (pInput != 0) {
+        (*env)->ReleaseByteArrayElements(env, lastToken, pInput, JNI_ABORT);
+    }
+
+    if (ss < 0) {
+        endSequence (pCred, pCtx);
+        return 0;
+    }
+
+    if ((ss == SEC_I_COMPLETE_NEEDED) || (ss == SEC_I_COMPLETE_AND_CONTINUE) ) {
+        ss = pCompleteAuthToken( pCtx, &OutBuffDesc );
+
+        if (ss < 0) {
+            endSequence (pCred, pCtx);
+            return 0;
+        }
+    }
+
+    if ( OutSecBuff.cbBuffer > 0 ) {
+        jbyteArray ret = (*env)->NewByteArray(env, OutSecBuff.cbBuffer);
+        (*env)->SetByteArrayRegion(env, ret, 0, OutSecBuff.cbBuffer,
+                OutSecBuff.pvBuffer);
+        if (lastToken != 0) // 2nd stage
+            endSequence (pCred, pCtx);
+        result = ret;
+    }
+
+    if ((ss != SEC_I_CONTINUE_NEEDED) && (ss == SEC_I_COMPLETE_AND_CONTINUE)) {
+        endSequence (pCred, pCtx);
+    }
+
+    return result;
+}
+
+static void endSequence (PCredHandle credHand, PCtxtHandle ctxHandle) {
+    if (credHand != 0) {
+        pFreeCredentialsHandle (credHand);
+        free (credHand);
+    }
+
+    if (ctxHandle != 0) {
+        pDeleteSecurityContext(ctxHandle);
+        free (ctxHandle);
+    }
+}
--- a/src/windows/native/sun/windows/awt_PrintControl.cpp	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/native/sun/windows/awt_PrintControl.cpp	Wed Nov 25 11:08:25 2009 -0800
@@ -687,7 +687,7 @@
     // Now, set-up the struct for the real calls to ::PrintDlg and ::CreateDC
 
     pd.hwndOwner = hwndOwner;
-    pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC;
+    pd.Flags = PD_ENABLEPRINTHOOK | PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE;
     pd.lpfnPrintHook = (LPPRINTHOOKPROC)PrintDlgHook;
 
     if (env->CallBooleanMethod(printCtrl, AwtPrintControl::getCollateID)) {
--- a/src/windows/native/sun/windows/awt_TrayIcon.cpp	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/native/sun/windows/awt_TrayIcon.cpp	Wed Nov 25 11:08:25 2009 -0800
@@ -59,7 +59,7 @@
 };
 
 typedef struct tagBitmapheader  {
-    BITMAPINFOHEADER bmiHeader;
+    BITMAPV5HEADER bmiHeader;
     DWORD            dwMasks[256];
 } Bitmapheader, *LPBITMAPHEADER;
 
@@ -638,12 +638,12 @@
 
 HBITMAP AwtTrayIcon::CreateBMP(HWND hW,int* imageData,int nSS, int nW, int nH)
 {
-    Bitmapheader    bmhHeader;
+    Bitmapheader    bmhHeader = {0};
     HDC             hDC;
     char            *ptrImageData;
     HBITMAP         hbmpBitmap;
     HBITMAP         hBitmap;
-    int             nNumChannels    = 3;
+    int             nNumChannels    = 4;
 
     if (!hW) {
         hW = ::GetDesktopWindow();
@@ -653,14 +653,20 @@
         return NULL;
     }
 
-    memset(&bmhHeader, 0, sizeof(Bitmapheader));
-    bmhHeader.bmiHeader.biSize              = sizeof(BITMAPINFOHEADER);
-    bmhHeader.bmiHeader.biWidth             = nW;
-    bmhHeader.bmiHeader.biHeight            = -nH;
-    bmhHeader.bmiHeader.biPlanes            = 1;
+    bmhHeader.bmiHeader.bV5Size              = sizeof(BITMAPV5HEADER);
+    bmhHeader.bmiHeader.bV5Width             = nW;
+    bmhHeader.bmiHeader.bV5Height            = -nH;
+    bmhHeader.bmiHeader.bV5Planes            = 1;
 
-    bmhHeader.bmiHeader.biBitCount          = 24;
-    bmhHeader.bmiHeader.biCompression       = BI_RGB;
+    bmhHeader.bmiHeader.bV5BitCount          = 32;
+    bmhHeader.bmiHeader.bV5Compression       = BI_BITFIELDS;
+
+    // The following mask specification specifies a supported 32 BPP
+    // alpha format for Windows XP.
+    bmhHeader.bmiHeader.bV5RedMask   =  0x00FF0000;
+    bmhHeader.bmiHeader.bV5GreenMask =  0x0000FF00;
+    bmhHeader.bmiHeader.bV5BlueMask  =  0x000000FF;
+    bmhHeader.bmiHeader.bV5AlphaMask =  0xFF000000;
 
     hbmpBitmap = ::CreateDIBSection(hDC, (BITMAPINFO*)&(bmhHeader),
                                     DIB_RGB_COLORS,
@@ -674,6 +680,7 @@
     }
     for (int nOutern = 0; nOutern < nH; nOutern++) {
         for (int nInner = 0; nInner < nSS; nInner++) {
+            dstPtr[3] = (*srcPtr >> 0x18) & 0xFF;
             dstPtr[2] = (*srcPtr >> 0x10) & 0xFF;
             dstPtr[1] = (*srcPtr >> 0x08) & 0xFF;
             dstPtr[0] = *srcPtr & 0xFF;
--- a/src/windows/native/sun/windows/awt_Window.cpp	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/native/sun/windows/awt_Window.cpp	Wed Nov 25 11:08:25 2009 -0800
@@ -143,6 +143,11 @@
     jobject window;
 };
 
+struct SetFullScreenExclusiveModeStateStruct {
+    jobject window;
+    jboolean isFSEMState;
+};
+
 
 /************************************************************************
  * AwtWindow fields
@@ -915,7 +920,9 @@
 
     bool show = false;
 
-    if (IsVisible() && currentWmSizeState != SIZE_MINIMIZED) {
+    if (IsVisible() && currentWmSizeState != SIZE_MINIMIZED &&
+            !isFullScreenExclusiveMode())
+    {
         if (AwtComponent::GetFocusedWindow() == GetHWnd()) {
             show = true;
         }
@@ -2954,6 +2961,25 @@
     delete uws;
 }
 
+void AwtWindow::_SetFullScreenExclusiveModeState(void *param)
+{
+    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
+
+    SetFullScreenExclusiveModeStateStruct * data =
+        (SetFullScreenExclusiveModeStateStruct*)param;
+    jobject self = data->window;
+    jboolean state = data->isFSEMState;
+
+    PDATA pData;
+    JNI_CHECK_PEER_GOTO(self, ret);
+    AwtWindow *window = (AwtWindow *)pData;
+
+    window->setFullScreenExclusiveModeState(state != 0);
+
+  ret:
+    env->DeleteGlobalRef(self);
+    delete data;
+}
 
 extern "C" {
 
@@ -3335,6 +3361,29 @@
 
 /*
  * Class:     sun_awt_windows_WWindowPeer
+ * Method:    setFullScreenExclusiveModeState
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL
+Java_sun_awt_windows_WWindowPeer_setFullScreenExclusiveModeState(JNIEnv *env,
+        jobject self, jboolean state)
+{
+    TRY;
+
+    SetFullScreenExclusiveModeStateStruct *data =
+        new SetFullScreenExclusiveModeStateStruct;
+    data->window = env->NewGlobalRef(self);
+    data->isFSEMState = state;
+
+    AwtToolkit::GetInstance().SyncCall(
+            AwtWindow::_SetFullScreenExclusiveModeState, data);
+    // global ref and data are deleted in the invoked method
+
+    CATCH_BAD_ALLOC;
+}
+
+/*
+ * Class:     sun_awt_windows_WWindowPeer
  * Method:    modalDisable
  * Signature: (J)V
  */
--- a/src/windows/native/sun/windows/awt_Window.h	Mon Nov 23 10:04:47 2009 +0000
+++ b/src/windows/native/sun/windows/awt_Window.h	Wed Nov 25 11:08:25 2009 -0800
@@ -229,6 +229,7 @@
     static void _SetOpaque(void* param);
     static void _UpdateWindow(void* param);
     static void _RepositionSecurityWarning(void* param);
+    static void _SetFullScreenExclusiveModeState(void* param);
 
     inline static BOOL IsResizing() {
         return sm_resizing;
@@ -331,6 +332,16 @@
     static void SetLayered(HWND window, bool layered);
     static bool IsLayered(HWND window);
 
+    BOOL fullScreenExclusiveModeState;
+    inline void setFullScreenExclusiveModeState(BOOL isEntered) {
+        fullScreenExclusiveModeState = isEntered;
+        UpdateSecurityWarningVisibility();
+    }
+    inline BOOL isFullScreenExclusiveMode() {
+        return fullScreenExclusiveModeState;
+    }
+
+
 public:
     void UpdateSecurityWarningVisibility();
     static bool IsWarningWindow(HWND hWnd);
--- a/test/Makefile	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/Makefile	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright 1995-2008 Sun Microsystems, Inc.  All Rights Reserved.
+# Copyright 1995-2009 Sun Microsystems, Inc.  All Rights Reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -27,83 +27,141 @@
 # Makefile to run various jdk tests
 #
 
-# Get OS/ARCH specifics
-OSNAME = $(shell uname -s)
+# Empty these to get rid of some default rules
+.SUFFIXES:
+.SUFFIXES: .java
+CO=
+GET=
+
+# Utilities used
+AWK       = awk
+CAT       = cat
+CD        = cd
+CHMOD     = chmod
+CP        = cp
+CUT       = cut
+ECHO      = echo
+EGREP     = egrep
+EXPAND    = expand
+EXPR      = expr
+KILL      = /usr/bin/kill
+MKDIR     = mkdir
+NOHUP     = nohup
+PWD       = pwd
+SED       = sed
+SLEEP     = sleep
+SORT      = sort
+TEE       = tee
+UNAME     = uname
+UNIQ      = uniq
+WC        = wc
+XHOST     = xhost
+ZIP       = zip
+
+# Get OS name from uname
+UNAME_S := $(shell $(UNAME) -s)
 
 # Commands to run on paths to make mixed paths for java on windows
-GETMIXEDPATH=echo
+GETMIXEDPATH=$(ECHO)
 
 # Location of developer shared files
 SLASH_JAVA = /java
 
 # Platform specific settings
-ifeq ($(OSNAME), SunOS)
-  PLATFORM = solaris
-  ARCH = $(shell uname -p)
-  ifeq ($(ARCH), i386)
-    ARCH=i586
-  endif
+ifeq ($(UNAME_S), SunOS)
+  OS_NAME     = solaris
+  OS_ARCH    := $(shell $(UNAME) -p)
+  OS_VERSION := $(shell $(UNAME) -r)
+endif
+ifeq ($(UNAME_S), Linux)
+  OS_NAME     = linux
+  OS_ARCH    := $(shell $(UNAME) -m)
+  OS_VERSION := $(shell $(UNAME) -r)
 endif
-ifeq ($(OSNAME), Linux)
-  PLATFORM = linux
-  ARCH = $(shell uname -m)
-  ifeq ($(ARCH), i386)
-    ARCH=i586
+ifndef OS_NAME
+  ifneq ($(PROCESSOR_IDENTIFIER), )
+    OS_NAME = windows
+    SLASH_JAVA = J:
+    # A variety of ways to say X64 arch :^(
+    OS_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
+    EXESUFFIX = .exe
+    # These need to be different depending on MKS or CYGWIN
+    ifeq ($(findstring cygdrive,$(shell ($(CD) C:/ && $(PWD)))), )
+      GETMIXEDPATH  = dosname -s
+      OS_VERSION   := $(shell $(UNAME) -r)
+    else
+      GETMIXEDPATH  = cygpath -m -s
+      OS_VERSION   := $(shell $(UNAME) -s | $(CUT) -d'-' -f2)
+    endif
   endif
 endif
 
-# Cannot trust uname output
-ifneq ($(PROCESSOR_IDENTIFIER), )
-  PLATFORM = windows
-  SLASH_JAVA = J:
-  # A variety of ways to say X64 arch :^(
-  PROC_ARCH:=$(word 1, $(PROCESSOR_IDENTIFIER))
-  PROC_ARCH:=$(subst x86,X86,$(PROC_ARCH))
-  PROC_ARCH:=$(subst x64,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst AMD64,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst amd64,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst EM64T,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst em64t,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst intel64,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst Intel64,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst INTEL64,X64,$(PROC_ARCH))
-  PROC_ARCH:=$(subst ia64,IA64,$(PROC_ARCH))
-  ifeq ($(PROC_ARCH),IA64)
-    ARCH = ia64
+# Only want major and minor numbers from os version
+OS_VERSION := $(shell $(ECHO) "$(OS_VERSION)" | $(CUT) -d'.' -f1,2)
+
+# Try and use names i586, x64, and ia64 consistently  
+OS_ARCH:=$(subst X64,x64,$(OS_ARCH))
+OS_ARCH:=$(subst AMD64,x64,$(OS_ARCH))
+OS_ARCH:=$(subst amd64,x64,$(OS_ARCH))
+OS_ARCH:=$(subst x86_64,x64,$(OS_ARCH))
+OS_ARCH:=$(subst EM64T,x64,$(OS_ARCH))
+OS_ARCH:=$(subst em64t,x64,$(OS_ARCH))
+OS_ARCH:=$(subst intel64,x64,$(OS_ARCH))
+OS_ARCH:=$(subst Intel64,x64,$(OS_ARCH))
+OS_ARCH:=$(subst INTEL64,x64,$(OS_ARCH))
+OS_ARCH:=$(subst IA64,ia64,$(OS_ARCH))
+OS_ARCH:=$(subst X86,i586,$(OS_ARCH))
+OS_ARCH:=$(subst x86,i586,$(OS_ARCH))
+OS_ARCH:=$(subst i386,i586,$(OS_ARCH))
+OS_ARCH:=$(subst i486,i586,$(OS_ARCH))
+OS_ARCH:=$(subst i686,i586,$(OS_ARCH))
+
+# Check for ARCH_DATA_MODEL, adjust OS_ARCH accordingly
+ifndef ARCH_DATA_MODEL
+  ARCH_DATA_MODEL=32
+endif
+ARCH_DATA_MODEL_ERROR= \
+  ARCH_DATA_MODEL=$(ARCH_DATA_MODEL) cannot be used with $(OS_NAME)-$(ARCH)
+ifeq ($(ARCH_DATA_MODEL),64)
+  ifeq ($(OS_NAME)-$(OS_ARCH),solaris-i586)
+    OS_ARCH=x64
+  endif
+  ifeq ($(OS_NAME)-$(OS_ARCH),solaris-sparc)
+    OS_ARCH=sparcv9
+  endif
+  ifeq ($(OS_ARCH),i586)
+    x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
+  endif
+  ifeq ($(OS_ARCH),sparc)
+    x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
+  endif
+else
+  ifeq ($(ARCH_DATA_MODEL),32)
+    ifeq ($(OS_ARCH),x64)
+      x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
+    endif
+    ifeq ($(OS_ARCH),ia64)
+      x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
+    endif
+    ifeq ($(OS_ARCH),sparcv9)
+      x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
+    endif
   else
-    ifeq ($(PROC_ARCH),X64)
-      ARCH = x64
-    else
-      ARCH = i586
-    endif
-  endif
-  EXESUFFIX = .exe
-  # These need to be different depending on MKS or CYGWIN
-  ifeq ($(findstring cygdrive,$(shell (cd C:/ && pwd))), )
-    GETMIXEDPATH=dosname -s
-  else
-    GETMIXEDPATH=cygpath -m -s
+    x:=$(warning "WARNING: $(ARCH_DATA_MODEL_ERROR)")
   endif
 endif
 
-# Utilities used
-CD    = cd
-CP    = cp
-ECHO  = echo
-MKDIR = mkdir
-ZIP   = zip
-
 # Root of this test area (important to use full paths in some places)
-TEST_ROOT := $(shell pwd)
+TEST_ROOT := $(shell $(PWD))
 
 # Root of all test results
 ifdef ALT_OUTPUTDIR
   ABS_OUTPUTDIR = $(ALT_OUTPUTDIR)
 else
-  ABS_OUTPUTDIR = $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)
+  ABS_OUTPUTDIR = $(TEST_ROOT)/../build/$(OS_NAME)-$(OS_ARCH)
 endif
 ABS_BUILD_ROOT = $(ABS_OUTPUTDIR)
-ABS_TEST_OUTPUT_DIR := $(ABS_BUILD_ROOT)/testoutput
+ABS_TEST_OUTPUT_DIR := $(ABS_BUILD_ROOT)/testoutput/$(UNIQUE_DIR)
 
 # Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
 ifndef PRODUCT_HOME
@@ -114,13 +172,14 @@
       if [ -d $(ABS_JDK_IMAGE) ] ; then \
          $(ECHO) "$(ABS_JDK_IMAGE)";    \
        else                             \
-         $(ECHO) "$(ABS_BUILD_ROOT)" ;  \
+         $(ECHO) "$(ABS_BUILD_ROOT)";   \
        fi)
   PRODUCT_HOME := $(PRODUCT_HOME)
 endif
 
 # Expect JPRT to set JPRT_PRODUCT_ARGS (e.g. -server etc.)
 #   Should be passed into 'java' only.
+#   Could include: -d64 -server -client OR any java option
 ifdef JPRT_PRODUCT_ARGS
   JAVA_ARGS = $(JPRT_PRODUCT_ARGS)
 endif
@@ -131,18 +190,131 @@
   JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS)
 endif
 
+# Check JAVA_ARGS arguments based on ARCH_DATA_MODEL etc.
+ifeq ($(OS_NAME),solaris)
+  D64_ERROR_MESSAGE=Mismatch between ARCH_DATA_MODEL=$(ARCH_DATA_MODEL) and use of -d64 in JAVA_ARGS=$(JAVA_ARGS)
+  ifeq ($(ARCH_DATA_MODEL),32)
+    ifneq ($(findstring -d64,$(JAVA_ARGS)),)
+      x:=$(warning "WARNING: $(D64_ERROR_MESSAGE)")
+    endif
+  endif
+  ifeq ($(ARCH_DATA_MODEL),64)
+    ifeq ($(findstring -d64,$(JAVA_ARGS)),)
+      x:=$(warning "WARNING: $(D64_ERROR_MESSAGE)")
+    endif
+  endif
+endif
+
 # Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
 ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
 ifdef JPRT_ARCHIVE_BUNDLE
   ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
 endif
 
+# DISPLAY settings for virtual frame buffer
+START_XVFB = start-Xvfb.sh
+NOHUP_OUTPUT = $(ABS_TEST_OUTPUT_DIR)/start-Xvfb.nohup-output.txt
+DISPLAY_PID_FILE=$(ABS_TEST_OUTPUT_DIR)/xvfb-display-number.txt
+DISPLAY_SLEEP_TIME=10
+DISPLAY_MAX_SLEEPS=10
+ifeq ($(OS_NAME),solaris)
+  VIRTUAL_FRAME_BUFFER = true
+endif
+ifeq ($(OS_NAME),linux)
+  VIRTUAL_FRAME_BUFFER = true
+endif
+
+# Does not work yet, display dies as soon as it gets used. :^(
+VIRTUAL_FRAME_BUFFER = false
+
+# Are we using a VIRTUAL_FRAME_BUFFER (Xvfb)
+ifeq ($(VIRTUAL_FRAME_BUFFER),true)
+  
+  PREP_DISPLAY = \
+    $(CP) $(START_XVFB) $(ABS_TEST_OUTPUT_DIR); \
+    $(CHMOD) a+x $(ABS_TEST_OUTPUT_DIR)/$(START_XVFB); \
+    ( $(CD) $(ABS_TEST_OUTPUT_DIR) && \
+      $(NOHUP) $(ABS_TEST_OUTPUT_DIR)/$(START_XVFB) $(DISPLAY_PID_FILE) > $(NOHUP_OUTPUT) 2>&1 && \
+      $(SLEEP) $(DISPLAY_SLEEP_TIME) ) & \
+    count=1; \
+    while [ ! -s $(DISPLAY_PID_FILE) ] ; do \
+      $(ECHO) "Sleeping $(DISPLAY_SLEEP_TIME) more seconds, DISPLAY not ready"; \
+      $(SLEEP) $(DISPLAY_SLEEP_TIME); \
+      count=`$(EXPR) $${count} '+' 1`; \
+      if [ $${count} -gt $(DISPLAY_MAX_SLEEPS) ] ; then \
+        $(ECHO) "ERROR: DISPLAY not ready, giving up on DISPLAY"; \
+        exit 9; \
+      fi; \
+    done ; \
+    DISPLAY=":`$(CAT) $(DISPLAY_PID_FILE)`"; \
+    export DISPLAY; \
+    $(CAT) $(NOHUP_OUTPUT); \
+    $(ECHO) "Prepared DISPLAY=$${DISPLAY}"; \
+    $(XHOST) || \
+    ( $(ECHO) "ERROR: No display" ; exit 8)
+
+  KILL_DISPLAY = \
+    ( \
+      DISPLAY=":`$(CAT) $(DISPLAY_PID_FILE)`"; \
+      export DISPLAY; \
+      if [ -s "$(DISPLAY_PID_FILE)" ] ; then \
+        $(KILL) `$(CAT) $(DISPLAY_PID_FILE)` > /dev/null 2>&1; \
+        $(KILL) -9 `$(CAT) $(DISPLAY_PID_FILE)` > /dev/null 2>&1; \
+      fi; \
+      $(ECHO) "Killed DISPLAY=$${DISPLAY}"; \
+    )
+
+else
+  
+  PREP_DISPLAY = $(ECHO) "VIRTUAL_FRAME_BUFFER=$(VIRTUAL_FRAME_BUFFER)"
+  KILL_DISPLAY = $(ECHO) "VIRTUAL_FRAME_BUFFER=$(VIRTUAL_FRAME_BUFFER)"
+
+endif
+
 # How to create the test bundle (pass or fail, we want to create this)
 #   Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
 ZIP_UP_RESULTS = ( $(MKDIR) -p `dirname $(ARCHIVE_BUNDLE)`     \
 	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
 	           && $(ZIP) -q -r $(ARCHIVE_BUNDLE) . )
-BUNDLE_UP_AND_EXIT = ( exitCode=$$? && $(ZIP_UP_RESULTS) && exit $${exitCode} )
+SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport/text/summary.txt
+STATS_TXT_NAME = Stats.txt
+STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/$(STATS_TXT_NAME)
+RUNLIST   = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/runlist.txt
+PASSLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/passlist.txt
+FAILLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/faillist.txt
+BUNDLE_UP_AND_EXIT = \
+( \
+  exitCode=$$? && \
+  _summary="$(SUMMARY_TXT)"; \
+  $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST); \
+  if [ -r "$${_summary}" ] ; then \
+    $(ECHO) "Summary: $${_summary}" > $(STATS_TXT); \
+    $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \
+    $(EGREP) ' Passed\.' $(RUNLIST) \
+      | $(EGREP) -v ' Error\.' \
+      | $(EGREP) -v ' Failed\.' > $(PASSLIST); \
+    ( $(EGREP) ' Failed\.' $(RUNLIST); \
+      $(EGREP) ' Error\.' $(RUNLIST); \
+      $(EGREP) -v ' Passed\.' $(RUNLIST) ) \
+      | $(SORT) | $(UNIQ) > $(FAILLIST); \
+    if [ $${exitCode} != 0 -o -s $(FAILLIST) ] ; then \
+      $(EXPAND) $(FAILLIST) \
+        | $(CUT) -d' ' -f1 \
+        | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \
+    fi; \
+    runc="`$(CAT) $(RUNLIST)      | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    passc="`$(CAT) $(PASSLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    failc="`$(CAT) $(FAILLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    exclc="`$(CAT) $(EXCLUDELIST) | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    $(ECHO) "TEST STATS: run=$${runc}  pass=$${passc}  fail=$${failc}  excluded=$${exclc}" \
+      >> $(STATS_TXT); \
+  else \
+    $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
+  fi; \
+  $(CAT) $(STATS_TXT); \
+  $(ZIP_UP_RESULTS) && $(KILL_DISPLAY) && \
+  exit $${exitCode} \
+)
 
 ################################################################
 
@@ -172,32 +344,239 @@
 
 # Expect JPRT to set TESTDIRS to the jtreg test dirs
 ifndef TESTDIRS
-  TESTDIRS = demo/jvmti/gctest demo/jvmti/hprof
+  TESTDIRS = demo
+endif
+
+# Samevm settings (default is false)
+ifndef USE_JTREG_SAMEVM
+  USE_JTREG_SAMEVM=false
+endif
+# With samevm, you cannot use -javaoptions?
+ifeq ($(USE_JTREG_SAMEVM),true)
+  EXTRA_JTREG_OPTIONS += -samevm $(JAVA_ARGS) $(JAVA_ARGS:%=-vmoption:%)
+  JTREG_TEST_OPTIONS = $(JAVA_VM_ARGS:%=-vmoption:%)
+else
+  JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_VM_ARGS:%=-vmoption:%)
+endif
+
+# Some tests annoy me and fail frequently
+PROBLEM_LIST=ProblemList.txt
+EXCLUDELIST=$(ABS_TEST_OUTPUT_DIR)/excludelist.txt
+
+# Create exclude list for this platform and arch
+ifdef NO_EXCLUDES
+$(EXCLUDELIST): $(PROBLEM_LIST) $(TESTDIRS)
+	@$(ECHO) "NOTHING_EXCLUDED" > $@
+else
+$(EXCLUDELIST): $(PROBLEM_LIST) $(TESTDIRS)
+	@$(RM) $@ $@.temp1 $@.temp2
+	@( ( $(EGREP) -- '$(OS_NAME)-all'           $< ) ;\
+	   ( $(EGREP) -- '$(OS_NAME)-$(OS_ARCH)'    $< ) ;\
+	   ( $(EGREP) -- '$(OS_NAME)-$(OS_VERSION)' $< ) ;\
+	   ( $(EGREP) -- 'generic-$(OS_ARCH)'       $< ) ;\
+           ( $(EGREP) -- 'generic-all'              $< ) ;\
+           ( $(ECHO) "#") ;\
+        ) | $(SED) -e 's@^[\ ]*@@' \
+          | $(EGREP) -v '^#' > $@.temp1
+	@for tdir in $(TESTDIRS) ; do \
+          ( ( $(CAT) $@.temp1 | $(EGREP) "^$${tdir}" ) ; $(ECHO) "#" ) >> $@.temp2 ; \
+        done
+	@$(ECHO) "# at least one line" >> $@.temp2
+	@( $(EGREP) -v '^#' $@.temp2 ; true ) > $@
+	@$(ECHO) "Excluding list contains `$(EXPAND) $@ | $(WC) -l` items"
 endif
 
+# Running batches of tests with or without samevm
+define RunSamevmBatch
+$(ECHO) "Running tests in samevm mode: $?"
+$(MAKE) TESTDIRS="$?" USE_JTREG_SAMEVM=true  UNIQUE_DIR=$@ jtreg_tests
+endef
+define RunOthervmBatch
+$(ECHO) "Running tests in othervm mode: $?"
+$(MAKE) TESTDIRS="$?" USE_JTREG_SAMEVM=false UNIQUE_DIR=$@ jtreg_tests
+endef
+define SummaryInfo
+$(ECHO) "Summary for: $?"
+$(CAT) $(?:%=$(ABS_TEST_OUTPUT_DIR)/%/$(STATS_TXT_NAME))
+endef
+
+# ------------------------------------------------------------------
+
+# Batches of tests (somewhat arbitrary assigments to jdk_* targets)
+JDK_ALL_TARGETS =
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has problems, and doesn't help performance as much as others.
+JDK_ALL_TARGETS += jdk_awt
+jdk_awt: com/sun/awt java/awt sun/awt
+	$(call RunOthervmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_beans1
+jdk_beans1: java/beans/beancontext java/beans/PropertyChangeSupport \
+            java/beans/Introspector java/beans/Performance \
+            java/beans/VetoableChangeSupport java/beans/Statement
+	$(call RunSamevmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has serious problems with these tests
+JDK_ALL_TARGETS += jdk_beans2
+jdk_beans2: java/beans/Beans java/beans/EventHandler java/beans/XMLDecoder \
+            java/beans/PropertyEditor
+	$(call RunOthervmBatch)
+JDK_ALL_TARGETS += jdk_beans3
+jdk_beans3: java/beans/XMLEncoder
+	$(call RunOthervmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_io
+jdk_io: java/io
+	$(call RunSamevmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_lang
+jdk_lang: java/lang
+	$(call RunSamevmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has serious problems with these tests
+JDK_ALL_TARGETS += jdk_management1
+jdk_management1: javax/management
+	$(call RunOthervmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has serious problems with these tests
+JDK_ALL_TARGETS += jdk_management2
+jdk_management2: com/sun/jmx com/sun/management sun/management
+	$(call RunOthervmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_math
+jdk_math: java/math
+	$(call RunSamevmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_misc
+jdk_misc: demo javax/imageio javax/naming javax/print javax/script \
+          javax/smartcardio javax/sound com/sun/java com/sun/jndi \
+	  com/sun/org sun/misc sun/pisces
+	$(call RunSamevmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_net
+jdk_net: com/sun/net java/net sun/net
+	$(call RunSamevmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_nio1
+jdk_nio1: java/nio/file
+	$(call RunSamevmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has serious problems with these tests
+JDK_ALL_TARGETS += jdk_nio2
+jdk_nio2: java/nio/Buffer java/nio/ByteOrder \
+          java/nio/channels java/nio/BufferPoolMXBean java/nio/MappedByteBuffer
+	$(call RunOthervmBatch)
+JDK_ALL_TARGETS += jdk_nio3
+jdk_nio3: com/sun/nio sun/nio
+	$(call RunOthervmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has serious problems with these tests
+JDK_ALL_TARGETS += jdk_rmi
+jdk_rmi: java/rmi javax/rmi sun/rmi
+	$(call RunOthervmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_security1
+jdk_security1: java/security
+	$(call RunSamevmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has serious problems with these tests
+JDK_ALL_TARGETS += jdk_security2
+jdk_security2: javax/crypto com/sun/crypto
+	$(call RunOthervmBatch)
+JDK_ALL_TARGETS += jdk_security3
+jdk_security3: com/sun/security lib/security javax/security sun/security
+	$(call RunOthervmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has problems, and doesn't help performance as much as others.
+JDK_ALL_TARGETS += jdk_swing
+jdk_swing: javax/swing sun/java2d
+	$(call RunOthervmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_text
+jdk_text: java/text sun/text
+	$(call RunSamevmBatch)
+
+# Stable othervm testruns (minus items from PROBLEM_LIST)
+#   Using samevm has serious problems with these tests
+JDK_ALL_TARGETS += jdk_tools1
+jdk_tools1: com/sun/jdi
+	$(call RunOthervmBatch)
+JDK_ALL_TARGETS += jdk_tools2
+jdk_tools2: com/sun/tools sun/jvmstat sun/tools tools vm com/sun/servicetag com/sun/tracing
+	$(call RunOthervmBatch)
+
+# Stable samevm testruns (minus items from PROBLEM_LIST)
+JDK_ALL_TARGETS += jdk_util
+jdk_util: java/util sun/util
+	$(call RunSamevmBatch)
+
+# ------------------------------------------------------------------
+
+# Run all tests
+jdk_all: $(filter-out jdk_awt jdk_rmi jdk_swing, $(JDK_ALL_TARGETS))
+	@$(SummaryInfo)
+
+# These are all phony targets
+PHONY_LIST += $(JDK_ALL_TARGETS)
+
+# ------------------------------------------------------------------
+
 # Default JTREG to run (win32 script works for everybody)
 JTREG = $(JT_HOME)/win32/bin/jtreg
+# Add any extra options (samevm etc.)
+JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
+# Only run automatic tests
+JTREG_BASIC_OPTIONS += -a
+# Report details on all failed or error tests, times too
+JTREG_BASIC_OPTIONS += -v:fail,error,time
+# Retain all files for failing tests
+JTREG_BASIC_OPTIONS += -retain:fail,error
+# Ignore tests are not run and completely silent about it
+JTREG_BASIC_OPTIONS += -ignore:quiet
+# Multiple by 2 the timeout numbers
+JTREG_BASIC_OPTIONS += -timeoutFactor:2
+# Boost the max memory for jtreg to avoid gc thrashing
+JTREG_BASIC_OPTIONS += -J-Xmx512m
 
-jtreg_tests: prep $(JT_HOME) $(PRODUCT_HOME) $(JTREG)
-	$(RM) $(JTREG).orig
-	cp $(JTREG) $(JTREG).orig
-	$(RM) $(JTREG)
-	sed -e 's@-J\*@-J-*@' $(JTREG).orig > $(JTREG)
-	chmod a+x $(JTREG)
-	( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                     \
-          export JT_HOME;                                                    \
-          $(shell $(GETMIXEDPATH) "$(JTREG)")                                \
-            -a -v:fail,error                                                 \
-	    -ignore:quiet                                                    \
-	    -timeoutFactor:2                                                 \
-            $(EXTRA_JTREG_OPTIONS)                                           \
-            -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport    \
-            -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork      \
-            -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                  \
-            $(JAVA_ARGS:%=-javaoptions:%)                                     \
-            $(JAVA_VM_ARGS:%=-vmoption:%)                                    \
-            $(TESTDIRS)                                                      \
-	) ; $(BUNDLE_UP_AND_EXIT)
+# Make sure jtreg exists
+$(JTREG): $(JT_HOME)
+
+# Run jtreg
+jtreg_tests: prep $(PRODUCT_HOME) $(JTREG) $(EXCLUDELIST)
+	@$(EXPAND) $(EXCLUDELIST) \
+            | $(CUT) -d' ' -f1 \
+            | $(SED) -e 's@^@Excluding: @'
+	(                                                                    \
+	  ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                   \
+            export JT_HOME;                                                  \
+	    $(PREP_DISPLAY) &&                                               \
+            $(shell $(GETMIXEDPATH) "$(JTREG)")                              \
+              $(JTREG_BASIC_OPTIONS)                                         \
+              -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTreport  \
+              -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)")/JTwork    \
+              -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \
+              -exclude:$(shell $(GETMIXEDPATH) "$(EXCLUDELIST)")             \
+              $(JTREG_TEST_OPTIONS)                                          \
+              $(TESTDIRS)                                                    \
+	  ) ; $(BUNDLE_UP_AND_EXIT)                                          \
+	) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt
 
 PHONY_LIST += jtreg_tests
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/ProblemList.txt	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,1211 @@
+###########################################################################
+#
+# 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.
+#
+###########################################################################
+#
+# List of tests that should not be run by test/Makefile, for various reasons:
+#   1. Does not run with jtreg -samevm mode
+#   2. Causes problems in jtreg -samevm mode for jtreg or tests that follow it
+#   3. The test is too slow or consumes too many system resources
+#   4. The test fails when run on any official build systems
+#
+# It is possible that a test being on this list is a mistake, and that some
+#   other test in samevm mode caused tests to fail, mistakes happen.
+#
+# Tests marked @ignore are not run by test/Makefile, but harmless to be listed.
+#
+# Tests that explicitly state "@run main/othervm ...", and are not listed here,
+#   will be run in the same batch as the samevm tests.
+#
+# Shell tests are othervm by default.
+#
+# List items  are testnames followed by labels, all MUST BE commented 
+#   as to why they are here and use a label:
+#     generic-all	Problems on all platforms
+#     generic-ARCH	Where ARCH is one of: sparc, sparcv9, x64, i586, etc.
+#     OSNAME-all	Where OSNAME is one of: solaris, linux, windows
+#     OSNAME-ARCH	Specific on to one OSNAME and ARCH, e.g. solaris-x64
+#     OSNAME-REV	Specific on to one OSNAME and REV, e.g. solaris-5.8
+#	 
+# More than one label is allowed but must be on the same line.
+#
+#############################################################################
+#
+# Running the tests:
+#    cd test && make JT_HOME=jtreg_home PRODUCT_HOME=jdk_home jdk_all
+#  Or instead of jdk_all, use any of the jdk_* targets.
+#
+# Samevm Notes:
+#  * Although some tests may have only been seen to fail on some platforms,
+#    they might be flagged as 'generic-all' because the problem they have
+#    could cause hidden slowdowns on other platforms.
+#    Most samevm problems will be generic-all, but windows usually dislikes
+#    them the most.
+#    Address already in use or connection errors indicate a generic port issue.
+#    (this is not necessarily a samevm issue, but an issue for running the tests
+#     on shared machines, two people or two test runs will collide).
+#  * Samevm problem (windows in particular) is not closing all input/output
+#  * Samevm problem when a test calls setSecurityManager()
+#  * Samevm problem with setHttps*() is used? (not exactly sure here)
+#  * Samevm problem when stuffing system properties with non Strings or anything
+#  * Samevm problem when changing vm settings, or registering any vm actions
+#  * Samevm problems with deleteOnExit(), if it must happen at end of test
+#  * Samevm problems with URLClassLoader? (no details here)
+#  * Samevm problems with dependence on predictable GC or finalizations
+#
+# Any of the above problems may mean the test needs to be flagged as "othervm".
+#
+#############################################################################
+#
+# Fixing the tests:
+#
+# Some tests just may need to be run with "othervm", and that can easily be
+#   done my adding a @run line (or modifying any existing @run):
+#      @run main/othervm NameOfMainClass
+#   Make sure this @run follows any use of @library.
+#   Otherwise, if the test is a samevm possibility, make sure the test is
+#     cleaning up after itself, closing all streams, deleting temp files, etc.
+#
+# Keep in mind that the bug could be in many places, and even different per
+#   platform, it could be a bug in any one of:
+#      - the testcase
+#      - the jdk (jdk classes, native code, or hotspot)
+#      - the native compiler
+#      - the javac compiler
+#      - the OS (depends on what the testcase does)
+#
+# If you managed to really fix one of these tests, here is how you can
+#    remove tests from this list:
+#  1. Make sure test passes on all platforms with samevm, or mark it othervm
+#  2. Make sure test passes on all platforms when run with it's entire group
+#  3. Make sure both VMs are tested, -server and -client, if possible
+#  4. Make sure you try the -d64 option on Solaris
+#  5. Use a tool like JPRT or something to verify these results
+#  6. Delete lines in this file, include the changes with your test changes
+#
+# You may need to repeat your testing 2 or even 3 times to verify good
+#   results, some of these samevm failures are not very predictable.
+#
+#############################################################################
+
+############################################################################
+
+# jdk_awt
+
+# None of the awt tests are using samevm, might not be worth the effort due
+#  to the vm overhead not being enough to make a difference.
+# In general, the awt tests are problematic with or without samevm, and there
+#  are issues with using a Xvfb display.
+
+# Fails on solaris sparc, timedout? in othervm mode
+java/awt/event/MouseEvent/AcceptExtraButton/AcceptExtraButton.java generic-all
+
+# Causes hang in samevm mode??? Solaris 11 i586
+java/awt/FullScreen/SetFSWindow/FSFrame.java			generic-all
+
+# Fails on solaris 11 i586, -client, in othervm mode not sure why
+java/awt/Component/PrintAllXcheckJNI/PrintAllXcheckJNI.java	generic-all
+java/awt/Focus/CloseDialogActivateOwnerTest/CloseDialogActivateOwnerTest.java generic-all
+java/awt/FontClass/FontAccess.java				generic-all
+java/awt/Mixing/HWDisappear.java				generic-all
+java/awt/Mixing/MixingInHwPanel.java				generic-all
+java/awt/Mouse/MaximizedFrameTest/MaximizedFrameTest.html	generic-all
+java/awt/Robot/AcceptExtraMouseButtons/AcceptExtraMouseButtons.java generic-all
+java/awt/Toolkit/SecurityTest/SecurityTest2.java		generic-all
+java/awt/image/mlib/MlibOpsTest.java				generic-all
+
+# Fails on windows, othervm mode, various errors
+java/awt/Focus/NonFocusableWindowTest/NonfocusableOwnerTest.java	generic-all
+java/awt/Focus/OwnedWindowFocusIMECrashTest/OwnedWindowFocusIMECrashTest.java	generic-all
+java/awt/FullScreen/NoResizeEventOnDMChangeTest/NoResizeEventOnDMChangeTest.java	generic-all
+java/awt/Mouse/MouseModifiersUnitTest/MouseModifiersUnitTest_Standard.java	generic-all
+java/awt/event/KeyEvent/KeyTyped/CtrlASCII.html			generic-all
+java/awt/font/Threads/FontThread.java				generic-all
+java/awt/print/PrinterJob/PrtException.java			generic-all
+
+# Fails with windows X64, othervm, -server
+com/sun/awt/Translucency/WindowOpacity.java			generic-all
+java/awt/EventDispatchThread/HandleExceptionOnEDT/HandleExceptionOnEDT.java		generic-all
+java/awt/EventDispatchThread/LoopRobustness/LoopRobustness.html	generic-all
+java/awt/Focus/AppletInitialFocusTest/AppletInitialFocusTest1.html generic-all
+java/awt/Focus/FocusEmbeddedFrameTest/FocusEmbeddedFrameTest.java generic-all
+java/awt/Frame/LayoutOnMaximizeTest/LayoutOnMaximizeTest.java	generic-all
+java/awt/FullScreen/TranslucentWindow/TranslucentWindow.java	generic-all
+java/awt/Mixing/MixingOnShrinkingHWButton.java			generic-all
+java/awt/Mouse/MouseModifiersUnitTest/ExtraButtonDrag.java	generic-all
+
+############################################################################
+
+# jdk_beans
+
+# A large set of the beans tests set the security manager, which would seem
+#  to indicate that a large number of them should be "othervm", yet are all
+#  very small tests and could greatly benefit from a samevm test run.
+#  So a large batch of beans tests are currently run with othervm mode.
+
+# Linux, some kind of problems with X11 display
+java/beans/PropertyChangeSupport/Test4682386.java		generic-all
+java/beans/PropertyChangeSupport/TestSynchronization.java	generic-all
+java/beans/Statement/Test4653179.java				generic-all
+
+# Runs REALLY slow on Solaris sparc for some reason, both -client and -server
+java/beans/XMLEncoder/Test4625418.java				solaris-sparc
+
+# Problems with samevm and setting security manager (speculation partially)
+java/beans/Beans/Test4080522.java				generic-all
+java/beans/EventHandler/Test6277246.java			generic-all
+java/beans/EventHandler/Test6277266.java			generic-all
+java/beans/Introspector/Test6277246.java			generic-all
+java/beans/Introspector/4168475/Test4168475.java		generic-all
+java/beans/Introspector/4520754/Test4520754.java		generic-all
+java/beans/Introspector/6380849/TestBeanInfo.java		generic-all
+java/beans/Introspector/Test4144543.java			generic-all
+
+# Failed to call method solaris-sparc???
+java/beans/EventHandler/Test6788531.java		 	generic-all
+
+# Jar or class not found???
+java/beans/XMLEncoder/6329581/Test6329581.java		 	generic-all
+
+############################################################################
+
+# jdk_io
+
+# Many of these tests have a tendency to leave input streams open, which
+#  will cause following tests to be failures when used in samevm mode.
+
+# Should be othervm, or corrected for samevm, fails with samevm:
+java/io/BufferedReader/BigMark.java			 	generic-all
+java/io/BufferedReader/ReadLineSync.java		 	generic-all
+
+# One of these is leaving "a.ser" file open, windows samevm
+java/io/Serializable/duplicateSerialFields/Setup.java		generic-all
+java/io/Serializable/duplicateSerialFields/Test.java		generic-all
+
+# One of these leaving foo.ser open, windows samevm problem
+java/io/Serializable/enum/constantSubclasses/Read.java		generic-all
+java/io/Serializable/enum/constantSubclasses/Write.java		generic-all
+java/io/Serializable/enum/missingConstant/Read.java		generic-all
+java/io/Serializable/enum/missingConstant/Write.java		generic-all
+
+# This is leaving subtest1.tmp open, windows samevm problem
+java/io/Serializable/oldTests/AnnotateClass.java		generic-all
+
+# One or more of these leave a piotest* file open, windows samevm
+java/io/Serializable/oldTests/ArrayFields.java			generic-all
+java/io/Serializable/oldTests/ArraysOfArrays.java		generic-all
+java/io/Serializable/oldTests/BinaryTree.java			generic-all
+java/io/Serializable/oldTests/CircularList.java			generic-all
+java/io/Serializable/oldTests/SerializeWithException.java	generic-all
+java/io/Serializable/oldTests/SimpleArrays.java			generic-all
+java/io/Serializable/oldTests/WritePrimitive.java		generic-all
+
+# Missing close on file 0.ser, windows samevm
+java/io/Serializable/enum/badResolve/Read.java			generic-all
+java/io/Serializable/enum/badResolve/Write.java			generic-all
+
+# One of these tests is leaving parents.ser open, windows samevm
+java/io/Serializable/parents/EvolvedClass.java			generic-all
+java/io/Serializable/parents/OriginalClass.java			generic-all
+
+# One of these tests is leaving file foo.ser and/or bar.ser open, windows samevm
+java/io/Serializable/fieldTypeString/Read.java			generic-all
+java/io/Serializable/fieldTypeString/Write.java			generic-all
+
+# One of these tests is leaving tmp.ser file open, windows samevm
+java/io/Serializable/ClassCastExceptionDetail/Read.java		generic-all
+java/io/Serializable/ClassCastExceptionDetail/Write.java	generic-all
+java/io/Serializable/GetField/Read.java				generic-all
+java/io/Serializable/GetField/Read2.java			generic-all
+java/io/Serializable/GetField/Write.java			generic-all
+java/io/Serializable/PutField/Read.java				generic-all
+java/io/Serializable/PutField/Read2.java			generic-all
+java/io/Serializable/PutField/Write.java			generic-all
+java/io/Serializable/PutField/Write2.java			generic-all
+java/io/Serializable/arraySuidConflict/Read.java		generic-all
+java/io/Serializable/arraySuidConflict/Write.java		generic-all
+java/io/Serializable/backRefCNFException/Read.java		generic-all
+java/io/Serializable/backRefCNFException/Write.java		generic-all
+java/io/Serializable/class/Test.java				generic-all
+java/io/Serializable/evolution/AddedExternField/ReadAddedField.java generic-all
+java/io/Serializable/evolution/AddedExternField/WriteAddedField.java generic-all
+java/io/Serializable/evolution/AddedExternField/run.sh		generic-all
+java/io/Serializable/evolution/AddedField/ReadAddedField.java	generic-all
+java/io/Serializable/evolution/AddedField/WriteAddedField.java	generic-all
+java/io/Serializable/evolution/AddedSuperClass/ReadAddedSuperClass.java	generic-all
+java/io/Serializable/evolution/AddedSuperClass/ReadAddedSuperClass2.java generic-all
+java/io/Serializable/evolution/AddedSuperClass/WriteAddedSuperClass.java generic-all
+java/io/Serializable/proxy/skipMissing/Read.java		generic-all
+java/io/Serializable/proxy/skipMissing/Write.java		generic-all
+java/io/Serializable/readObjectNoData/Read.java			generic-all
+java/io/Serializable/readObjectNoData/Write.java		generic-all
+java/io/Serializable/skipWriteObject/Read.java			generic-all
+java/io/Serializable/skipWriteObject/Write.java			generic-all
+java/io/Serializable/skippedObjCNFException/Read.java		generic-all
+java/io/Serializable/skippedObjCNFException/Write.java		generic-all
+java/io/Serializable/stopCustomDeserialization/Read.java	generic-all
+java/io/Serializable/stopCustomDeserialization/Write.java	generic-all
+java/io/Serializable/unresolvedClassDesc/Read.java		generic-all
+java/io/Serializable/unresolvedClassDesc/Write.java		generic-all
+java/io/Serializable/unshared/Read.java				generic-all
+java/io/Serializable/unshared/Write.java			generic-all
+java/io/Serializable/wrongReturnTypes/Read.java			generic-all
+java/io/Serializable/wrongReturnTypes/Write.java		generic-all
+
+# Windows samevm issues? triggers other tests to fail, missing close() on f.txt?
+java/io/DataInputStream/OpsAfterClose.java		 	generic-all
+
+# Windows 32bit samevm failure: RuntimeException: File.getFreeSpace() failed
+java/io/File/MaxPathLength.java					generic-all
+
+# Should be othervm, or corrected for samevm, fails with samevm:
+java/io/File/DeleteOnExit.java				 	generic-all
+java/io/File/DeleteOnExitLong.java			 	generic-all
+java/io/File/DeleteOnExitNPE.java			 	generic-all
+java/io/File/IsHidden.java				 	generic-all
+java/io/FileDescriptor/FileChannelFDTest.java		 	generic-all
+java/io/FileDescriptor/Finalize.java			 	generic-all
+java/io/FileInputStream/FinalizeShdCallClose.java	 	generic-all
+
+# Known to cause samevm issues on windows, other tests fail, missing close()?
+java/io/FileInputStream/OpsAfterClose.java		 	generic-all
+
+# Should be othervm, or corrected for samevm, fails with samevm:
+java/io/FileOutputStream/FinalizeShdCallClose.java	 	generic-all
+
+# Known to cause samevm issues on windows, other tests fail, missing close()?
+java/io/FileOutputStream/OpsAfterClose.java		 	generic-all
+
+# Windows samevm issues? triggers other tests to fail, missing close() on f.txt?
+java/io/InputStream/OpsAfterClose.java			 	generic-all
+
+# Missing close() on x.ReadBounds file? Windows samevm issues
+java/io/InputStream/ReadParams.java			 	generic-all
+
+# Known to cause samevm issues on windows, other tests fail, missing close()?
+java/io/InputStreamReader/GrowAfterEOF.java		 	generic-all
+
+# Should be othervm, or corrected for samevm, fails with samevm:
+java/io/ObjectInputStream/ResolveProxyClass.java	 	generic-all
+
+# Not doing a close() on x.ParameterCheck file? windows samevm cascade error
+java/io/RandomAccessFile/ParameterCheck.java                    generic-all
+
+# Not doing a close on x.ReadLine file? windows cascade samevm problems
+java/io/RandomAccessFile/ReadLine.java				generic-all
+
+# Not doing close on file input x.WriteByteChars, windows samevm problems
+java/io/RandomAccessFile/WriteBytesChars.java			generic-all
+
+# Not doing close on file input x.WriteUTF, windows samevm problems
+java/io/RandomAccessFile/WriteUTF.java                          generic-all
+
+# Possibly, not doing a close() on input.txt, windows samevm issues.
+java/io/RandomAccessFile/skipBytes/SkipBytes.java	 	generic-all
+java/io/readBytes/MemoryLeak.java			 	generic-all
+java/io/readBytes/ReadBytesBounds.java			 	generic-all 
+
+# Missing close on fields.ser, windows samevm
+java/io/Serializable/checkModifiers/CheckModifiers.java		generic-all
+
+# Should be othervm, or corrected for samevm, fails with samevm:
+java/io/Serializable/auditStreamSubclass/AuditStreamSubclass.java generic-all
+java/io/Serializable/proxy/Basic.java			 	generic-all
+
+# Possibly not doing a close() on input.txt, windows samevm issues.
+java/io/StreamTokenizer/Comment.java			 	generic-all
+
+############################################################################
+
+# jdk_lang
+
+# Some of these tests (like java/lang/management) may just need to be marked
+#   othervm, but that is partially speculation.
+
+# Times out on solaris 10 sparc
+java/lang/ClassLoader/Assert.java				generic-all
+
+# Fedora 9 X64, RuntimeException: MyThread expected to be blocked on lock, but got null
+java/lang/management/ThreadMXBean/ThreadStateTest.java 		generic-all
+
+# RuntimeException: Uptime of the JVM is more than 30 minutes (32 minutes).
+java/lang/management/RuntimeMXBean/UpTime.java			generic-all
+
+# Times out on solaris sparc occasionally, in samevm mode
+java/lang/Runtime/exec/ExecWithDir.java				generic-all
+java/lang/ProcessBuilder/Basic.java				generic-all
+
+# Solaris sparc, samevm, java.lang.Exception: Read from closed pipe hangs
+java/lang/Runtime/exec/SleepyCat.java				generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/lang/annotation/ParameterAnnotations.java			generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/lang/ClassLoader/defineClass/DefineClassByteBuffer.java	generic-all
+java/lang/ClassLoader/findSystemClass/Loader.java		generic-all
+
+# Fedora 9 32bit, -client, samevm, Error while cleaning up threads after test
+java/lang/management/ThreadMXBean/Locks.java			generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/lang/management/ClassLoadingMXBean/LoadCounts.java		generic-all
+java/lang/management/ManagementFactory/MBeanServerMXBeanUnsupportedTest.java generic-all
+java/lang/management/ManagementFactory/MXBeanProxyTest.java	generic-all
+java/lang/management/ManagementFactory/ThreadMXBeanProxy.java	generic-all
+java/lang/management/MemoryMXBean/CollectionUsageThreshold.java	generic-all
+java/lang/management/MemoryMXBean/GetMBeanInfo.java		generic-all
+java/lang/management/MemoryMXBean/LowMemoryTest.java		generic-all
+java/lang/management/MemoryMXBean/MemoryManagement.java		generic-all
+java/lang/management/MemoryMXBean/MemoryTest.java		generic-all
+java/lang/management/MemoryMXBean/Pending.java			generic-all
+
+# Problematic on all platforms (even as othervm)
+java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java 	generic-all
+
+# Causes jtreg exit samevm issues due to non-String object in system properties
+java/lang/management/RuntimeMXBean/GetSystemProperties.java 	generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/lang/management/RuntimeMXBean/PropertiesTest.java		generic-all
+java/lang/management/ThreadMXBean/AllThreadIds.java		generic-all
+java/lang/management/ThreadMXBean/EnableTest.java		generic-all
+java/lang/management/ThreadMXBean/FindMonitorDeadlock.java	generic-all
+java/lang/management/ThreadMXBean/LockingThread.java		generic-all
+java/lang/management/ThreadMXBean/MonitorDeadlock.java		generic-all
+java/lang/management/ThreadMXBean/MyOwnSynchronizer.java	generic-all
+java/lang/management/ThreadMXBean/SharedSynchronizer.java	generic-all
+java/lang/management/ThreadMXBean/SynchronizerLockingThread.java generic-all
+java/lang/management/ThreadMXBean/ThreadCounts.java		generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/lang/reflect/Proxy/Boxing.java				generic-all
+java/lang/reflect/Proxy/ClassRestrictions.java			generic-all
+java/lang/reflect/Proxy/returnTypes/Test.java			generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/lang/Runtime/exec/LotsOfOutput.java			generic-all
+java/lang/System/ExitFinalizersAndJIT.java			generic-all
+java/lang/System/finalization/FinThreads.java			generic-all
+java/lang/System/IgnoreNullSecurityManager.java			generic-all
+java/lang/Thread/GenerifyStackTraces.java			generic-all
+java/lang/Thread/StackTraces.java				generic-all
+java/lang/ThreadGroup/Daemon.java				generic-all
+java/lang/ThreadGroup/NullThreadName.java			generic-all
+
+# Times out on solaris sparc -server
+java/lang/ThreadLocal/MemoryLeak.java			 	solaris-all
+
+# Windows X64, RuntimeException: MyThread expected to have RUNNABLE but got WAITING
+java/lang/Thread/ThreadStateTest.java				generic-all
+
+# Timeout on windows 64bit 
+java/lang/ClassLoader/deadlock/TestCrossDelegate.sh		generic-all
+
+############################################################################
+
+# jdk_management
+
+# Solaris 10 sparc, NPE from org.omg.stub.javax.management.remote.rmi._RMIConnectionImpl_Tie._invoke
+javax/management/remote/mandatory/threads/ExecutorTest.java 	generic-all
+
+# Linux 32bit Fedora 9, IllegalStateException
+javax/management/monitor/RuntimeExceptionTest.java		generic-all
+
+# Problems with rmi connection, othervm  
+javax/management/remote/mandatory/subjectDelegation/SubjectDelegation2Test.java generic-all
+
+# Fails with port already in use
+sun/management/jmxremote/bootstrap/SSLConfigFilePermissionTest.sh generic-all
+
+# Fails with port already in use
+sun/management/jmxremote/bootstrap/RmiRegistrySslTest.sh	generic-all
+
+# Windows, connection can't last that long
+javax/management/eventService/LeaseTest.java			generic-all
+
+# Linux othervm, X64, java.lang.Exception: Failed: ratio=102.4027795593753
+javax/management/remote/mandatory/notif/ListenerScaleTest.java	generic-all
+
+# Windows run seems to have triggered a hotspot gc error (see 6801625)
+com/sun/management/HotSpotDiagnosticMXBean/DumpHeap.sh		generic-all
+
+# rmi problem? othervm, java.lang.reflect.UndeclaredThrowableException
+javax/management/remote/mandatory/subjectDelegation/SubjectDelegation3Test.java generic-all
+
+# Linux Fedora 9 32bit NPE in rmi server somehere??? othervm
+javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java generic-all
+
+# Times out on solaris sparc, with othervm
+javax/management/eventService/AddRemoveListenerTest.java	generic-all
+
+# Linux i586 and x64 -server, timed out waiting for threads to expire? othervm
+javax/management/eventService/EventClientThreadTest.java	generic-all
+
+# Linux i586 -server, Expected to receive 20, but got 21, othervm
+#   Fails on Linux X64 -server 20!=21
+javax/management/eventService/FetchingTest.java			generic-all
+
+# NPE on windows 2000 i586 -client and -server
+javax/management/eventService/CustomForwarderTest.java	 	windows-all
+
+# Windows i586 failure, callback did not complete
+javax/management/eventService/LeaseManagerDeadlockTest.java 	windows-all
+
+# Port already in use
+sun/management/jmxremote/bootstrap/LocalManagementTest.sh 	generic-all
+
+# Failed to initialize connector (also overflowing jtreg io buffers)
+sun/management/jmxremote/bootstrap/RmiBootstrapTest.sh	 	generic-all
+sun/management/jmxremote/bootstrap/RmiSslBootstrapTest.sh 	generic-all
+
+# Windows X64, java.lang.IllegalStateException
+javax/management/monitor/AttributeArbitraryDataTypeTest.java	generic-all
+
+############################################################################
+
+# jdk_math
+
+# Problems with rounding add failures on solaris-sparcv9 and -server
+java/math/BigDecimal/AddTests.java			 	solaris-sparcv9
+
+# Problems on windows with samevm, missing inputstream close()?
+# Also times out on solaris-sparcv9 -server
+java/math/BigInteger/BigIntegerTest.java		 	generic-all
+
+# Should be samevm? But seems problematic with samevm on windows
+java/math/BigInteger/ModPow65537.java			 	generic-all
+
+############################################################################
+
+# jdk_misc
+
+# On Windows com.sun.java.swing.plaf.gtk does not exist, always fails there
+com/sun/java/swing/plaf/gtk/Test6635110.java		 	windows-all
+
+# Need to be marked othervm, or changed to be samevm safe
+com/sun/jndi/ldap/ReadTimeoutTest.java				generic-all
+com/sun/jndi/rmi/registry/RegistryContext/UnbindIdempotent.java	generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+com/sun/org/apache/xml/internal/security/transforms/ClassLoaderTest.java generic-all
+
+# Solaris sparc and others, exception in initializer
+javax/imageio/CachePremissionsTest/CachePermissionsTest.java 	generic-all
+
+# Leaves file rgba_* open, fails with windows samevm
+javax/imageio/plugins/png/PngOutputTypeTest.java		generic-all
+
+# Suspect test.png file is left open, windows samevm problems
+javax/imageio/plugins/png/ITXtTest.java				generic-all
+
+# Solaris sparc and others, failed to compile testcase
+javax/imageio/metadata/DOML3Node.java			 	generic-all
+
+# One of these tests is leaving file IMGP1001.JPG open, windows samevm
+javax/imageio/plugins/jpeg/ConcurrentReadingTest.java		generic-all
+javax/imageio/plugins/jpeg/ReadingInterruptionTest.java		generic-all
+
+# One of these files is missing a close on writer_* files, windows samevm
+javax/imageio/plugins/jpeg/ConcurrentWritingTest.java		generic-all
+javax/imageio/plugins/jpeg/WritingInterruptionTest.java		generic-all
+
+# Leaving file test.jpg open, windows samevm
+javax/imageio/plugins/jpeg/ReadAsGrayTest.java			generic-all
+
+# Missing close on file wbmp*, windows samevm
+javax/imageio/plugins/wbmp/CanDecodeTest.java			generic-all
+
+# Exclude all javax/print tests, even if they passed, they may need samevm work
+
+# Times out on solaris-sparc, sparcv9, x64 -server, some on i586 -client
+javax/print/attribute/autosense/PrintAutoSenseData.java 	generic-all
+javax/print/attribute/Chroma.java			 	generic-all
+javax/print/attribute/CollateAttr.java			 	generic-all
+javax/print/attribute/PSCopiesFlavorTest.java		 	generic-all
+javax/print/LookupServices.java 			 	generic-all
+javax/print/TestRaceCond.java				 	generic-all
+
+# These tests really require a printer (might all be windows only tests?)
+javax/print/CheckDupFlavor.java					generic-all
+javax/print/PrintSE/PrintSE.sh					generic-all
+javax/print/attribute/ChromaticityValues.java			generic-all
+javax/print/attribute/GetCopiesSupported.java			generic-all
+javax/print/attribute/SidesPageRangesTest.java			generic-all
+javax/print/attribute/SupportedPrintableAreas.java		generic-all
+
+# Only print test left, excluding just because all print tests have been
+javax/print/attribute/MediaMappingsTest.java 			generic-all
+
+############################################################################
+
+# jdk_net
+
+# Suspect many of these tests auffer from using fixed ports, no concrete 
+#   evidence.
+
+# Fails on OpenSolaris, BindException unexpected 
+java/net/BindException/Test.java				generic-all
+
+# Fails on OpenSolaris, times out
+java/net/MulticastSocket/SetOutgoingIf.java			generic-all
+
+# Timed out on Solaris 10 X86.
+com/sun/net/httpserver/Test3.java				generic-all
+
+# Exception in test on windows
+com/sun/net/httpserver/bugs/B6373555.java		 	windows-all
+
+# One of these pollutes the samevm on Linux, too many open files, kills jtreg
+com/sun/net/httpserver/bugs/B6339483.java			generic-all
+com/sun/net/httpserver/bugs/B6341616.java			generic-all
+
+# Suspects in cascading samevm problem, solaris 11 i586 (needs othervm?)
+#   Suspect use of setHttps*()?
+com/sun/net/httpserver/SelCacheTest.java			generic-all
+com/sun/net/httpserver/Test1.java				generic-all
+com/sun/net/httpserver/Test12.java				generic-all
+com/sun/net/httpserver/Test13.java				generic-all
+com/sun/net/httpserver/Test6a.java				generic-all
+com/sun/net/httpserver/Test7a.java				generic-all
+com/sun/net/httpserver/Test8a.java				generic-all
+com/sun/net/httpserver/Test9.java				generic-all
+com/sun/net/httpserver/Test9a.java				generic-all
+
+# 10,000 connections, fails on Linux and makes tests&jtreg fail with samevm
+com/sun/net/httpserver/bugs/B6361557.java			generic-all
+
+# Address already in use with samevm? Always? Solaris sparc, probably ports
+java/net/Authenticator/B4933582.sh				generic-all
+java/net/DatagramSocket/SendSize.java				generic-all
+
+# Solaris 11: exception wrong address???
+java/net/Inet6Address/B6558853.java				generic-all
+
+# Not closing stream on file i6a1, windows samevm problem
+java/net/Inet6Address/serialize/Serialize.java			generic-all
+
+# Linux x64 fails "network unreachable"?
+java/net/ipv6tests/TcpTest.java 			 	generic-all
+
+# Linux i586, fails with unexpected output
+java/net/MulticastSocket/NoLoopbackPackets.java 	 	linux-i586
+
+# Times out on windows x64, fails with samevm on solaris 11 i586
+java/net/ServerSocket/AcceptCauseFileDescriptorLeak.java 	generic-all
+
+# Address already in use
+java/net/DatagramSocket/DatagramTimeout.java			generic-all
+
+# Fails on windows, takes too long and fails
+#   Solaris 10 sparcv9, samevm, java.lang.Exception: Takes too long. Dead lock
+java/net/Socket/DeadlockTest.java				generic-all
+
+# Linux i586 address already in use or connection error, samevm issues
+java/net/Socket/AccurateTimeout.java			 	generic-all
+java/net/Socket/asyncClose/BrokenPipe.java		 	generic-all
+java/net/Socket/CloseAvailable.java			 	generic-all
+java/net/Socket/FDClose.java				 	generic-all
+
+# Linux X64 address already in use, samevm issues
+java/net/Socket/LingerTest.java 			 	generic-all
+java/net/Socket/LinkLocal.java				 	generic-all
+java/net/Socket/NullHost.java				 	generic-all
+java/net/Socket/ProxyCons.java				 	generic-all
+java/net/Socket/ReadTimeout.java			 	generic-all
+
+# Linux X64 address already in use, samevm issues
+java/net/Socket/SetReceiveBufferSize.java		 	generic-all
+
+# Linux i586 address already in use or connection error, samevm issues
+java/net/Socket/setReuseAddress/Basic.java		 	generic-all
+java/net/Socket/setReuseAddress/Restart.java		 	generic-all
+
+# Linux X64 address already in use, samevm issues
+java/net/Socket/SetSoLinger.java			 	generic-all
+
+# Address already in use, windows samevm
+java/net/Socket/Timeout.java					generic-all
+
+# Linux X64 address already in use, samevm issues
+java/net/Socket/ShutdownBoth.java			 	generic-all
+java/net/Socket/SoTimeout.java				 	generic-all
+java/net/Socket/TestClose.java				 	generic-all
+java/net/Socket/UrgentDataTest.java			 	generic-all
+java/net/SocketInputStream/SocketClosedException.java	 	generic-all
+java/net/SocketInputStream/SocketTimeout.java		 	generic-all
+
+# Linux i586, address already in use or timeout, samevm issues
+java/net/URLConnection/B5052093.java			 	generic-all
+java/net/URLConnection/contentHandler/UserContentHandler.java 	generic-all
+java/net/URLConnection/DisconnectAfterEOF.java		 	generic-all
+java/net/URLConnection/HandleContentTypeWithAttrs.java	 	generic-all
+java/net/URLConnection/Responses.java			 	generic-all
+java/net/URLConnection/TimeoutTest.java 		 	generic-all
+java/net/URLConnection/ZeroContentLength.java		 	generic-all
+
+# Solaris 11 i586 fails with samevm, not sure why
+java/net/Authenticator/B4769350.java				generic-all
+java/net/HttpURLConnection/HttpResponseCode.java		generic-all
+java/net/ResponseCache/B6181108.java				generic-all
+java/net/ResponseCache/ResponseCacheTest.java			generic-all
+java/net/URL/GetContent.java					generic-all
+java/net/URL/TestIPv6Addresses.java				generic-all
+java/net/URLClassLoader/HttpTest.java				generic-all
+java/net/URLConnection/HttpContinueStackOverflow.java		generic-all
+java/net/URLConnection/Redirect307Test.java			generic-all
+java/net/URLConnection/RedirectLimit.java			generic-all
+java/net/URLConnection/ResendPostBody.java			generic-all
+java/net/URL/OpenStream.java					generic-all
+java/net/URLClassLoader/ClassLoad.java				generic-all
+java/net/URLConnection/SetIfModifiedSince.java			generic-all
+java/net/URLConnection/URLConnectionHeaders.java		generic-all
+
+# Linux i586 Connection refused or address already in use, samevm issues
+sun/net/ftp/B6427768.java				 	generic-all
+sun/net/ftp/FtpGetContent.java				 	generic-all
+sun/net/ftp/FtpURL.java 				 	generic-all
+
+# Failed on solaris 10 i586, Exception: should have gotten HttpRetryException?
+sun/net/www/http/ChunkedOutputStream/Test.java			generic-all
+
+# Trouble cleaning up threads in samevm mode on solaris 11 i586
+sun/net/www/http/HttpClient/ProxyTest.java			generic-all
+sun/net/www/http/ChunkedInputStream/ChunkedEncodingTest.java	generic-all
+sun/net/www/http/ChunkedInputStream/ChunkedEncodingWithProgressMonitorTest.java	generic-all
+sun/net/www/http/HttpClient/B6726695.java			generic-all
+sun/net/www/http/HttpClient/MultiThreadTest.java		generic-all
+sun/net/www/http/KeepAliveCache/KeepAliveTimerThread.java	generic-all
+
+# Connection refused, windows samevm
+sun/net/www/protocol/http/DigestTest.java			generic-all
+
+############################################################################
+
+# jdk_nio
+
+# Suspect many of these tests auffer from using fixed ports, no concrete 
+#   evidence.
+
+# Fails on OpenSolaris, IllegalStateException: Cannot add or remove addresses 
+#    from a channel that is bound to the wildcard address
+com/sun/nio/sctp/SctpChannel/Bind.java				generic-all
+
+# Failed on OpenSolaris, java.lang.AssertionError: Unknown event type
+com/sun/nio/sctp/SctpChannel/Receive.java			generic-all
+
+# Triggers a hotspot crash on Fedora 9 32bit -server and Windows X64  samevm
+sun/nio/cs/TestUTF8.java					generic-all
+
+# Solaris sparc, socket timeout
+java/nio/channels/spi/SelectorProvider/inheritedChannel/run_tests.sh generic-all
+
+# Runtime exception on windows X64, samevm mode
+java/nio/channels/Selector/WakeupNow.java			generic-all
+
+# Occasional errors, solarix x86, address already in use, othervm mode
+java/nio/channels/Selector/SelectorTest.java			generic-all
+
+# Fails on Linux Fedora 9 X64
+sun/nio/cs/FindDecoderBugs.java					generic-all
+
+# Solaris 11 gave assert error and "connection refused", samevm issues?
+com/sun/nio/sctp/SctpServerChannel/NonBlockingAccept.java 	generic-all
+
+# Fails with othervm on solaris 11 i586
+com/sun/nio/sctp/SctpChannel/CommUp.java			generic-all
+com/sun/nio/sctp/SctpChannel/Connect.java			generic-all
+com/sun/nio/sctp/SctpMultiChannel/Branch.java			generic-all
+com/sun/nio/sctp/SctpMultiChannel/Send.java			generic-all
+com/sun/nio/sctp/SctpMultiChannel/SocketOptionTests.java	generic-all
+
+# Linux 64bit failures. too many files open
+java/nio/channels/Selector/HelperSlowToDie.java			generic-all
+
+# Timeouts etc. on Window
+java/nio/channels/AsyncCloseAndInterrupt.java		 	windows-all
+
+# Gets java.lang.ExceptionInInitializerError on windows: (Windows 2000 only?)
+java/nio/channels/AsynchronousChannelGroup/Basic.java	 	windows-5.0
+java/nio/channels/AsynchronousChannelGroup/GroupOfOne.java 	windows-5.0
+java/nio/channels/AsynchronousChannelGroup/Identity.java 	windows-5.0
+java/nio/channels/AsynchronousChannelGroup/Restart.java 	windows-5.0
+java/nio/channels/AsynchronousDatagramChannel/Basic.java 	windows-5.0
+java/nio/channels/AsynchronousFileChannel/Lock.java	 	windows-5.0
+java/nio/channels/AsynchronousServerSocketChannel/Basic.java 	windows-5.0
+java/nio/channels/AsynchronousServerSocketChannel/WithSecurityManager.java windows-5.0
+java/nio/channels/AsynchronousSocketChannel/Basic.java	 	windows-5.0
+java/nio/channels/AsynchronousSocketChannel/DieBeforeComplete.java windows-5.0
+java/nio/channels/AsynchronousSocketChannel/Leaky.java	 	windows-5.0
+java/nio/channels/AsynchronousSocketChannel/StressLoopback.java windows-5.0
+java/nio/channels/Channels/Basic2.java			 	windows-5.0
+
+# Solaris sparc timeout
+java/nio/channels/DatagramChannel/Connect.java		 	generic-all
+
+# Solaris i586 timeouts
+java/nio/channels/DatagramChannel/EmptyBuffer.java	 	solaris-all
+
+# Failed loopback connection? On windows 32bit? 
+#   Considered a stress test, can consume all resources.
+java/nio/channels/Selector/LotsOfChannels.java		 	generic-all
+
+# Solaris sparcv9, just fails with exception
+java/nio/channels/Selector/OpRead.java			 	solaris-sparc
+
+# Windows i586 client, crashed hotspot? Unpredictable
+#   Considered a stress test, can consume all resources.
+java/nio/channels/Selector/RegAfterPreClose.java	 	generic-all
+
+# Solaris i586, cannot assign address, samevm issues
+java/nio/channels/Selector/SelectorLimit.java		 	generic-all
+
+# Socket timeout windows X64
+java/nio/channels/ServerSocketChannel/AdaptServerSocket.java 	windows-all
+
+# Timeouts etc. on Window
+java/nio/channels/SocketChannel/ConnectState.java	 	windows-all
+java/nio/channels/SocketChannel/FinishConnect.java	 	windows-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/nio/channels/SocketChannel/OpenLeak.java			generic-all
+
+# Gets java.net.BindException alot (static port number?)
+java/nio/channels/SocketChannel/VectorIO.java		 	generic-all
+
+# Solaris i586 java.net.BindExceptions
+java/nio/channels/SocketChannel/VectorParams.java	 	solaris-all
+
+# Linux i586 address already in use, samevm issues
+java/nio/channels/SocketChannel/Write.java		 	generic-all
+
+# Fails on all platforms due to overlap of JDK jar file contents:
+sun/nio/cs/Test4200310.sh				 	generic-all
+
+# Depends on motif packages that do not exist all the time:
+sun/nio/cs/TestX11CNS.java				 	generic-all
+
+############################################################################
+
+# jdk_rmi
+
+# Port already in use, fails on sparc, othervm
+java/rmi/reliability/benchmark/runRmiBench.sh			generic-all
+
+# Already in use port issues? othervm solaris
+java/rmi/activation/rmidViaInheritedChannel/InheritedChannelNotServerSocket.java generic-all
+java/rmi/activation/rmidViaInheritedChannel/RmidViaInheritedChannel.java generic-all
+
+# Address already in use, othervm mode, solaris
+java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java	generic-all
+java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java	generic-all
+
+# Registry already running on port, solaris
+java/rmi/Naming/legalRegistryNames/LegalRegistryNames.java	generic-all
+
+# Fails on Linux 32 and 64bit -server?, impl not garbage collected???
+java/rmi/transport/pinLastArguments/PinLastArguments.java	generic-all
+
+# Times out on solaris sparc
+java/rmi/server/RemoteServer/AddrInUse.java			generic-all
+
+# Connection error on Windows i586 -server
+#  Also connection errors in othervm on Solaris 10 sparc, same port??? 
+sun/rmi/transport/tcp/DeadCachedConnection.java 	 	generic-all
+
+# Connection errors in othervm on Solaris 10 sparc, same port??? 
+java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java generic-all
+java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java generic-all
+java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java generic-all
+java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java generic-all
+java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java generic-all
+java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java generic-all
+java/rmi/activation/Activatable/extLoadedImpl/ext.sh generic-all
+java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java generic-all
+java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java generic-all
+java/rmi/activation/Activatable/nestedActivate/NestedActivate.java generic-all
+java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java generic-all
+java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java generic-all
+java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java generic-all
+java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java generic-all
+java/rmi/activation/ActivateFailedException/activateFails/ActivateFails.java generic-all
+java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java generic-all
+java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java generic-all
+java/rmi/reliability/juicer/AppleUserImpl.java generic-all
+java/rmi/server/RMISocketFactory/useSocketFactory/unicast/UseCustomSocketFactory.java generic-all
+java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java generic-all
+java/rmi/transport/handshakeTimeout/HandshakeTimeout.java generic-all
+java/rmi/activation/Activatable/restartService/RestartService.java generic-all
+java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java generic-all
+java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java generic-all
+java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java generic-all
+java/rmi/activation/CommandEnvironment/SetChildEnv.java generic-all
+java/rmi/registry/classPathCodebase/ClassPathCodebase.java generic-all
+java/rmi/registry/reexport/Reexport.java generic-all
+java/rmi/server/Unreferenced/finiteGCLatency/FiniteGCLatency.java generic-all
+java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java generic-all
+java/rmi/server/Unreferenced/unreferencedContext/UnreferencedContext.java generic-all
+java/rmi/server/useCustomRef/UseCustomRef.java generic-all
+java/rmi/transport/checkFQDN/CheckFQDN.java generic-all
+java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java generic-all
+java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java generic-all
+java/rmi/server/RMISocketFactory/useSocketFactory/registry/UseCustomSocketFactory.java generic-all
+java/rmi/server/UnicastRemoteObject/unexportObject/UnexportLeak.java generic-all
+
+############################################################################
+
+# jdk_security
+
+# Run too slow on Solaris 10 sparc
+sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/SSLSocketTimeoutNulls.java solaris-sparc
+sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ClientTimeout.java solaris-sparc
+sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/ServerTimeout.java solaris-sparc
+sun/security/ssl/sun/net/www/protocol/https/HttpsURLConnection/ReadTimeout.java solaris-sparc
+sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/NotifyHandshakeTest.sh solaris-sparc
+sun/security/tools/keytool/AltProviderPath.sh 			solaris-sparc
+
+# Solaris 10 sparc, passed/failed confusion? java.security.ProviderException: update() failed
+sun/security/ssl/com/sun/net/ssl/internal/ssl/SSLSocketImpl/AsyncSSLSocketClose.java generic-all
+
+# Seem really slow on Solaris sparc, being excluded just for timing reasons
+sun/security/tools/jarsigner/AlgOptions.sh			solaris-sparc
+sun/security/tools/jarsigner/nameclash.sh			solaris-sparc
+sun/security/krb5/auto/basic.sh					solaris-sparc
+sun/security/provider/PolicyFile/getinstance/getinstance.sh	solaris-sparc
+sun/security/tools/jarsigner/samename.sh			solaris-sparc
+
+# Timed out, Solaris 10 64bit sparcv9
+com/sun/crypto/provider/Cipher/DES/PaddingTest.java		generic-all
+
+# Othervm, sparc, NoRouteToHostException: Cannot assign requested address
+sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all
+
+# ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
+#    Does not seem to run on windows machines? dll missing? 
+sun/security/pkcs11/rsa/TestKeyPairGenerator.java		generic-all
+
+# Times out on windows X64, othervm mode
+#    Solaris sparc and sparcv9 -server, timeout
+sun/security/ssl/javax/net/ssl/NewAPIs/SessionTimeOutTests.java	generic-all
+
+# Failed on solaris 10 sparc, othervm mode,  "js.jks: No such file or directory"
+#  Also, cannot verify signature on solaris i586 -server
+sun/security/tools/jarsigner/concise_jarsigner.sh		generic-all
+
+# Various failures on Linux Fedora 9 X64, othervm mode
+lib/security/cacerts/VerifyCACerts.java				generic-all
+sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/TestAllSuites.java generic-all
+sun/security/ssl/sanity/ciphersuites/CheckCipherSuites.java	generic-all
+sun/security/tools/jarsigner/oldsig.sh				generic-all
+
+# Various failures on Linux Fedora 9 X64, othervm mode
+#   Does not seem to run on windows machines? dll missing? 
+sun/security/ssl/sanity/interop/ClientJSSEServerJSSE.java	generic-all
+
+# Linux i586 -server, buffer too short to hold shared secret?
+com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java	generic-all
+
+# Solaris sparcv9: Failed to parse input emptysubject.jks: No such file or directory
+sun/security/tools/keytool/emptysubject.sh			generic-all
+
+# Timeout on solaris-sparcv9 or exception thrown
+com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java	 	solaris-all
+
+# File 6535697.test input stream left open? windows samevm
+java/security/cert/CertificateFactory/openssl/OpenSSLCert.java	generic-all
+
+# Leaving file open: SerialVersion.current, windows samevm
+java/security/BasicPermission/SerialVersion.java		generic-all
+
+# Solaris 11 i586, these all fail with samevm, need to be othervm???
+java/security/BasicPermission/NullOrEmptyName.java		generic-all
+
+# Suspect missing close() on file PermClass.current, windows samevm cascade
+java/security/BasicPermission/PermClass.java			generic-all
+
+# Solaris 11 i586, these all fail with samevm, need to be othervm???
+java/security/KeyPairGenerator/Failover.java			generic-all
+java/security/Provider/DefaultPKCS11.java			generic-all
+java/security/SecureClassLoader/DefineClassByteBuffer.java	generic-all
+java/security/SecureRandom/GetAlgorithm.java			generic-all
+java/security/Security/removing/RemoveProviders.java		generic-all
+java/security/Signature/ByteBuffers.java			generic-all
+java/security/Signature/NONEwithRSA.java			generic-all
+java/security/Signature/SignWithOutputBuffer.java		generic-all
+java/security/Signature/TestInitSignWithMyOwnRandom.java	generic-all
+java/security/UnresolvedPermission/AccessorMethods.java		generic-all
+java/security/UnresolvedPermission/Equals.java			generic-all
+
+# Do not seem to run on windows machines? dll missing? 
+sun/security/krb5/auto/IgnoreChannelBinding.java	 	windows-all
+
+# Fails on OpenSolaris, missing classes, slow on Solaris sparc
+sun/security/ec/TestEC.java					generic-all
+
+# Problems with windows x64
+sun/security/mscapi/IsSunMSCAPIAvailable.sh		 	windows-x64
+sun/security/mscapi/RSAEncryptDecrypt.sh		 	windows-x64
+
+# Do not seem to run on windows machines? dll missing? 
+sun/security/pkcs11/Cipher/ReinitCipher.java		 	windows-all
+sun/security/pkcs11/Cipher/TestRSACipher.java		 	windows-all
+sun/security/pkcs11/Cipher/TestRSACipherWrap.java	 	windows-all
+sun/security/pkcs11/Cipher/TestSymmCiphers.java 	 	windows-all
+sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java	 	windows-all
+
+# Do not seem to run on windows machines? dll missing? 
+sun/security/pkcs11/ec/ReadCertificates.java		 	windows-all
+sun/security/pkcs11/ec/ReadPKCS12.java			 	windows-all
+sun/security/pkcs11/ec/TestCurves.java			 	windows-all
+sun/security/pkcs11/ec/TestECDH.java			 	windows-all
+sun/security/pkcs11/ec/TestECDSA.java			 	windows-all
+sun/security/pkcs11/ec/TestECGenSpec.java		 	windows-all
+sun/security/pkcs11/ec/TestKeyFactory.java		 	windows-all
+sun/security/pkcs11/fips/TrustManagerTest.java		 	windows-all
+
+# Do not seem to run on windows machines? dll missing? 
+sun/security/pkcs11/KeyAgreement/TestShort.java 	 	windows-all
+sun/security/pkcs11/KeyGenerator/DESParity.java 	 	windows-all
+
+# Exception in test solaris-sparc -client -server, no windows
+sun/security/pkcs11/KeyGenerator/TestKeyGenerator.java	windows-all solaris-all
+
+# Do not seem to run on windows machines? dll missing? 
+sun/security/pkcs11/KeyStore/Basic.sh			 	windows-all
+sun/security/pkcs11/KeyStore/ClientAuth.sh		 	windows-all
+
+# Solaris sparc client, fails to compile?
+sun/security/pkcs11/KeyStore/SecretKeysBasic.sh 	 	solaris-all
+
+# Do not seem to run on windows machines? dll missing? 
+sun/security/pkcs11/Mac/ReinitMac.java			 	windows-all
+sun/security/pkcs11/MessageDigest/ByteBuffers.java	 	windows-all
+sun/security/pkcs11/MessageDigest/DigestKAT.java	 	windows-all
+sun/security/pkcs11/MessageDigest/ReinitDigest.java	 	windows-all
+sun/security/pkcs11/Provider/ConfigQuotedString.sh	 	windows-all
+sun/security/pkcs11/Provider/Login.sh			 	windows-all
+sun/security/pkcs11/rsa/KeyWrap.java			 	windows-all
+sun/security/pkcs11/rsa/TestCACerts.java		 	windows-all
+sun/security/pkcs11/rsa/TestKeyFactory.java		 	windows-all
+sun/security/pkcs11/rsa/TestSignatures.java		 	windows-all
+sun/security/pkcs11/SampleTest.java			 	windows-all
+sun/security/pkcs11/Secmod/AddPrivateKey.java		 	windows-all
+sun/security/pkcs11/Secmod/AddTrustedCert.java		 	windows-all
+sun/security/pkcs11/Secmod/Crypto.java			 	windows-all
+sun/security/pkcs11/Secmod/GetPrivateKey.java		 	windows-all
+sun/security/pkcs11/Secmod/JksSetPrivateKey.java	 	windows-all
+sun/security/pkcs11/Secmod/TrustAnchors.java		 	windows-all
+sun/security/pkcs11/SecureRandom/Basic.java		 	windows-all
+sun/security/pkcs11/Serialize/SerializeProvider.java	 	windows-all
+sun/security/pkcs11/Signature/ByteBuffers.java		 	windows-all
+sun/security/pkcs11/Signature/ReinitSignature.java	 	windows-all
+sun/security/pkcs11/Signature/TestDSA.java		 	windows-all
+sun/security/pkcs11/tls/TestKeyMaterial.java		 	windows-all
+sun/security/pkcs11/tls/TestMasterSecret.java		 	windows-all
+sun/security/pkcs11/tls/TestPremaster.java		 	windows-all
+sun/security/pkcs11/tls/TestPRF.java			 	windows-all
+
+# Fails on OpenSolaris java.net.BindException: Address already in use
+sun/security/pkcs11/sslecc/ClientJSSEServerJSSE.java		generic-all
+
+# Timeout on solaris-sparcv9 or ArrayIndexOutOfBoundsException?
+sun/security/rsa/TestKeyPairGeneratorLength.java	 	solaris-all
+sun/security/rsa/TestSignatures.java			 	solaris-all
+
+# Timeout on solaris-sparc and i586 and x64, -client and -server
+sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/InterruptedIO.java solaris-all
+
+# Do not seem to run on windows machines? dll missing? 
+sun/security/tools/jarsigner/emptymanifest.sh		 	windows-all
+
+# Files does not exist or no encoding? solaris-sparcv9
+sun/security/tools/keytool/importreadall.sh		 	solaris-all
+sun/security/tools/keytool/selfissued.sh		 	solaris-all
+
+############################################################################
+
+# jdk_swing (not using samevm)
+
+# Fails on solaris 10 sparc, throws RuntimeException that just says "failed"
+javax/swing/JLabel/6501991/bug6501991.java			generic-all
+
+# Fails on solaris 11 i586, with othervm
+javax/swing/JFileChooser/6570445/bug6570445.java		generic-all
+javax/swing/JFileChooser/6738668/bug6738668.java		generic-all
+javax/swing/JPopupMenu/6675802/bug6675802.java			generic-all
+javax/swing/system/6799345/TestShutdown.java			generic-all
+
+############################################################################
+
+# jdk_text
+
+# Linux x64 occasional errors, no details
+java/text/Bidi/Bug6665028.java				 	linux-x64
+
+############################################################################
+
+# jdk_tools
+
+# Some of the tools tests kind of require "othervm" or if they don't will
+#  always be firing up another VM anyway due to the nature of tools testing.
+#  So most if not all tools tests are now being run with "othervm" mode.
+#  Some of these tools tests have a tendency to use fixed ports, bad idea.
+
+# Solaris 10 client x86, java.lang.IndexOutOfBoundsException resumer Interrupted
+com/sun/jdi/SimulResumerTest.java				generic-all
+
+# Output of jps differs from expected output.
+#   Invalid argument count on solaris-sparc and x64
+sun/tools/jstatd/jstatdPort.sh					generic-all
+
+# othervm mode, Could not synchronize with target
+sun/tools/jps/jps-l_1.sh					generic-all
+sun/tools/jps/jps-l_2.sh					generic-all
+sun/tools/jps/jps-lm.sh						generic-all
+sun/tools/jps/jps-Vvml_2.sh					generic-all
+sun/tools/jps/jps-m_2.sh					generic-all
+
+# Server name error, port 2098 problem?
+sun/tools/jstatd/jstatdServerName.sh				generic-all
+
+# Solaris, handshake failed, othervm mode
+com/sun/jdi/RedefineException.sh				generic-all
+
+# These tests fail on solaris sparc, all the time
+com/sun/servicetag/DeleteServiceTag.java			generic-all
+com/sun/servicetag/DuplicateNotFound.java			generic-all
+com/sun/servicetag/FindServiceTags.java				generic-all
+com/sun/servicetag/InstanceUrnCheck.java			generic-all
+com/sun/servicetag/InvalidRegistrationData.java			generic-all
+com/sun/servicetag/InvalidServiceTag.java			generic-all
+com/sun/servicetag/JavaServiceTagTest.java			generic-all
+com/sun/servicetag/JavaServiceTagTest1.java			generic-all
+com/sun/servicetag/NewRegistrationData.java			generic-all
+com/sun/servicetag/SystemRegistryTest.java			generic-all
+com/sun/servicetag/TestLoadFromXML.java				generic-all
+com/sun/servicetag/UpdateServiceTagTest.java			generic-all
+com/sun/servicetag/ValidRegistrationData.java			generic-all
+
+# Problems on windows, jmap.exe hangs?
+com/sun/tools/attach/BasicTests.sh				windows-all
+
+# Fails on Solaris 10 sparc, in othervm mode, throws unexpected exception
+sun/jvmstat/monitor/MonitoredVm/CR6672135.java			generic-all
+
+# Unexpected Monitor Exception, solaris sparc -client
+sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.sh	generic-all
+
+# Probably should be samevm, but seem to cause errors even in othervm at times
+sun/tools/jhat/HatHeapDump1Test.java			 	generic-all
+
+# Problems on windows, jmap.exe hangs? (these run jmap)
+sun/tools/jmap/Basic.sh						windows-all
+
+# Invalid argument count on solaris-sparc and x64
+sun/tools/jstatd/jstatdDefaults.sh			 	solaris-all
+
+# Solaris sparcv9, jps output does not match, x64 different
+sun/tools/jstatd/jstatdExternalRegistry.sh		 	solaris-all
+
+# Probably should be samevm, but seem to cause errors even in othervm at times
+sun/tools/native2ascii/NativeErrors.java		 	generic-all
+
+# Solaris 10 sparc 32bit -client, java.lang.AssertionError: Some tests failed
+tools/jar/JarEntryTime.java					generic-all
+
+# Times out on sparc?
+tools/launcher/VersionCheck.java				generic-all
+
+# These tests fail on solaris sparc, all the time
+tools/jar/ChangeDir.java					generic-all
+
+# Cannot write jar
+#  Also, possible problems on windows, jmap.exe hangs? 
+tools/jar/index/MetaInf.java				 	windows-all
+
+############################################################################
+
+# jdk_util
+
+# Assert error, failures, on Linux Fedora 9 -server
+#   Windows samevm failure, assert error "Passed = 134, failed = 2"
+java/util/Arrays/ArrayObjectMethods.java			generic-all
+
+# Windows 2000, -client, samevm, java.lang.Error: Completed != 2
+java/util/concurrent/locks/ReentrantLock/CancelledLockLoops.java generic-all
+
+# Windows X64, Executor Stuck samevm mode:
+java/util/concurrent/FutureTask/BlockingTaskExecutor.java	generic-all
+
+# Problems on windows, jmap.exe hangs? (these run jmap), fails on Solaris 10 x86
+java/util/concurrent/locks/Lock/TimedAcquireLeak.java		generic-all
+
+# Solaris sparc client, some failures, "1 not equal to 3"?
+#   also Linux problems with samevm mode, -server linux i586? 1 not equal to 3?
+java/util/concurrent/Executors/AutoShutdown.java		generic-all
+
+# Fails on solaris-sparc -server (Set not equal to copy. 1)
+java/util/EnumSet/EnumSetBash.java			 	solaris-sparc
+
+# Failing to close an input stream? "foo", triggers samevm windows failures
+java/util/Formatter/Constructors.java				generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/util/Locale/Bug4175998Test.java				generic-all
+java/util/Locale/Bug4184873Test.java				generic-all
+java/util/Locale/LocaleTest.java				generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/util/logging/GetGlobalTest.java				generic-all
+java/util/logging/LoggerSubclass.java				generic-all
+java/util/logging/LoggingDeadlock.java				generic-all
+java/util/logging/LoggingDeadlock2.java 			generic-all
+java/util/logging/LoggingMXBeanTest.java			generic-all
+java/util/logging/LoggingMXBeanTest2.java			generic-all
+java/util/logging/LoggingNIOChange.java 			generic-all
+java/util/logging/ParentLoggersTest.java			generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/util/ResourceBundle/Bug4168625Test.java			generic-all
+java/util/ResourceBundle/Bug6359330.java			generic-all
+java/util/ResourceBundle/TestBug4179766.java			generic-all
+
+# Need to be marked othervm, or changed to be samevm safe
+java/util/WeakHashMap/GCDuringIteration.java			generic-all
+
+# Possible missing input stream close()? Causes samevm issues on windows
+java/util/zip/InfoZip.java				 	generic-all
+
+# Missing a close() on file Test0.zip? windows samevm cascade problem
+java/util/zip/ZipFile/Comment.java                              generic-all
+
+# Suspect missing close() on bad*.zip files, windows cascade errors with samevm
+java/util/zip/ZipFile/CorruptedZipFiles.java			generic-all
+
+# Should be samevm but causes problems with samevm, no details:
+java/util/zip/ZipFile/ManyEntries.java			 	generic-all
+
+############################################################################
+
--- a/test/com/sun/jdi/ShellScaffold.sh	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/com/sun/jdi/ShellScaffold.sh	Wed Nov 25 11:08:25 2009 -0800
@@ -307,7 +307,7 @@
              #The alternative would be to use /usr/bin/pargs [pid] to get
              #all the args for a process, splice them back into one
              #long string, then grep.
-             UU=`/usr/bin/id -un`
+             UU=`/usr/xpg4/bin/id -u -n`
              psCmd="pgrep -f -l -U $UU"
          else
              ulimit -c 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/management/HotSpotDiagnosticMXBean/SetAllVMOptions.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2005-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     6858708
+ * @summary Basic Test for HotSpotDiagnosticMXBean.setVMOption()
+ * @author  Tomas Hurka, Daniel Fuchs
+ *
+ * @run main SetAllVMOptions
+ */
+
+import com.sun.management.HotSpotDiagnosticMXBean;
+import com.sun.management.VMOption;
+import java.lang.management.ManagementFactory;
+import java.util.List;
+import javax.management.MBeanServer;
+
+public class SetAllVMOptions {
+    private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
+        "com.sun.management:type=HotSpotDiagnostic";
+
+    public static void main(String[] args) throws Exception {
+        List<HotSpotDiagnosticMXBean> list =
+            ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
+        HotSpotDiagnosticMXBean mbean = list.get(0);
+        setAllVMOptions(mbean);
+
+        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
+                    HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
+                    HotSpotDiagnosticMXBean.class);
+        setAllVMOptions(mbean);
+    }
+
+    private static void setAllVMOptions(HotSpotDiagnosticMXBean mbean) {
+        List<VMOption> options = mbean.getDiagnosticOptions();
+        for (VMOption opt : options) {
+            String name = opt.getName();
+            String val = opt.getValue();
+            System.out.println("option: "+name+"="+val);
+            mbean.setVMOption(name,val);
+        }
+    }
+}
--- a/test/demo/jvmti/DemoRun.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/demo/jvmti/DemoRun.java	Wed Nov 25 11:08:25 2009 -0800
@@ -145,7 +145,7 @@
          */
         int nvm_options = 0;
         if ( vm_options != null ) nvm_options = vm_options.length;
-        String cmd[]     = new String[1 + (d64?1:0) + 5 + nvm_options];
+        String cmd[]     = new String[1 + (d64?1:0) + 7 + nvm_options];
         String cmdLine;
         int exitStatus;
         int i,j;
@@ -154,6 +154,10 @@
         cmdLine = "";
         cmdLine += (cmd[i++] = java);
         cmdLine += " ";
+        cmdLine += (cmd[i++] = "-cp");
+        cmdLine += " ";
+        cmdLine += (cmd[i++] = cdir);
+        cmdLine += " ";
         cmdLine += (cmd[i++] = "-Dtest.classes=" + cdir);
         if ( d64 ) {
             cmdLine += " ";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/Container/ValidateRoot/InvalidateMustRespectValidateRoots.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,114 @@
+/*
+ * 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 6852592
+  @summary invalidate() must stop when it encounters a validate root
+  @author anthony.petrov@sun.com
+  @run main InvalidateMustRespectValidateRoots
+*/
+
+import javax.swing.*;
+import java.awt.event.*;
+
+public class InvalidateMustRespectValidateRoots {
+    private static volatile JRootPane rootPane;
+
+    public static void main(String args[]) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                // The JRootPane is a validate root. We'll check if
+                // invalidate() stops on the root pane, or goes further
+                // up to the frame.
+                JFrame frame = new JFrame();
+                final JButton button = new JButton();
+
+                frame.add(button);
+
+                // To enable running the test manually: use the Ctrl-Shift-F1
+                // to print the component hierarchy to the console
+                button.addActionListener(new ActionListener() {
+                    public void actionPerformed(ActionEvent ev) {
+                        if (button.isValid()) {
+                            button.invalidate();
+                        } else {
+                            button.revalidate();
+                        }
+                    }
+                });
+
+                rootPane = frame.getRootPane();
+
+                // Now the component hierarchy looks like:
+                // frame
+                // --> rootPane
+                //     --> layered pane
+                //         --> content pane
+                //             --> button
+
+                // Make all components valid first via showing the frame
+                // We have to make the frame visible. Otherwise revalidate() is
+                // useless (see RepaintManager.addInvalidComponent()).
+                frame.pack(); // To enable running this test manually
+                frame.setVisible(true);
+
+                if (!frame.isValid()) {
+                    throw new RuntimeException(
+                            "setVisible(true) failed to validate the frame");
+                }
+
+                // Now invalidate the button
+                button.invalidate();
+
+                // Check if the 'valid' status is what we expect it to be
+                if (rootPane.isValid()) {
+                    throw new RuntimeException(
+                            "invalidate() failed to invalidate the root pane");
+                }
+
+                if (!frame.isValid()) {
+                    throw new RuntimeException(
+                            "invalidate() invalidated the frame");
+                }
+
+                // Now validate the hierarchy again
+                button.revalidate();
+
+                // Now let the validation happen on the EDT
+            }
+        });
+
+        Thread.sleep(1000);
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                // Check if the root pane finally became valid
+                if (!rootPane.isValid()) {
+                    throw new RuntimeException(
+                            "revalidate() failed to validate the hierarchy");
+                }
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/GraphicsDevice/CloneConfigsTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,118 @@
+/*
+ * 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     6822057
+ *
+ * @summary Test verifies that list of supported graphics configurations
+ *          can not be changed via modification of elements of an array
+ *          returned by getConfiguration() method.
+ *
+ * @run     main CloneConfigsTest
+ * @run     main/othervm -Dsun.java2d.opengl=True CloneConfigsTest
+ * @run     main/othervm -Dsun.java2d.d3d=true CloneConfigsTest
+ * @run     main/othervm -Dsun.java2d.noddraw=true CloneConfigsTest
+ */
+
+import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Rectangle;
+import java.awt.geom.AffineTransform;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+
+public class CloneConfigsTest {
+
+    public static void main(String[] args) {
+        GraphicsEnvironment env =
+                GraphicsEnvironment.getLocalGraphicsEnvironment();
+
+        GraphicsDevice[] devices = env.getScreenDevices();
+
+        GraphicsConfiguration c = new TestConfig();
+
+        for (GraphicsDevice gd : devices) {
+            System.out.println("Device: " + gd);
+
+            GraphicsConfiguration[] configs = gd.getConfigurations();
+
+            for (int i = 0; i < configs.length; i++) {
+                GraphicsConfiguration gc  = configs[i];
+                System.out.println("\tConfig: " + gc);
+
+                configs[i] = c;
+            }
+
+            // verify whether array of configs was modified
+            configs = gd.getConfigurations();
+            for (GraphicsConfiguration gc : configs) {
+                if (gc == c) {
+                    throw new RuntimeException("Test failed.");
+                }
+            }
+            System.out.println("Test passed.");
+        }
+    }
+
+    private static class TestConfig extends GraphicsConfiguration {
+
+        @Override
+        public GraphicsDevice getDevice() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public BufferedImage createCompatibleImage(int width, int height) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public ColorModel getColorModel() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public ColorModel getColorModel(int transparency) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public AffineTransform getDefaultTransform() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public AffineTransform getNormalizingTransform() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public Rectangle getBounds() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/event/InvocationEvent/InvocationEventTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,68 @@
+/*
+ * 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 6852111
+  @summary Unhandled 'spurious wakeup' in java.awt.EventQueue.invokeAndWait()
+  @author dmitry.cherepanov@sun.com: area=awt.event
+  @run main InvocationEventTest
+*/
+
+/**
+ * InvocationEventTest.java
+ *
+ * summary: Tests new isDispatched method of the InvocationEvent class
+ */
+
+import java.awt.*;
+import java.awt.event.*;
+
+public class InvocationEventTest
+{
+    public static void main(String []s) throws Exception
+    {
+        Toolkit tk = Toolkit.getDefaultToolkit();
+        Runnable runnable = new Runnable() {
+            public void run() {
+            }
+        };
+        Object lock = new Object();
+        InvocationEvent event = new InvocationEvent(tk, runnable, lock, true);
+
+        if (event.isDispatched()) {
+            throw new RuntimeException(" Initially, the event shouldn't be dispatched ");
+        }
+
+        synchronized(lock) {
+            tk.getSystemEventQueue().postEvent(event);
+            while(!event.isDispatched()) {
+                lock.wait();
+            }
+        }
+
+        if(!event.isDispatched()) {
+            throw new RuntimeException(" Finally, the event should be dispatched ");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/font/NumericShaper/EqualsTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 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 6842557
+ * @summary confirm that an instance which is created with new Enum ranges is
+ * equivalent to another instance which is created with equivalent traditional
+ * ranges or the same Enum ranges.
+ */
+
+import java.awt.font.NumericShaper;
+import java.util.EnumSet;
+import static java.awt.font.NumericShaper.*;
+
+public class EqualsTest {
+    public static void main(String[] args) {
+        NumericShaper ns1 = getContextualShaper(ARABIC | TAMIL, TAMIL);
+        NumericShaper ns2 = getContextualShaper(
+                                EnumSet.of(Range.ARABIC, Range.TAMIL),
+                                Range.TAMIL);
+        NumericShaper ns3 = getContextualShaper(
+                                EnumSet.of(Range.ARABIC, Range.TAMIL),
+                                Range.TAMIL);
+        NumericShaper ns4 = getContextualShaper(
+                                EnumSet.of(Range.ARABIC, Range.TAMIL),
+                                Range.ARABIC);
+
+        if (!ns1.equals(ns2)) {
+            throw new RuntimeException("ns1 != ns2: ns1=" + ns1 + ", ns2=" + ns2);
+        }
+        if (!ns2.equals(ns1)) {
+            throw new RuntimeException("ns2 != ns1: ns1=" + ns1 + ", ns2=" + ns2);
+        }
+        if (!ns2.equals(ns3)) {
+            throw new RuntimeException("ns2 != ns3: ns2=" + ns2 + ", ns3=" + ns3);
+        }
+        if (ns1.equals(ns4)) {
+            throw new RuntimeException("ns1 == ns4: ns1=" + ns1 + ", ns4=" + ns4);
+        }
+        if (ns2.equals(ns4)) {
+            throw new RuntimeException("ns2 == ns4: ns2=" + ns2 + ", ns4=" + ns4);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/font/NumericShaper/MTTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 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 6843181
+ * @summary Confirm that NumericShaper is thread-safe.
+ * @run main/timeout=300/othervm MTTest
+ */
+
+import java.awt.font.NumericShaper;
+import java.util.Arrays;
+import java.util.EnumSet;
+import static java.awt.font.NumericShaper.*;
+
+public class MTTest {
+    static volatile boolean runrun = true;
+    static volatile boolean err = false;
+
+    final static String text = "-123 (English) 456.00 (Arabic) \u0641\u0642\u0643 -789 (Thai) \u0e01\u0e33 01.23";
+    static char[] t1, t2;
+    static NumericShaper ns1, ns2, ns3, ns4;
+
+    public static void main(String[] args) {
+        System.out.println("   original: " + text);
+        ns1 = getContextualShaper(EnumSet.of(Range.ARABIC), Range.ARABIC);
+        t1 = text.toCharArray();
+        ns1.shape(t1, 0, t1.length);
+        System.out.println("expected t1: " + String.valueOf(t1));
+
+        ns2 = getContextualShaper(EnumSet.of(Range.THAI), Range.THAI);
+        t2 = text.toCharArray();
+        ns2.shape(t2, 0, t2.length);
+        System.out.println("expected t2: " + String.valueOf(t2));
+
+        ns3 = getContextualShaper(ARABIC, ARABIC);
+        ns4 = getContextualShaper(THAI, THAI);
+
+        Thread th1 = new Thread(new Work(ns1, t1));
+        Thread th2 = new Thread(new Work(ns2, t2));
+        Thread th3 = new Thread(new Work(ns1, t1));
+        Thread th4 = new Thread(new Work(ns2, t2));
+        Thread th5 = new Thread(new Work(ns3, t1));
+        Thread th6 = new Thread(new Work(ns4, t2));
+        Thread th7 = new Thread(new Work(ns3, t1));
+        Thread th8 = new Thread(new Work(ns4, t2));
+
+        th1.start();
+        th2.start();
+        th3.start();
+        th4.start();
+        th5.start();
+        th6.start();
+        th7.start();
+        th8.start();
+
+        try {
+            for (int i = 0; runrun && i < 180; i++) {
+                Thread.sleep(1000); // 1 seconds
+            }
+            runrun = false;
+            th1.join();
+            th2.join();
+            th3.join();
+            th4.join();
+            th5.join();
+            th6.join();
+            th7.join();
+            th8.join();
+        }
+        catch (InterruptedException e) {
+        }
+
+        if (err) {
+            throw new RuntimeException("Thread-safe test failed.");
+        }
+    }
+
+    private static class Work implements Runnable {
+        NumericShaper ns;
+        char[] expectedText;
+
+        Work(NumericShaper ns, char[] expectedText) {
+            this.ns = ns;
+            this.expectedText = expectedText;
+
+        }
+
+        public void run() {
+            int count = 0;
+            while (runrun) {
+                char[] t = text.toCharArray();
+                try {
+                    count++;
+                    ns.shape(t, 0, t.length);
+                } catch (Exception e) {
+                    System.err.println("Error: Unexpected exception: " + e);
+                    runrun = false;
+                    err = true;
+                    return;
+                }
+                if (!Arrays.equals(t, expectedText)) {
+                    System.err.println("Error: shape() returned unexpected value: ");
+                    System.err.println("count = " + count);
+                    System.err.println("   expected: " + String.valueOf(expectedText));
+                    System.err.println("        got: " + String.valueOf(t));
+                    runrun = false;
+                    err = true;
+                    return;
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/awt/font/NumericShaper/ShapingTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 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 6842557
+ * @summary confirm that shaping works as expected. (Mainly for new characters which were added in Unicode 5)
+ * used where appropriate.
+ */
+
+import java.awt.font.NumericShaper;
+import java.util.EnumSet;
+import static java.awt.font.NumericShaper.*;
+
+public class ShapingTest {
+    public static void main(String[] args) {
+        NumericShaper ns_old = getContextualShaper(ARABIC | TAMIL | ETHIOPIC,
+                                   EUROPEAN);
+        NumericShaper ns_new = getContextualShaper(EnumSet.of(
+                                   Range.ARABIC, Range.TAMIL, Range.ETHIOPIC),
+                                   Range.EUROPEAN);
+
+        boolean err = false;
+
+        String[][] data = {
+           // Arabic "October 10"
+          {"\u0623\u0643\u062a\u0648\u0628\u0631 10",
+           "\u0623\u0643\u062a\u0648\u0628\u0631 \u0661\u0660"},
+
+           // Tamil "Year 2009"
+          {"\u0b86\u0ba3\u0bcd\u0b9f\u0bc1 2009",
+           "\u0b86\u0ba3\u0bcd\u0b9f\u0bc1 \u0be8\u0be6\u0be6\u0bef"},
+           // "\u0be800\u0bef is returned by pre-JDK7 because Tamil zero was not
+           //  included in Unicode 4.0.0.
+
+           // Ethiopic "Syllable<HA> 2009"
+          {"\u1200 2009",
+           "\u1200 \u136a00\u1371"},
+           // Ethiopic zero doesn't exist even in Unicode 5.1.0.
+        };
+
+        for (int i = 0; i < data.length; i++) {
+            String expected = data[i][1];
+
+            char[] text = data[i][0].toCharArray();
+            ns_old.shape(text, 0, text.length);
+            String got = new String(text);
+
+            if (!expected.equals(got)) {
+                err = true;
+                System.err.println("Error with traditional range.");
+                System.err.println("  text = " + data[i][0]);
+                System.err.println("  got = " + got);
+                System.err.println("  expected = " + expected);
+            } else {
+                System.err.println("OK with traditional range.");
+                System.err.println("  text = " + data[i][0]);
+                System.err.println("  got = " + got);
+                System.err.println("  expected = " + expected);
+            }
+
+            text = data[i][0].toCharArray();
+            ns_new.shape(text, 0, text.length);
+            got = new String(text);
+
+            if (!expected.equals(got)) {
+                err = true;
+                System.err.println("Error with new Enum range.");
+                System.err.println("  text = " + data[i][0]);
+                System.err.println("  got = " + got);
+                System.err.println("  expected = " + expected);
+            } else {
+                System.err.println("OK with new Enum range.");
+                System.err.println("  text = " + data[i][0]);
+                System.err.println("  got = " + got);
+                System.err.println("  expected = " + expected);
+            }
+        }
+
+        if (err) {
+            throw new RuntimeException("shape() returned unexpected value.");
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/ClassLoader/UninitializedParent.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,68 @@
+/*
+ * 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 6636650
+ * @summary Uninitialized class loaders should not be a parent of other
+ *          class loaders.
+ */
+
+
+import java.net.*;
+
+public class UninitializedParent {
+    private static ClassLoader loader;
+    public static void main(String[] args) throws Exception {
+        System.setSecurityManager(new SecurityManager());
+
+        // Create an uninitialized class loader
+        try {
+            new ClassLoader(null) {
+                @Override
+                protected void finalize() {
+                    loader = this;
+                }
+            };
+        } catch (SecurityException exc) {
+            // Expected
+        }
+        System.gc();
+        System.runFinalization();
+
+        // if 'loader' isn't null, need to ensure that it can't be used as
+        // parent
+        if (loader != null) {
+            try {
+                // Create a class loader with 'loader' being the parent
+                URLClassLoader child = URLClassLoader.newInstance
+                    (new URL[0], loader);
+                throw new RuntimeException("Test Failed!");
+            } catch (SecurityException se) {
+                System.out.println("Test Passed: Exception thrown");
+            }
+        } else {
+            System.out.println("Test Passed: Loader is null");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/math/BigInteger/ExtremeShiftingTests.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6371401
+ * @summary Tests of shiftLeft and shiftRight on Integer.MIN_VALUE
+ * @author Joseph D. Darcy
+ */
+import static java.math.BigInteger.*;
+
+public class ExtremeShiftingTests {
+    public static void main(String... args) {
+        try {
+            ONE.shiftLeft(Integer.MIN_VALUE);
+            throw new RuntimeException("Should not reach here.");
+        } catch (ArithmeticException ae) {
+            ; // Expected
+        }
+
+        try {
+            ONE.shiftRight(Integer.MIN_VALUE);
+            throw new RuntimeException("Should not reach here.");
+        } catch (ArithmeticException ae) {
+            ; // Expected
+        }
+    }
+}
--- a/test/java/net/CookieHandler/B6644726.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/net/CookieHandler/B6644726.java	Wed Nov 25 11:08:25 2009 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6644726
+ * @bug 6644726 6873543
  * @summary Cookie management issues
  */
 
@@ -170,6 +170,28 @@
         if (isIn(clst, "myCookie8=")) {
             fail("A cookie with an invalid port list was returned");
         }
+
+        // Test httpOnly flag (CR# 6873543)
+        lst.clear();
+        map.clear();
+        cm.getCookieStore().removeAll();
+        lst.add("myCookie11=httpOnlyTest; httpOnly");
+        map.put("Set-Cookie", lst);
+        uri = new URI("http://www.sun.com/");
+        cm.put(uri, map);
+        m = cm.get(uri, emptyMap);
+        clst = m.get("Cookie");
+        // URI scheme was http: so we should get the cookie
+        if (!isIn(clst, "myCookie11=")) {
+            fail("Missing cookie with httpOnly flag");
+        }
+        uri = new URI("javascript://www.sun.com/");
+        m = cm.get(uri, emptyMap);
+        clst = m.get("Cookie");
+        // URI scheme was neither http or https so we shouldn't get the cookie
+        if (isIn(clst, "myCookie11=")) {
+            fail("Should get the cookie with httpOnly when scheme is javascript:");
+        }
     }
 
     private static boolean isIn(List<String> lst, String cookie) {
--- a/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java	Wed Nov 25 11:08:25 2009 -0800
@@ -34,7 +34,7 @@
 
 public class Unbounded {
     // number of concurrent completion handlers
-    static final int CONCURRENCY_COUNT = 512;
+    static final int CONCURRENCY_COUNT = 256;
 
     public static void main(String[] args) throws Exception {
         // all accepted connections are added to a queue
--- a/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/nio/channels/DatagramChannel/NetworkConfiguration.java	Wed Nov 25 11:08:25 2009 -0800
@@ -73,22 +73,22 @@
 
             List<InetAddress> addrs = Collections.list(nif.getInetAddresses());
             for (InetAddress addr: addrs) {
-                if (addr instanceof Inet4Address) {
-                    List<InetAddress> list = ip4Interfaces.get(nif);
-                    if (list == null) {
-                        list = new LinkedList<InetAddress>();
+                if (!addr.isAnyLocalAddress()) {
+                    if (addr instanceof Inet4Address) {
+                        List<InetAddress> list = ip4Interfaces.get(nif);
+                        if (list == null) {
+                            list = new LinkedList<InetAddress>();
+                        }
+                        list.add(addr);
+                        ip4Interfaces.put(nif, list);
+                    } else if (addr instanceof Inet6Address) {
+                        List<InetAddress> list = ip6Interfaces.get(nif);
+                        if (list == null) {
+                            list = new LinkedList<InetAddress>();
+                        }
+                        list.add(addr);
+                        ip6Interfaces.put(nif, list);
                     }
-                    list.add(addr);
-                    ip4Interfaces.put(nif, list);
-                }
-                if (addr instanceof Inet6Address) {
-                    List<InetAddress> list = ip6Interfaces.get(nif);
-                    if (list == null) {
-                        list = new LinkedList<InetAddress>();
-                    }
-                    list.add(addr);
-                    ip6Interfaces.put(nif, list);
-
                 }
             }
         }
--- a/test/java/nio/channels/FileChannel/Transfer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/nio/channels/FileChannel/Transfer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,7 @@
  * @bug 4434723 4482726 4559072 4638365 4795550 5081340 5103988 6253145
  * @summary Test FileChannel.transferFrom and transferTo
  * @library ..
+ * @run main/timeout=180 Transfer
  */
 
 import java.io.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/nio/channels/Selector/LotsOfCancels.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2009 Google 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.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.ServerSocketChannel;
+import java.nio.channels.SocketChannel;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Reproduces O(N^2) behavior of JDK6/7 select() call. This happens when
+ * a selector has many unprocessed updates to its interest set (e.g. adding
+ * OP_READ on a bunch of newly accepted sockets). The O(N^2) is triggered
+ * by cancelling a number of selection keys (or just closing a few sockets).
+ * In this case, select() will first go through the list of cancelled keys
+ * and try to deregister them. That deregistration is O(N^2) over the list
+ * of unprocessed updates to the interest set.
+ *
+ * <p> This O(N^2) behavior is a BUG in JVM and should be fixed.
+ *
+ * <p> The test first creates initCount connections, and adds them
+ * to the server epoll set. It then creates massCount connections,
+ * registers interest (causing updateList to be populated with massCount*2
+ * elements), but does not add them to epoll set (that would've cleared
+ * updateList). The test then closes initCount connections, thus populating
+ * deregistration queue. The subsequent call to selectNow() will first process
+ * deregistration queue, performing O(N^2) over updateList size,
+ * equal to massCount * 2.
+ *
+ * <p> Note that connect rate is artificially slowed down to compensate
+ * for what I believe is a Linux bug, where too high of a connection rate
+ * ends up in SYN's being dropped and then slow retransmits.
+ *
+ * @author Igor Chernyshev
+ */
+public class LotsOfCancels {
+
+    static long testStartTime;
+
+    public static void main(String[] args) throws Exception {
+        // the final select should run in less than 1000ms.
+        runTest(500, 2700, 1000);
+    }
+
+    static void log(String msg) {
+        System.out.println(getLogPrefix() + msg);
+    }
+
+    static String getLogPrefix() {
+        return durationMillis(testStartTime) + ": ";
+    }
+
+    /**
+     * Returns the elapsed time since startNanos, in milliseconds.
+     * @param startNanos the start time; this must be a value returned
+     * by {@link System.nanoTime}
+     */
+    static long durationMillis(long startNanos) {
+        return (System.nanoTime() - startNanos) / (1000L * 1000L);
+    }
+
+    static void runTest(int initCount, int massCount, int maxSelectTime)
+            throws Exception {
+        testStartTime = System.nanoTime();
+
+        InetSocketAddress address = new InetSocketAddress("127.0.0.1", 7359);
+
+        // Create server channel, add it to selector and run epoll_ctl.
+        log("Setting up server");
+        Selector serverSelector = Selector.open();
+        ServerSocketChannel server = ServerSocketChannel.open();
+        server.configureBlocking(false);
+        server.socket().bind(address, 5000);
+        server.register(serverSelector, SelectionKey.OP_ACCEPT);
+        serverSelector.selectNow();
+
+        log("Setting up client");
+        ClientThread client = new ClientThread(address);
+        client.start();
+        Thread.sleep(100);
+
+        // Set up initial set of client sockets.
+        log("Starting initial client connections");
+        client.connectClients(initCount);
+        Thread.sleep(500);  // Wait for client connections to arrive
+
+        // Accept all initial client sockets, add to selector and run
+        // epoll_ctl.
+        log("Accepting initial connections");
+        List<SocketChannel> serverChannels1 =
+            acceptAndAddAll(serverSelector, server, initCount);
+        if (serverChannels1.size() != initCount) {
+            throw new Exception("Accepted " + serverChannels1.size() +
+                                " instead of " + initCount);
+        }
+        serverSelector.selectNow();
+
+        // Set up mass set of client sockets.
+        log("Requesting mass client connections");
+        client.connectClients(massCount);
+        Thread.sleep(500);  // Wait for client connections to arrive
+
+        // Accept all mass client sockets, add to selector and do NOT
+        // run epoll_ctl.
+        log("Accepting mass connections");
+        List<SocketChannel> serverChannels2 =
+            acceptAndAddAll(serverSelector, server, massCount);
+        if (serverChannels2.size() != massCount) {
+            throw new Exception("Accepted " + serverChannels2.size() +
+                                " instead of " + massCount);
+        }
+
+        // Close initial set of sockets.
+        log("Closing initial connections");
+        closeAll(serverChannels1);
+
+        // Now get the timing of select() call.
+        log("Running the final select call");
+        long startTime = System.nanoTime();
+        serverSelector.selectNow();
+        long duration = durationMillis(startTime);
+        log("Init count = " + initCount +
+            ", mass count = " + massCount +
+            ", duration = " + duration + "ms");
+
+        if (duration > maxSelectTime) {
+            System.out.println
+                ("\n\n\n\n\nFAILURE: The final selectNow() took " +
+                 duration + "ms " +
+                 "- seems like O(N^2) bug is still here\n\n");
+            System.exit(1);
+        }
+    }
+
+    static List<SocketChannel> acceptAndAddAll(Selector selector,
+                                               ServerSocketChannel server,
+                                               int expected)
+            throws Exception {
+        int retryCount = 0;
+        int acceptCount = 0;
+        List<SocketChannel> channels = new ArrayList<SocketChannel>();
+        while (channels.size() < expected) {
+            SocketChannel channel = server.accept();
+            if (channel == null) {
+                log("accept() returned null " +
+                    "after accepting " + acceptCount + " more connections");
+                acceptCount = 0;
+                if (retryCount < 10) {
+                    // See if more new sockets got stacked behind.
+                    retryCount++;
+                    Thread.sleep(500);
+                    continue;
+                }
+                break;
+            }
+            retryCount = 0;
+            acceptCount++;
+            channel.configureBlocking(false);
+            channel.register(selector, SelectionKey.OP_READ);
+            channels.add(channel);
+        }
+        // Cause an additional updateList entry per channel.
+        for (SocketChannel channel : channels) {
+            channel.register(selector, SelectionKey.OP_WRITE);
+        }
+        return channels;
+    }
+
+    static void closeAll(List<SocketChannel> channels)
+            throws Exception {
+        for (SocketChannel channel : channels) {
+            channel.close();
+        }
+    }
+
+    static class ClientThread extends Thread {
+        private final SocketAddress address;
+        private final Selector selector;
+        private int connectionsNeeded;
+        private int totalCreated;
+
+        ClientThread(SocketAddress address) throws Exception {
+            this.address = address;
+            selector = Selector.open();
+            setDaemon(true);
+        }
+
+        void connectClients(int count) throws Exception {
+            synchronized (this) {
+                connectionsNeeded += count;
+            }
+            selector.wakeup();
+        }
+
+        @Override
+        public void run() {
+            try {
+                handleClients();
+            } catch (Throwable e) {
+                e.printStackTrace();
+                System.exit(1);
+            }
+        }
+
+        private void handleClients() throws Exception {
+            int selectCount = 0;
+            while (true) {
+                int createdCount = 0;
+                synchronized (this) {
+                    if (connectionsNeeded > 0) {
+
+                        while (connectionsNeeded > 0 && createdCount < 20) {
+                            connectionsNeeded--;
+                            createdCount++;
+                            totalCreated++;
+
+                            SocketChannel channel = SocketChannel.open();
+                            channel.configureBlocking(false);
+                            channel.connect(address);
+                            if (!channel.finishConnect()) {
+                                channel.register(selector,
+                                                 SelectionKey.OP_CONNECT);
+                            }
+                        }
+
+                        log("Started total of " +
+                            totalCreated + " client connections");
+                        Thread.sleep(200);
+                    }
+                }
+
+                if (createdCount > 0) {
+                    selector.selectNow();
+                } else {
+                    selectCount++;
+                    long startTime = System.nanoTime();
+                    selector.select();
+                    long duration = durationMillis(startTime);
+                    log("Exited clientSelector.select(), loop #"
+                        + selectCount + ", duration = " + duration + "ms");
+                }
+
+                int keyCount = -1;
+                Iterator<SelectionKey> keys =
+                    selector.selectedKeys().iterator();
+                while (keys.hasNext()) {
+                    SelectionKey key = keys.next();
+                    synchronized (key) {
+                        keyCount++;
+                        keys.remove();
+                        if (!key.isValid()) {
+                            log("Ignoring client key #" + keyCount);
+                            continue;
+                        }
+                        int readyOps = key.readyOps();
+                        if (readyOps == SelectionKey.OP_CONNECT) {
+                            key.interestOps(0);
+                            ((SocketChannel) key.channel()).finishConnect();
+                        } else {
+                            log("readyOps() on client key #" + keyCount +
+                                " returned " + readyOps);
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
--- a/test/java/nio/file/Path/CopyAndMove.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/nio/file/Path/CopyAndMove.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,6 +25,8 @@
  * @bug 4313887 6838333
  * @summary Unit test for java.nio.file.Path copyTo/moveTo methods
  * @library ..
+ * @build CopyAndMove
+ * @run main/othervm CopyAndMove
  */
 
 import java.nio.ByteBuffer;
--- a/test/java/nio/file/Path/Links.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/nio/file/Path/Links.java	Wed Nov 25 11:08:25 2009 -0800
@@ -26,6 +26,8 @@
  * @summary Unit test for java.nio.file.Path createSymbolicLink,
  *     readSymbolicLink, and createLink methods
  * @library ..
+ * @build Links
+ * @run main/othervm Links
  */
 
 import java.nio.file.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/Arrays/Sorting.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,1440 @@
+/*
+ * 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 6880672 6896573 6899694
+ * @summary Exercise Arrays.sort
+ * @build Sorting
+ * @run main Sorting -shortrun
+ *
+ * @author Vladimir Yaroslavskiy
+ * @author Jon Bentley
+ * @author Josh Bloch
+ */
+
+import java.util.Arrays;
+import java.util.Random;
+import java.io.PrintStream;
+
+public class Sorting {
+    private static final PrintStream out = System.out;
+    private static final PrintStream err = System.err;
+
+    // Array lengths used in a long run (default)
+    private static final int[] LONG_RUN_LENGTHS = {
+        1, 2, 3, 5, 8, 13, 21, 34, 55, 100, 1000, 10000, 100000, 1000000};
+
+    // Array lengths used in a short run
+    private static final int[] SHORT_RUN_LENGTHS = { 1, 2, 3, 21, 55, 1000, 10000 };
+
+    // Random initial values used in a long run (default)
+    private static final long[] LONG_RUN_RANDOMS = {666, 0xC0FFEE, 999};
+
+    // Random initial values used in a short run
+    private static final long[] SHORT_RUN_RANDOMS = {666};
+
+    public static void main(String[] args) {
+        boolean shortRun = args.length > 0 && args[0].equals("-shortrun");
+        long start = System.currentTimeMillis();
+
+        if (shortRun) {
+            testAndCheck(SHORT_RUN_LENGTHS, SHORT_RUN_RANDOMS);
+        } else {
+            testAndCheck(LONG_RUN_LENGTHS, LONG_RUN_RANDOMS);
+        }
+        long end = System.currentTimeMillis();
+
+        out.format("PASS in %d sec.\n", Math.round((end - start) / 1E3));
+    }
+
+    private static void testAndCheck(int[] lengths, long[] randoms) {
+        for (long random : randoms) {
+            reset(random);
+
+            for (int len : lengths) {
+                testAndCheckWithCheckSum(len, random);
+            }
+            reset(random);
+
+            for (int len : lengths) {
+                testAndCheckWithScrambling(len, random);
+            }
+            reset(random);
+
+            for (int len : lengths) {
+                testAndCheckFloat(len, random);
+            }
+            reset(random);
+
+            for (int len : lengths) {
+                testAndCheckDouble(len, random);
+            }
+            reset(random);
+
+            for (int len : lengths) {
+                testAndCheckRange(len, random);
+            }
+            reset(random);
+
+            for (int len : lengths) {
+                testAndCheckSubArray(len, random);
+            }
+        }
+    }
+
+    private static void testAndCheckSubArray(int len, long random) {
+        int[] golden = new int[len];
+
+        for (int m = 1; m < len / 2; m *= 2) {
+            int fromIndex = m;
+            int toIndex = len - m;
+
+            prepareSubArray(golden, fromIndex, toIndex, m);
+            int[] test = golden.clone();
+
+            for (TypeConverter converter : TypeConverter.values()) {
+                out.println("Test #6: " + converter +
+                   " len = " + len + ", m = " + m);
+                Object convertedGolden = converter.convert(golden);
+                Object convertedTest = converter.convert(test);
+
+                // outArr(test);
+                sortSubArray(convertedTest, fromIndex, toIndex);
+                // outArr(test);
+                checkSubArray(convertedTest, fromIndex, toIndex, m);
+            }
+        }
+        out.println();
+    }
+
+    private static void testAndCheckRange(int len, long random) {
+        int[] golden = new int[len];
+
+        for (int m = 1; m < 2 * len; m *= 2) {
+            for (int i = 1; i <= len; i++) {
+                golden[i - 1] = i % m + m % i;
+            }
+            for (TypeConverter converter : TypeConverter.values()) {
+                out.println("Test #5: " + converter +
+                   ", len = " + len + ", m = " + m);
+                Object convertedGolden = converter.convert(golden);
+                sortRange(convertedGolden, m);
+                sortEmpty(convertedGolden);
+            }
+        }
+        out.println();
+    }
+
+    private static void testAndCheckWithCheckSum(int len, long random) {
+        int[] golden = new int[len];
+
+        for (int m = 1; m < 2 * len; m *= 2) {
+            for (UnsortedBuilder builder : UnsortedBuilder.values()) {
+                builder.build(golden, m);
+                int[] test = golden.clone();
+
+                for (TypeConverter converter : TypeConverter.values()) {
+                    out.println("Test #1: " + converter + " " + builder +
+                       "random = " +  random + ", len = " + len +
+                       ", m = " + m);
+                    Object convertedGolden = converter.convert(golden);
+                    Object convertedTest = converter.convert(test);
+                    sort(convertedTest);
+                    checkWithCheckSum(convertedTest, convertedGolden);
+                }
+            }
+        }
+        out.println();
+    }
+
+    private static void testAndCheckWithScrambling(int len, long random) {
+        int[] golden = new int[len];
+
+        for (int m = 1; m <= 7; m++) {
+            if (m > len) {
+                break;
+            }
+            for (SortedBuilder builder : SortedBuilder.values()) {
+                builder.build(golden, m);
+                int[] test = golden.clone();
+                scramble(test);
+
+                for (TypeConverter converter : TypeConverter.values()) {
+                    out.println("Test #2: " + converter + " " + builder +
+                       "random = " +  random + ", len = " + len +
+                       ", m = " + m);
+                    Object convertedGolden = converter.convert(golden);
+                    Object convertedTest = converter.convert(test);
+                    sort(convertedTest);
+                    compare(convertedTest, convertedGolden);
+                }
+            }
+        }
+        out.println();
+    }
+
+    private static void testAndCheckFloat(int len, long random) {
+        float[] golden = new float[len];
+        final int MAX = 10;
+        boolean newLine = false;
+
+        for (int a = 0; a <= MAX; a++) {
+            for (int g = 0; g <= MAX; g++) {
+                for (int z = 0; z <= MAX; z++) {
+                    for (int n = 0; n <= MAX; n++) {
+                        for (int p = 0; p <= MAX; p++) {
+                            if (a + g + z + n + p > len) {
+                                continue;
+                            }
+                            if (a + g + z + n + p < len) {
+                                continue;
+                            }
+                            for (FloatBuilder builder : FloatBuilder.values()) {
+                                out.println("Test #3: random = " + random +
+                                   ", len = " + len + ", a = " + a + ", g = " + g +
+                                   ", z = " + z + ", n = " + n + ", p = " + p);
+                                builder.build(golden, a, g, z, n, p);
+                                float[] test = golden.clone();
+                                scramble(test);
+                                // outArr(test);
+                                sort(test);
+                                // outArr(test);
+                                compare(test, golden, a, n, g);
+                            }
+                            newLine = true;
+                        }
+                    }
+                }
+            }
+        }
+        if (newLine) {
+            out.println();
+        }
+    }
+
+    private static void testAndCheckDouble(int len, long random) {
+        double[] golden = new double[len];
+        final int MAX = 10;
+        boolean newLine = false;
+
+        for (int a = 0; a <= MAX; a++) {
+            for (int g = 0; g <= MAX; g++) {
+                for (int z = 0; z <= MAX; z++) {
+                    for (int n = 0; n <= MAX; n++) {
+                        for (int p = 0; p <= MAX; p++) {
+                            if (a + g + z + n + p > len) {
+                                continue;
+                            }
+                            if (a + g + z + n + p < len) {
+                                continue;
+                            }
+                            for (DoubleBuilder builder : DoubleBuilder.values()) {
+                                out.println("Test #4: random = " + random +
+                                   ", len = " + len + ", a = " + a + ", g = " + g +
+                                   ", z = " + z + ", n = " + n + ", p = " + p);
+                                builder.build(golden, a, g, z, n, p);
+                                double[] test = golden.clone();
+                                scramble(test);
+                                // outArr(test);
+                                sort(test);
+                                // outArr(test);
+                                compare(test, golden, a, n, g);
+                            }
+                            newLine = true;
+                        }
+                    }
+                }
+            }
+        }
+        if (newLine) {
+            out.println();
+        }
+    }
+
+    private static void prepareSubArray(int[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            a[i] = 0xBABA;
+        }
+
+        for (int i = fromIndex; i < toIndex; i++) {
+            a[i] = -i + m;
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            a[i] = 0xDEDA;
+        }
+    }
+
+    private static void scramble(int[] a) {
+        int length = a.length;
+
+        for (int i = 0; i < length * 7; i++) {
+            swap(a, ourRandom.nextInt(length), ourRandom.nextInt(length));
+        }
+    }
+
+    private static void scramble(float[] a) {
+        int length = a.length;
+
+        for (int i = 0; i < length * 7; i++) {
+            swap(a, ourRandom.nextInt(length), ourRandom.nextInt(length));
+        }
+    }
+
+    private static void scramble(double[] a) {
+        int length = a.length;
+
+        for (int i = 0; i < length * 7; i++) {
+            swap(a, ourRandom.nextInt(length), ourRandom.nextInt(length));
+        }
+    }
+
+    private static void swap(int[] a, int i, int j) {
+        int t = a[i];
+        a[i] = a[j];
+        a[j] = t;
+    }
+
+    private static void swap(float[] a, int i, int j) {
+        float t = a[i];
+        a[i] = a[j];
+        a[j] = t;
+    }
+
+    private static void swap(double[] a, int i, int j) {
+        double t = a[i];
+        a[i] = a[j];
+        a[j] = t;
+    }
+
+    private static enum TypeConverter {
+        INT {
+            Object convert(int[] a) {
+                return a.clone();
+            }
+        },
+        LONG {
+            Object convert(int[] a) {
+                long[] b = new long[a.length];
+
+                for (int i = 0; i < a.length; i++) {
+                    b[i] = (long) a[i];
+                }
+                return b;
+            }
+        },
+        BYTE {
+            Object convert(int[] a) {
+                byte[] b = new byte[a.length];
+
+                for (int i = 0; i < a.length; i++) {
+                    b[i] = (byte) a[i];
+                }
+                return b;
+            }
+        },
+        SHORT {
+            Object convert(int[] a) {
+                short[] b = new short[a.length];
+
+                for (int i = 0; i < a.length; i++) {
+                    b[i] = (short) a[i];
+                }
+                return b;
+            }
+        },
+        CHAR {
+            Object convert(int[] a) {
+                char[] b = new char[a.length];
+
+                for (int i = 0; i < a.length; i++) {
+                    b[i] = (char) a[i];
+                }
+                return b;
+            }
+        },
+        FLOAT {
+            Object convert(int[] a) {
+                float[] b = new float[a.length];
+
+                for (int i = 0; i < a.length; i++) {
+                    b[i] = (float) a[i];
+                }
+                return b;
+            }
+        },
+        DOUBLE {
+            Object convert(int[] a) {
+                double[] b = new double[a.length];
+
+                for (int i = 0; i < a.length; i++) {
+                    b[i] = (double) a[i];
+                }
+                return b;
+            }
+        };
+
+        abstract Object convert(int[] a);
+
+        @Override public String toString() {
+            String name = name();
+
+            for (int i = name.length(); i < 9; i++) {
+                name += " ";
+            }
+            return name;
+        }
+    }
+
+    private static enum FloatBuilder {
+        SIMPLE {
+            void build(float[] x, int a, int g, int z, int n, int p) {
+                int fromIndex = 0;
+                float negativeValue = -ourRandom.nextFloat();
+                float positiveValue =  ourRandom.nextFloat();
+
+                writeValue(x, negativeValue, fromIndex, n);
+                fromIndex += n;
+
+                writeValue(x, -0.0f, fromIndex, g);
+                fromIndex += g;
+
+                writeValue(x, 0.0f, fromIndex, z);
+                fromIndex += z;
+
+                writeValue(x, positiveValue, fromIndex, p);
+                fromIndex += p;
+
+                writeValue(x, Float.NaN, fromIndex, a);
+            }
+        };
+
+        abstract void build(float[] x, int a, int g, int z, int n, int p);
+    }
+
+    private static enum DoubleBuilder {
+        SIMPLE {
+            void build(double[] x, int a, int g, int z, int n, int p) {
+                int fromIndex = 0;
+                double negativeValue = -ourRandom.nextFloat();
+                double positiveValue =  ourRandom.nextFloat();
+
+                writeValue(x, negativeValue, fromIndex, n);
+                fromIndex += n;
+
+                writeValue(x, -0.0d, fromIndex, g);
+                fromIndex += g;
+
+                writeValue(x, 0.0d, fromIndex, z);
+                fromIndex += z;
+
+                writeValue(x, positiveValue, fromIndex, p);
+                fromIndex += p;
+
+                writeValue(x, Double.NaN, fromIndex, a);
+            }
+        };
+
+        abstract void build(double[] x, int a, int g, int z, int n, int p);
+    }
+
+    private static void writeValue(float[] a, float value, int fromIndex, int count) {
+        for (int i = fromIndex; i < fromIndex + count; i++) {
+            a[i] = value;
+        }
+    }
+
+    private static void compare(float[] a, float[] b, int numNaN, int numNeg, int numNegZero) {
+        for (int i = a.length - numNaN; i < a.length; i++) {
+            if (a[i] == a[i]) {
+                failed("On position " + i + " must be NaN instead of " + a[i]);
+            }
+        }
+        final int NEGATIVE_ZERO = Float.floatToIntBits(-0.0f);
+
+        for (int i = numNeg; i < numNeg + numNegZero; i++) {
+            if (NEGATIVE_ZERO != Float.floatToIntBits(a[i])) {
+                failed("On position " + i + " must be -0.0f instead of " + a[i]);
+            }
+        }
+        for (int i = 0; i < a.length - numNaN; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void writeValue(double[] a, double value, int fromIndex, int count) {
+        for (int i = fromIndex; i < fromIndex + count; i++) {
+            a[i] = value;
+        }
+    }
+
+    private static void compare(double[] a, double[] b, int numNaN, int numNeg, int numNegZero) {
+        for (int i = a.length - numNaN; i < a.length; i++) {
+            if (a[i] == a[i]) {
+                failed("On position " + i + " must be NaN instead of " + a[i]);
+            }
+        }
+        final long NEGATIVE_ZERO = Double.doubleToLongBits(-0.0d);
+
+        for (int i = numNeg; i < numNeg + numNegZero; i++) {
+            if (NEGATIVE_ZERO != Double.doubleToLongBits(a[i])) {
+                failed("On position " + i + " must be -0.0d instead of " + a[i]);
+            }
+        }
+        for (int i = 0; i < a.length - numNaN; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static enum SortedBuilder {
+        REPEATED {
+            void build(int[] a, int m) {
+                int period = a.length / m;
+                int i = 0;
+                int k = 0;
+
+                while (true) {
+                    for (int t = 1; t <= period; t++) {
+                        if (i >= a.length) {
+                            return;
+                        }
+                        a[i++] = k;
+                    }
+                    if (i >= a.length) {
+                        return;
+                    }
+                    k++;
+                }
+            }
+        },
+
+        ORGAN_PIPES {
+            void build(int[] a, int m) {
+                int i = 0;
+                int k = m;
+
+                while (true) {
+                    for (int t = 1; t <= m; t++) {
+                        if (i >= a.length) {
+                            return;
+                        }
+                        a[i++] = k;
+                    }
+                }
+            }
+        };
+
+        abstract void build(int[] a, int m);
+
+        @Override public String toString() {
+            String name = name();
+
+            for (int i = name.length(); i < 12; i++) {
+                name += " ";
+            }
+            return name;
+        }
+    }
+
+    private static enum UnsortedBuilder {
+        RANDOM {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = ourRandom.nextInt();
+                }
+            }
+        },
+        ASCENDING {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = m + i;
+                }
+            }
+        },
+        DESCENDING {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = a.length - m - i;
+                }
+            }
+        },
+        ALL_EQUAL {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = m;
+                }
+            }
+        },
+        SAW {
+            void build(int[] a, int m) {
+                int incCount = 1;
+                int decCount = a.length;
+                int i = 0;
+                int period = m;
+                m--;
+                while (true) {
+                    for (int k = 1; k <= period; k++) {
+                        if (i >= a.length) {
+                            return;
+                        }
+                        a[i++] = incCount++;
+                    }
+                    period += m;
+
+                    for (int k = 1; k <= period; k++) {
+                        if (i >= a.length) {
+                            return;
+                        }
+                        a[i++] = decCount--;
+                    }
+                    period += m;
+                }
+            }
+        },
+        REPEATED {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = i % m;
+                }
+            }
+        },
+        DUPLICATED {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = ourRandom.nextInt(m);
+                }
+            }
+        },
+        ORGAN_PIPES {
+            void build(int[] a, int m) {
+                int middle = a.length / (m + 1);
+
+                for (int i = 0; i < middle; i++) {
+                    a[i] = i;
+                }
+                for (int i = middle; i < a.length; i++) {
+                    a[i] = a.length - i - 1;
+                }
+            }
+        },
+        STAGGER {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = (i * m + i) % a.length;
+                }
+            }
+        },
+        PLATEAU {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = Math.min(i, m);
+                }
+            }
+        },
+        SHUFFLE {
+            void build(int[] a, int m) {
+                for (int i = 0; i < a.length; i++) {
+                    a[i] = ourRandom.nextBoolean() ? (ourFirst += 2) : (ourSecond += 2);
+                }
+            }
+        };
+
+        abstract void build(int[] a, int m);
+
+        @Override public String toString() {
+            String name = name();
+
+            for (int i = name.length(); i < 12; i++) {
+                name += " ";
+            }
+            return name;
+        }
+    }
+
+    private static void compare(Object test, Object golden) {
+        if (test instanceof int[]) {
+            compare((int[]) test, (int[]) golden);
+        } else if (test instanceof long[]) {
+            compare((long[]) test, (long[]) golden);
+        } else if (test instanceof short[]) {
+            compare((short[]) test, (short[]) golden);
+        } else if (test instanceof byte[]) {
+            compare((byte[]) test, (byte[]) golden);
+        } else if (test instanceof char[]) {
+            compare((char[]) test, (char[]) golden);
+        } else if (test instanceof float[]) {
+            compare((float[]) test, (float[]) golden);
+        } else if (test instanceof double[]) {
+            compare((double[]) test, (double[]) golden);
+        } else {
+            failed("Unknow type of array: " + test + " of class " +
+                test.getClass().getName());
+        }
+    }
+
+    private static void checkWithCheckSum(Object test, Object golden) {
+        checkSorted(test);
+        checkCheckSum(test, golden);
+    }
+
+    private static void failed(String message) {
+        err.format("\n*** FAILED: %s\n\n", message);
+        throw new RuntimeException("Test failed - see log file for details");
+    }
+
+    private static void failed(int index, String value1, String value2) {
+        failed("Array is not sorted at " + index + "-th position: " + value1 +
+               " and " + value2);
+    }
+
+    private static void checkSorted(Object object) {
+        if (object instanceof int[]) {
+            checkSorted((int[]) object);
+        } else if (object instanceof long[]) {
+            checkSorted((long[]) object);
+        } else if (object instanceof short[]) {
+            checkSorted((short[]) object);
+        } else if (object instanceof byte[]) {
+            checkSorted((byte[]) object);
+        } else if (object instanceof char[]) {
+            checkSorted((char[]) object);
+        } else if (object instanceof float[]) {
+            checkSorted((float[]) object);
+        } else if (object instanceof double[]) {
+            checkSorted((double[]) object);
+        } else {
+            failed("Unknow type of array: " + object + " of class " +
+                object.getClass().getName());
+        }
+    }
+
+    private static void compare(int[] a, int[] b) {
+        for (int i = 0; i < a.length; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void compare(long[] a, long[] b) {
+        for (int i = 0; i < a.length; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void compare(short[] a, short[] b) {
+        for (int i = 0; i < a.length; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void compare(byte[] a, byte[] b) {
+        for (int i = 0; i < a.length; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void compare(char[] a, char[] b) {
+        for (int i = 0; i < a.length; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void compare(float[] a, float[] b) {
+        for (int i = 0; i < a.length; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void compare(double[] a, double[] b) {
+        for (int i = 0; i < a.length; i++) {
+            if (a[i] != b[i]) {
+                failed(i, "" + a[i], "" + b[i]);
+            }
+        }
+    }
+
+    private static void checkSorted(int[] a) {
+        for (int i = 0; i < a.length - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+    }
+
+    private static void checkSorted(long[] a) {
+        for (int i = 0; i < a.length - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+    }
+
+    private static void checkSorted(short[] a) {
+        for (int i = 0; i < a.length - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+    }
+
+    private static void checkSorted(byte[] a) {
+        for (int i = 0; i < a.length - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+    }
+
+    private static void checkSorted(char[] a) {
+        for (int i = 0; i < a.length - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+    }
+
+    private static void checkSorted(float[] a) {
+        for (int i = 0; i < a.length - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+    }
+
+    private static void checkSorted(double[] a) {
+        for (int i = 0; i < a.length - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+    }
+
+    private static void checkCheckSum(Object test, Object golden) {
+        if (checkSum(test) != checkSum(golden)) {
+            failed("Original and sorted arrays seems not identical");
+        }
+    }
+
+    private static int checkSum(Object object) {
+        if (object instanceof int[]) {
+            return checkSum((int[]) object);
+        } else if (object instanceof long[]) {
+            return checkSum((long[]) object);
+        } else if (object instanceof short[]) {
+            return checkSum((short[]) object);
+        } else if (object instanceof byte[]) {
+            return checkSum((byte[]) object);
+        } else if (object instanceof char[]) {
+            return checkSum((char[]) object);
+        } else if (object instanceof float[]) {
+            return checkSum((float[]) object);
+        } else if (object instanceof double[]) {
+            return checkSum((double[]) object);
+        } else {
+            failed("Unknow type of array: " + object + " of class " +
+                object.getClass().getName());
+            return -1;
+        }
+    }
+
+    private static int checkSum(int[] a) {
+        int checkXorSum = 0;
+
+        for (int e : a) {
+            checkXorSum ^= e;
+        }
+        return checkXorSum;
+    }
+
+    private static int checkSum(long[] a) {
+        long checkXorSum = 0;
+
+        for (long e : a) {
+            checkXorSum ^= e;
+        }
+        return (int) checkXorSum;
+    }
+
+    private static int checkSum(short[] a) {
+        short checkXorSum = 0;
+
+        for (short e : a) {
+            checkXorSum ^= e;
+        }
+        return (int) checkXorSum;
+    }
+
+    private static int checkSum(byte[] a) {
+        byte checkXorSum = 0;
+
+        for (byte e : a) {
+            checkXorSum ^= e;
+        }
+        return (int) checkXorSum;
+    }
+
+    private static int checkSum(char[] a) {
+        char checkXorSum = 0;
+
+        for (char e : a) {
+            checkXorSum ^= e;
+        }
+        return (int) checkXorSum;
+    }
+
+    private static int checkSum(float[] a) {
+        int checkXorSum = 0;
+
+        for (float e : a) {
+            checkXorSum ^= (int) e;
+        }
+        return checkXorSum;
+    }
+
+    private static int checkSum(double[] a) {
+        int checkXorSum = 0;
+
+        for (double e : a) {
+            checkXorSum ^= (int) e;
+        }
+        return checkXorSum;
+    }
+
+    private static void sort(Object object) {
+        if (object instanceof int[]) {
+            Arrays.sort((int[]) object);
+        } else if (object instanceof long[]) {
+            Arrays.sort((long[]) object);
+        } else if (object instanceof short[]) {
+            Arrays.sort((short[]) object);
+        } else if (object instanceof byte[]) {
+            Arrays.sort((byte[]) object);
+        } else if (object instanceof char[]) {
+            Arrays.sort((char[]) object);
+        } else if (object instanceof float[]) {
+            Arrays.sort((float[]) object);
+        } else if (object instanceof double[]) {
+            Arrays.sort((double[]) object);
+        } else {
+            failed("Unknow type of array: " + object + " of class " +
+                object.getClass().getName());
+        }
+    }
+
+    private static void sortSubArray(Object object, int fromIndex, int toIndex) {
+        if (object instanceof int[]) {
+            Arrays.sort((int[]) object, fromIndex, toIndex);
+        } else if (object instanceof long[]) {
+            Arrays.sort((long[]) object, fromIndex, toIndex);
+        } else if (object instanceof short[]) {
+            Arrays.sort((short[]) object, fromIndex, toIndex);
+        } else if (object instanceof byte[]) {
+            Arrays.sort((byte[]) object, fromIndex, toIndex);
+        } else if (object instanceof char[]) {
+            Arrays.sort((char[]) object, fromIndex, toIndex);
+        } else if (object instanceof float[]) {
+            Arrays.sort((float[]) object, fromIndex, toIndex);
+        } else if (object instanceof double[]) {
+            Arrays.sort((double[]) object, fromIndex, toIndex);
+        } else {
+            failed("Unknow type of array: " + object + " of class " +
+                object.getClass().getName());
+        }
+    }
+
+    private static void checkSubArray(Object object, int fromIndex, int toIndex, int m) {
+        if (object instanceof int[]) {
+            checkSubArray((int[]) object, fromIndex, toIndex, m);
+        } else if (object instanceof long[]) {
+            checkSubArray((long[]) object, fromIndex, toIndex, m);
+        } else if (object instanceof short[]) {
+            checkSubArray((short[]) object, fromIndex, toIndex, m);
+        } else if (object instanceof byte[]) {
+            checkSubArray((byte[]) object, fromIndex, toIndex, m);
+        } else if (object instanceof char[]) {
+            checkSubArray((char[]) object, fromIndex, toIndex, m);
+        } else if (object instanceof float[]) {
+            checkSubArray((float[]) object, fromIndex, toIndex, m);
+        } else if (object instanceof double[]) {
+            checkSubArray((double[]) object, fromIndex, toIndex, m);
+        } else {
+            failed("Unknow type of array: " + object + " of class " +
+                object.getClass().getName());
+        }
+    }
+
+    private static void checkSubArray(int[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            if (a[i] != 0xBABA) {
+                failed("Range sort changes left element on position " + i +
+                    ": " + a[i] + ", must be " + 0xBABA);
+            }
+        }
+
+        for (int i = fromIndex; i < toIndex - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            if (a[i] != 0xDEDA) {
+                failed("Range sort changes right element on position " + i +
+                    ": " + a[i] + ", must be " + 0xDEDA);
+            }
+        }
+    }
+
+    private static void checkSubArray(byte[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            if (a[i] != (byte) 0xBABA) {
+                failed("Range sort changes left element on position " + i +
+                    ": " + a[i] + ", must be " + 0xBABA);
+            }
+        }
+
+        for (int i = fromIndex; i < toIndex - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            if (a[i] != (byte) 0xDEDA) {
+                failed("Range sort changes right element on position " + i +
+                    ": " + a[i] + ", must be " + 0xDEDA);
+            }
+        }
+    }
+
+    private static void checkSubArray(long[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            if (a[i] != (long) 0xBABA) {
+                failed("Range sort changes left element on position " + i +
+                    ": " + a[i] + ", must be " + 0xBABA);
+            }
+        }
+
+        for (int i = fromIndex; i < toIndex - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            if (a[i] != (long) 0xDEDA) {
+                failed("Range sort changes right element on position " + i +
+                    ": " + a[i] + ", must be " + 0xDEDA);
+            }
+        }
+    }
+
+    private static void checkSubArray(char[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            if (a[i] != (char) 0xBABA) {
+                failed("Range sort changes left element on position " + i +
+                    ": " + a[i] + ", must be " + 0xBABA);
+            }
+        }
+
+        for (int i = fromIndex; i < toIndex - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            if (a[i] != (char) 0xDEDA) {
+                failed("Range sort changes right element on position " + i +
+                    ": " + a[i] + ", must be " + 0xDEDA);
+            }
+        }
+    }
+
+    private static void checkSubArray(short[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            if (a[i] != (short) 0xBABA) {
+                failed("Range sort changes left element on position " + i +
+                    ": " + a[i] + ", must be " + 0xBABA);
+            }
+        }
+
+        for (int i = fromIndex; i < toIndex - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            if (a[i] != (short) 0xDEDA) {
+                failed("Range sort changes right element on position " + i +
+                    ": " + a[i] + ", must be " + 0xDEDA);
+            }
+        }
+    }
+
+    private static void checkSubArray(float[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            if (a[i] != (float) 0xBABA) {
+                failed("Range sort changes left element on position " + i +
+                    ": " + a[i] + ", must be " + 0xBABA);
+            }
+        }
+
+        for (int i = fromIndex; i < toIndex - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            if (a[i] != (float) 0xDEDA) {
+                failed("Range sort changes right element on position " + i +
+                    ": " + a[i] + ", must be " + 0xDEDA);
+            }
+        }
+    }
+
+    private static void checkSubArray(double[] a, int fromIndex, int toIndex, int m) {
+        for (int i = 0; i < fromIndex; i++) {
+            if (a[i] != (double) 0xBABA) {
+                failed("Range sort changes left element on position " + i +
+                    ": " + a[i] + ", must be " + 0xBABA);
+            }
+        }
+
+        for (int i = fromIndex; i < toIndex - 1; i++) {
+            if (a[i] > a[i + 1]) {
+                failed(i, "" + a[i], "" + a[i + 1]);
+            }
+        }
+
+        for (int i = toIndex; i < a.length; i++) {
+            if (a[i] != (double) 0xDEDA) {
+                failed("Range sort changes right element on position " + i +
+                    ": " + a[i] + ", must be " + 0xDEDA);
+            }
+        }
+    }
+
+    private static void sortRange(Object object, int m) {
+        if (object instanceof int[]) {
+            sortRange((int[]) object, m);
+        } else if (object instanceof long[]) {
+            sortRange((long[]) object, m);
+        } else if (object instanceof short[]) {
+            sortRange((short[]) object, m);
+        } else if (object instanceof byte[]) {
+            sortRange((byte[]) object, m);
+        } else if (object instanceof char[]) {
+            sortRange((char[]) object, m);
+        } else if (object instanceof float[]) {
+            sortRange((float[]) object, m);
+        } else if (object instanceof double[]) {
+            sortRange((double[]) object, m);
+        } else {
+            failed("Unknow type of array: " + object + " of class " +
+                object.getClass().getName());
+        }
+    }
+
+    private static void sortEmpty(Object object) {
+        if (object instanceof int[]) {
+            Arrays.sort(new int [] {});
+        } else if (object instanceof long[]) {
+            Arrays.sort(new long [] {});
+        } else if (object instanceof short[]) {
+            Arrays.sort(new short [] {});
+        } else if (object instanceof byte[]) {
+            Arrays.sort(new byte [] {});
+        } else if (object instanceof char[]) {
+            Arrays.sort(new char [] {});
+        } else if (object instanceof float[]) {
+            Arrays.sort(new float [] {});
+        } else if (object instanceof double[]) {
+            Arrays.sort(new double [] {});
+        } else {
+            failed("Unknow type of array: " + object + " of class " +
+                object.getClass().getName());
+        }
+    }
+
+    private static void sortRange(int[] a, int m) {
+        try {
+            Arrays.sort(a, m + 1, m);
+
+            failed("Sort does not throw IllegalArgumentException " +
+                " as expected: fromIndex = " + (m + 1) +
+                " toIndex = " + m);
+        }
+        catch (IllegalArgumentException iae) {
+            try {
+                Arrays.sort(a, -m, a.length);
+
+                failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                    " as expected: fromIndex = " + (-m));
+            }
+            catch (ArrayIndexOutOfBoundsException aoe) {
+                try {
+                    Arrays.sort(a, 0, a.length + m);
+
+                    failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                        " as expected: toIndex = " + (a.length + m));
+                }
+                catch (ArrayIndexOutOfBoundsException aie) {
+                    return;
+                }
+            }
+        }
+    }
+
+    private static void sortRange(long[] a, int m) {
+        try {
+            Arrays.sort(a, m + 1, m);
+
+            failed("Sort does not throw IllegalArgumentException " +
+                " as expected: fromIndex = " + (m + 1) +
+                " toIndex = " + m);
+        }
+        catch (IllegalArgumentException iae) {
+            try {
+                Arrays.sort(a, -m, a.length);
+
+                failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                    " as expected: fromIndex = " + (-m));
+            }
+            catch (ArrayIndexOutOfBoundsException aoe) {
+                try {
+                    Arrays.sort(a, 0, a.length + m);
+
+                    failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                        " as expected: toIndex = " + (a.length + m));
+                }
+                catch (ArrayIndexOutOfBoundsException aie) {
+                    return;
+                }
+            }
+        }
+    }
+
+    private static void sortRange(byte[] a, int m) {
+        try {
+            Arrays.sort(a, m + 1, m);
+
+            failed("Sort does not throw IllegalArgumentException " +
+                " as expected: fromIndex = " + (m + 1) +
+                " toIndex = " + m);
+        }
+        catch (IllegalArgumentException iae) {
+            try {
+                Arrays.sort(a, -m, a.length);
+
+                failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                    " as expected: fromIndex = " + (-m));
+            }
+            catch (ArrayIndexOutOfBoundsException aoe) {
+                try {
+                    Arrays.sort(a, 0, a.length + m);
+
+                    failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                        " as expected: toIndex = " + (a.length + m));
+                }
+                catch (ArrayIndexOutOfBoundsException aie) {
+                    return;
+                }
+            }
+        }
+    }
+
+    private static void sortRange(short[] a, int m) {
+        try {
+            Arrays.sort(a, m + 1, m);
+
+            failed("Sort does not throw IllegalArgumentException " +
+                " as expected: fromIndex = " + (m + 1) +
+                " toIndex = " + m);
+        }
+        catch (IllegalArgumentException iae) {
+            try {
+                Arrays.sort(a, -m, a.length);
+
+                failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                    " as expected: fromIndex = " + (-m));
+            }
+            catch (ArrayIndexOutOfBoundsException aoe) {
+                try {
+                    Arrays.sort(a, 0, a.length + m);
+
+                    failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                        " as expected: toIndex = " + (a.length + m));
+                }
+                catch (ArrayIndexOutOfBoundsException aie) {
+                    return;
+                }
+            }
+        }
+    }
+
+    private static void sortRange(char[] a, int m) {
+        try {
+            Arrays.sort(a, m + 1, m);
+
+            failed("Sort does not throw IllegalArgumentException " +
+                " as expected: fromIndex = " + (m + 1) +
+                " toIndex = " + m);
+        }
+        catch (IllegalArgumentException iae) {
+            try {
+                Arrays.sort(a, -m, a.length);
+
+                failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                    " as expected: fromIndex = " + (-m));
+            }
+            catch (ArrayIndexOutOfBoundsException aoe) {
+                try {
+                    Arrays.sort(a, 0, a.length + m);
+
+                    failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                        " as expected: toIndex = " + (a.length + m));
+                }
+                catch (ArrayIndexOutOfBoundsException aie) {
+                    return;
+                }
+            }
+        }
+    }
+
+    private static void sortRange(float[] a, int m) {
+        try {
+            Arrays.sort(a, m + 1, m);
+
+            failed("Sort does not throw IllegalArgumentException " +
+                " as expected: fromIndex = " + (m + 1) +
+                " toIndex = " + m);
+        }
+        catch (IllegalArgumentException iae) {
+            try {
+                Arrays.sort(a, -m, a.length);
+
+                failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                    " as expected: fromIndex = " + (-m));
+            }
+            catch (ArrayIndexOutOfBoundsException aoe) {
+                try {
+                    Arrays.sort(a, 0, a.length + m);
+
+                    failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                        " as expected: toIndex = " + (a.length + m));
+                }
+                catch (ArrayIndexOutOfBoundsException aie) {
+                    return;
+                }
+            }
+        }
+    }
+
+    private static void sortRange(double[] a, int m) {
+        try {
+            Arrays.sort(a, m + 1, m);
+
+            failed("Sort does not throw IllegalArgumentException " +
+                " as expected: fromIndex = " + (m + 1) +
+                " toIndex = " + m);
+        }
+        catch (IllegalArgumentException iae) {
+            try {
+                Arrays.sort(a, -m, a.length);
+
+                failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                    " as expected: fromIndex = " + (-m));
+            }
+            catch (ArrayIndexOutOfBoundsException aoe) {
+                try {
+                    Arrays.sort(a, 0, a.length + m);
+
+                    failed("Sort does not throw ArrayIndexOutOfBoundsException " +
+                        " as expected: toIndex = " + (a.length + m));
+                }
+                catch (ArrayIndexOutOfBoundsException aie) {
+                    return;
+                }
+            }
+        }
+    }
+
+    private static void prepareRandom(int[] a) {
+        for (int i = 0; i < a.length; i++) {
+            a[i] = ourRandom.nextInt();
+        }
+    }
+
+    private static void reset(long seed) {
+        ourRandom = new Random(seed);
+        ourFirst = 0;
+        ourSecond = 0;
+    }
+
+    private static void outArr(int[] a) {
+        for (int i = 0; i < a.length; i++) {
+            out.print(a[i] + " ");
+        }
+        out.println();
+        out.println();
+    }
+
+    private static void outArr(float[] a) {
+        for (int i = 0; i < a.length; i++) {
+            out.print(a[i] + " ");
+        }
+        out.println();
+        out.println();
+    }
+
+    private static void outArr(double[] a) {
+        for (int i = 0; i < a.length; i++) {
+            out.print(a[i] + " ");
+        }
+        out.println();
+        out.println();
+    }
+
+    private static int ourFirst;
+    private static int ourSecond;
+    private static Random ourRandom;
+}
--- a/test/java/util/Collection/MOAT.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/util/Collection/MOAT.java	Wed Nov 25 11:08:25 2009 -0800
@@ -421,8 +421,11 @@
 
     private static void testQueue(Queue<Integer> q) {
         q.clear();
-        for (int i = 0; i < 5; i++)
+        for (int i = 0; i < 5; i++) {
+            testQueueAddRemove(q, null);
+            testQueueAddRemove(q, 537);
             q.add(i);
+        }
         equal(q.size(), 5);
         checkFunctionalInvariants(q);
         q.poll();
@@ -435,6 +438,216 @@
         }
     }
 
+    private static void testQueueAddRemove(final Queue<Integer> q,
+                                           final Integer e) {
+        final List<Integer> originalContents = new ArrayList<Integer>(q);
+        final boolean isEmpty = q.isEmpty();
+        final boolean isList = (q instanceof List);
+        final List asList = isList ? (List) q : null;
+        check(!q.contains(e));
+        try {
+            q.add(e);
+        } catch (NullPointerException npe) {
+            check(e == null);
+            return;                     // Null elements not supported
+        }
+        check(q.contains(e));
+        check(q.remove(e));
+        check(!q.contains(e));
+        equal(new ArrayList<Integer>(q), originalContents);
+
+        if (q instanceof Deque<?>) {
+            final Deque<Integer> deq = (Deque<Integer>) q;
+            final List<Integer> singleton = Collections.singletonList(e);
+
+            // insert, query, remove element at head
+            if (isEmpty) {
+                THROWS(NoSuchElementException.class,
+                       new Fun(){void f(){ deq.getFirst(); }},
+                       new Fun(){void f(){ deq.element(); }},
+                       new Fun(){void f(){ deq.iterator().next(); }});
+                check(deq.peekFirst() == null);
+                check(deq.peek() == null);
+            } else {
+                check(deq.getFirst() != e);
+                check(deq.element() != e);
+                check(deq.iterator().next() != e);
+                check(deq.peekFirst() != e);
+                check(deq.peek() != e);
+            }
+            check(!deq.contains(e));
+            check(!deq.removeFirstOccurrence(e));
+            check(!deq.removeLastOccurrence(e));
+            if (isList) {
+                check(asList.indexOf(e) == -1);
+                check(asList.lastIndexOf(e) == -1);
+            }
+            switch (rnd.nextInt(isList ? 4 : 3)) {
+            case 0: deq.addFirst(e); break;
+            case 1: check(deq.offerFirst(e)); break;
+            case 2: deq.push(e); break;
+            case 3: asList.add(0, e); break;
+            default: throw new AssertionError();
+            }
+            check(deq.peekFirst() == e);
+            check(deq.getFirst() == e);
+            check(deq.element() == e);
+            check(deq.peek() == e);
+            check(deq.iterator().next() == e);
+            check(deq.contains(e));
+            if (isList) {
+                check(asList.get(0) == e);
+                check(asList.indexOf(e) == 0);
+                check(asList.lastIndexOf(e) == 0);
+                check(asList.subList(0, 1).equals(singleton));
+            }
+            switch (rnd.nextInt(isList ? 11 : 9)) {
+            case 0: check(deq.pollFirst() == e); break;
+            case 1: check(deq.removeFirst() == e); break;
+            case 2: check(deq.remove() == e); break;
+            case 3: check(deq.pop() == e); break;
+            case 4: check(deq.removeFirstOccurrence(e)); break;
+            case 5: check(deq.removeLastOccurrence(e)); break;
+            case 6: check(deq.remove(e)); break;
+            case 7: check(deq.removeAll(singleton)); break;
+            case 8: Iterator it = deq.iterator(); it.next(); it.remove(); break;
+            case 9: asList.remove(0); break;
+            case 10: asList.subList(0, 1).clear(); break;
+            default: throw new AssertionError();
+            }
+            if (isEmpty) {
+                THROWS(NoSuchElementException.class,
+                       new Fun(){void f(){ deq.getFirst(); }},
+                       new Fun(){void f(){ deq.element(); }},
+                       new Fun(){void f(){ deq.iterator().next(); }});
+                check(deq.peekFirst() == null);
+                check(deq.peek() == null);
+            } else {
+                check(deq.getFirst() != e);
+                check(deq.element() != e);
+                check(deq.iterator().next() != e);
+                check(deq.peekFirst() != e);
+                check(deq.peek() != e);
+            }
+            check(!deq.contains(e));
+            check(!deq.removeFirstOccurrence(e));
+            check(!deq.removeLastOccurrence(e));
+            if (isList) {
+                check(isEmpty || asList.get(0) != e);
+                check(asList.indexOf(e) == -1);
+                check(asList.lastIndexOf(e) == -1);
+            }
+            equal(new ArrayList<Integer>(deq), originalContents);
+
+            // insert, query, remove element at tail
+            if (isEmpty) {
+                check(deq.peekLast() == null);
+                THROWS(NoSuchElementException.class,
+                       new Fun(){void f(){ deq.getLast(); }});
+            } else {
+                check(deq.peekLast() != e);
+                check(deq.getLast() != e);
+            }
+            switch (rnd.nextInt(isList ? 6 : 4)) {
+            case 0: deq.addLast(e); break;
+            case 1: check(deq.offerLast(e)); break;
+            case 2: check(deq.add(e)); break;
+            case 3: deq.addAll(singleton); break;
+            case 4: asList.addAll(deq.size(), singleton); break;
+            case 5: asList.add(deq.size(), e); break;
+            default: throw new AssertionError();
+            }
+            check(deq.peekLast() == e);
+            check(deq.getLast() == e);
+            check(deq.contains(e));
+            if (isList) {
+                ListIterator it = asList.listIterator(asList.size());
+                check(it.previous() == e);
+                check(asList.get(asList.size() - 1) == e);
+                check(asList.indexOf(e) == asList.size() - 1);
+                check(asList.lastIndexOf(e) == asList.size() - 1);
+                int size = asList.size();
+                check(asList.subList(size - 1, size).equals(singleton));
+            }
+            switch (rnd.nextInt(isList ? 8 : 6)) {
+            case 0: check(deq.pollLast() == e); break;
+            case 1: check(deq.removeLast() == e); break;
+            case 2: check(deq.removeFirstOccurrence(e)); break;
+            case 3: check(deq.removeLastOccurrence(e)); break;
+            case 4: check(deq.remove(e)); break;
+            case 5: check(deq.removeAll(singleton)); break;
+            case 6: asList.remove(asList.size() - 1); break;
+            case 7:
+                ListIterator it = asList.listIterator(asList.size());
+                it.previous();
+                it.remove();
+                break;
+            default: throw new AssertionError();
+            }
+            if (isEmpty) {
+                check(deq.peekLast() == null);
+                THROWS(NoSuchElementException.class,
+                       new Fun(){void f(){ deq.getLast(); }});
+            } else {
+                check(deq.peekLast() != e);
+                check(deq.getLast() != e);
+            }
+            check(!deq.contains(e));
+            equal(new ArrayList<Integer>(deq), originalContents);
+
+            // Test operations on empty deque
+            switch (rnd.nextInt(isList ? 4 : 2)) {
+            case 0: deq.clear(); break;
+            case 1:
+                Iterator it = deq.iterator();
+                while (it.hasNext()) {
+                    it.next();
+                    it.remove();
+                }
+                break;
+            case 2: asList.subList(0, asList.size()).clear(); break;
+            case 3:
+                ListIterator lit = asList.listIterator(asList.size());
+                while (lit.hasPrevious()) {
+                    lit.previous();
+                    lit.remove();
+                }
+                break;
+            default: throw new AssertionError();
+            }
+            testEmptyCollection(deq);
+            check(!deq.iterator().hasNext());
+            if (isList) {
+                check(!asList.listIterator().hasPrevious());
+                THROWS(NoSuchElementException.class,
+                       new Fun(){void f(){ asList.listIterator().previous(); }});
+            }
+            THROWS(NoSuchElementException.class,
+                   new Fun(){void f(){ deq.iterator().next(); }},
+                   new Fun(){void f(){ deq.element(); }},
+                   new Fun(){void f(){ deq.getFirst(); }},
+                   new Fun(){void f(){ deq.getLast(); }},
+                   new Fun(){void f(){ deq.pop(); }},
+                   new Fun(){void f(){ deq.remove(); }},
+                   new Fun(){void f(){ deq.removeFirst(); }},
+                   new Fun(){void f(){ deq.removeLast(); }});
+
+            check(deq.poll() == null);
+            check(deq.pollFirst() == null);
+            check(deq.pollLast() == null);
+            check(deq.peek() == null);
+            check(deq.peekFirst() == null);
+            check(deq.peekLast() == null);
+            check(!deq.removeFirstOccurrence(e));
+            check(!deq.removeLastOccurrence(e));
+
+            check(deq.addAll(originalContents) == !isEmpty);
+            equal(new ArrayList<Integer>(deq), originalContents);
+            check(!deq.addAll(Collections.<Integer>emptyList()));
+            equal(new ArrayList<Integer>(deq), originalContents);
+        }
+    }
+
     private static void testQueueIteratorRemove(Queue<Integer> q) {
         System.err.printf("testQueueIteratorRemove %s%n",
                           q.getClass().getSimpleName());
--- a/test/java/util/Objects/BasicObjectsTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/util/Objects/BasicObjectsTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6797535
+ * @bug 6797535 6889858 6891113
  * @summary Basic tests for methods in java.util.Objects
  * @author  Joseph D. Darcy
  */
@@ -34,8 +34,11 @@
     public static void main(String... args) {
         int errors = 0;
         errors += testEquals();
+        errors += testDeepEquals();
         errors += testHashCode();
+        errors += testHash();
         errors += testToString();
+        errors += testToString2();
         errors += testCompare();
         errors += testNonNull();
         if (errors > 0 )
@@ -60,6 +63,36 @@
         return errors;
     }
 
+    private static int testDeepEquals() {
+        int errors = 0;
+        Object[] values = {null,
+                           null, // Change to values later
+                           new byte[]  {(byte)1},
+                           new short[] {(short)1},
+                           new int[]   {1},
+                           new long[]  {1L},
+                           new char[]  {(char)1},
+                           new float[] {1.0f},
+                           new double[]{1.0d},
+                           new String[]{"one"}};
+        values[1] = values;
+
+        for(int i = 0; i < values.length; i++)
+            for(int j = 0; j < values.length; j++) {
+                boolean expected = (i == j);
+                Object a = values[i];
+                Object b = values[j];
+                boolean result = Objects.deepEquals(a, b);
+                if (result != expected) {
+                    errors++;
+                    System.err.printf("When equating %s to %s, got %b instead of %b%n.",
+                                      a, b, result, expected);
+                }
+            }
+
+        return errors;
+    }
+
     private static int testHashCode() {
         int errors = 0;
         errors += (Objects.hashCode(null) == 0 ) ? 0 : 1;
@@ -68,6 +101,19 @@
         return errors;
     }
 
+    private static int testHash() {
+        int errors = 0;
+
+        Object[] data = new String[]{"perfect", "ham", "THC"};
+
+        errors += ((Objects.hash((Object[])null) == 0) ? 0 : 1);
+
+        errors += (Objects.hash("perfect", "ham", "THC") ==
+                   Arrays.hashCode(data)) ? 0 : 1;
+
+        return errors;
+    }
+
     private static int testToString() {
         int errors = 0;
         errors += ("null".equals(Objects.toString(null)) ) ? 0 : 1;
@@ -76,6 +122,14 @@
         return errors;
     }
 
+    private static int testToString2() {
+        int errors = 0;
+        String s = "not the default";
+        errors += (s.equals(Objects.toString(null, s)) ) ? 0 : 1;
+        errors += (s.equals(Objects.toString(s, "another string")) ) ? 0 : 1;
+        return errors;
+    }
+
     private static int testCompare() {
         int errors = 0;
         String[] values = {"e. e. cummings", "zzz"};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/logging/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,279 @@
+/*
+ * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along 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     6876135
+ *
+ * @summary Test PlatformLoggingMXBean
+ *          This test performs similar testing as LoggingMXBeanTest.
+ *
+ * @build PlatformLoggingMXBeanTest
+ * @run main PlatformLoggingMXBeanTest
+ */
+
+import javax.management.*;
+import java.lang.management.ManagementFactory;
+import java.util.logging.*;
+import java.util.List;
+
+public class PlatformLoggingMXBeanTest
+{
+
+    ObjectName objectName = null;
+    static String LOGGER_NAME_1 = "com.sun.management.Logger1";
+    static String LOGGER_NAME_2 = "com.sun.management.Logger2";
+
+    public PlatformLoggingMXBeanTest() throws Exception {
+    }
+
+    private void runTest(PlatformLoggingMXBean mBean) throws Exception {
+
+        /*
+         * Create the MBeanServeri, register the PlatformLoggingMXBean
+         */
+        System.out.println( "***************************************************" );
+        System.out.println( "********** PlatformLoggingMXBean Unit Test **********" );
+        System.out.println( "***************************************************" );
+        System.out.println( "" );
+        System.out.println( "*******************************" );
+        System.out.println( "*********** Phase 1 ***********" );
+        System.out.println( "*******************************" );
+        System.out.println( "    Creating MBeanServer " );
+        System.out.print( "    Register PlatformLoggingMXBean: " );
+        MBeanServer mbs = MBeanServerFactory.createMBeanServer();
+        String[] list = new String[0];
+
+        try {
+            objectName = new ObjectName(LogManager.LOGGING_MXBEAN_NAME);
+            mbs.registerMBean( mBean, objectName );
+        }
+        catch ( Exception e ) {
+            System.out.println( "FAILED" );
+            throw e;
+        }
+        System.out.println( "PASSED" );
+        System.out.println("");
+
+        /*
+         * Access our MBean to get the current list of Loggers
+         */
+        System.out.println( "*******************************" );
+        System.out.println( "*********** Phase 2 ***********" );
+        System.out.println( "*******************************" );
+        System.out.println( "   Test Logger Name retrieval (getLoggerNames) " );
+        // check that Level object are returned properly
+        try {
+            list = (String[]) mbs.getAttribute( objectName,  "LoggerNames" );
+        }
+        catch ( Exception e ) {
+            System.out.println("    : FAILED" );
+            throw e;
+        }
+
+        /*
+         * Dump the list of Loggers already present, if any
+         */
+        Object[] params =  new Object[1];
+        String[] signature =  new String[1];
+        Level l;
+
+        if ( list == null ) {
+            System.out.println("    : PASSED.  No Standard Loggers Present" );
+            System.out.println("");
+        }
+        else {
+            System.out.println("    : PASSED. There are " + list.length + " Loggers Present" );
+            System.out.println("");
+            System.out.println( "*******************************" );
+            System.out.println( "*********** Phase 2B **********" );
+            System.out.println( "*******************************" );
+            System.out.println( " Examine Existing Loggers" );
+            for ( int i = 0; i < list.length; i++ ) {
+                try {
+                    params[0] = list[i];
+                    signature[0] = "java.lang.String";
+                    String levelName = (String) mbs.invoke(  objectName, "getLoggerLevel", params, signature );
+                    System.out.println("    : Logger #" + i + " = " + list[i] );
+                    System.out.println("    : Level = " + levelName );
+                }
+                catch ( Exception e ) {
+                    System.out.println("    : FAILED" );
+                    throw e;
+                }
+            }
+            System.out.println("    : PASSED" );
+        }
+
+        /*
+         * Create two new loggers to the list of Loggers already present
+         */
+        System.out.println("");
+        System.out.println( "*******************************" );
+        System.out.println( "*********** Phase 3 ***********" );
+        System.out.println( "*******************************" );
+        System.out.println( " Create and test new Loggers" );
+        Logger logger1 = Logger.getLogger( LOGGER_NAME_1 );
+        Logger logger2 = Logger.getLogger( LOGGER_NAME_2 );
+
+        // check that Level object are returned properly
+        try {
+            list = (String[]) mbs.getAttribute( objectName,  "LoggerNames" );
+        }
+        catch ( Exception e ) {
+            System.out.println("    : FAILED" );
+            throw e;
+        }
+
+        /*
+         *  Check for the existence of our new Loggers
+         */
+        boolean log1 = false, log2 = false;
+
+        if ( list == null || list.length < 2 ) {
+            System.out.println("    : FAILED.  Could not Detect the presense of the new Loggers" );
+            throw new RuntimeException(
+                "Could not Detect the presense of the new Loggers");
+        }
+        else {
+            for ( int i = 0; i < list.length; i++ ) {
+                if ( list[i].equals( LOGGER_NAME_1 ) ) {
+                    log1 = true;
+                    System.out.println( "    : Found new Logger : " + list[i] );
+                }
+                if ( list[i].equals( LOGGER_NAME_2 ) ) {
+                    log2 = true;
+                    System.out.println( "    : Found new Logger : " + list[i] );
+                }
+            }
+            if ( log1 && log2 )
+                System.out.println( "    : PASSED." );
+            else {
+                System.out.println( "    : FAILED.  Could not Detect the new Loggers." );
+                throw new RuntimeException(
+                    "Could not Detect the presense of the new Loggers");
+            }
+        }
+
+        /*
+         *  Set a new Logging levels and check that it succeeded
+         */
+        System.out.println("");
+        System.out.println( "*******************************" );
+        System.out.println( "*********** Phase 4 ***********" );
+        System.out.println( "*******************************" );
+        System.out.println( " Set and Check the Logger Level" );
+        log1 = false;
+        log2 = false;
+        try {
+            // Set the level of logger1 to ALL
+            params = new Object[2];
+            signature =  new String[2];
+            params[0] = LOGGER_NAME_1;
+            params[1] = Level.ALL.getName();
+            signature[0] = "java.lang.String";
+            signature[1] = "java.lang.String";
+            mbs.invoke(  objectName, "setLoggerLevel", params, signature );
+
+            // Set the level of logger2 to FINER
+            params[0] = LOGGER_NAME_2;
+            params[1] = Level.FINER.getName();
+            mbs.invoke(  objectName, "setLoggerLevel", params, signature );
+
+            // Okay read back the Level from Logger1. Should be ALL
+            params =  new Object[1];
+            signature =  new String[1];
+            params[0] = LOGGER_NAME_1;
+            signature[0] = "java.lang.String";
+            String levelName = (String) mbs.invoke(  objectName, "getLoggerLevel", params, signature );
+            l = Level.parse(levelName);
+            System.out.print("    Logger1: " );
+            if ( l.equals( l.ALL ) ) {
+                System.out.println("Level Set to ALL: PASSED" );
+                log1 = true;
+            }
+            else {
+                System.out.println("Level Set to ALL: FAILED" );
+                throw new RuntimeException(
+                    "Level Set to ALL but returned " + l.toString());
+            }
+
+            // Okay read back the Level from Logger2. Should be FINER
+            params =  new Object[1];
+            signature =  new String[1];
+            params[0] = LOGGER_NAME_2;
+            signature[0] = "java.lang.String";
+            levelName = (String) mbs.invoke(  objectName, "getLoggerLevel", params, signature );
+            l = Level.parse(levelName);
+            System.out.print("    Logger2: " );
+            if ( l.equals( l.FINER ) ) {
+                System.out.println("Level Set to FINER: PASSED" );
+                log2 = true;
+            }
+            else {
+                System.out.println("Level Set to FINER: FAILED" );
+                throw new RuntimeException(
+                    "Level Set to FINER but returned " + l.toString());
+            }
+        }
+        catch ( Exception e ) {
+            throw e;
+        }
+
+        System.out.println( "" );
+        System.out.println( "***************************************************" );
+        System.out.println( "***************** All Tests Passed ****************" );
+        System.out.println( "***************************************************" );
+    }
+
+    public static void main(String[] argv) throws Exception {
+        List<PlatformLoggingMXBean> result =
+            ManagementFactory.getPlatformMXBeans(PlatformLoggingMXBean.class);
+        if (result.size() != 1) {
+            throw new RuntimeException("Unexpected number of PlatformLoggingMXBean instances: " +
+                result.size());
+        }
+
+        PlatformLoggingMXBean mbean = result.get(0);
+        ObjectName objname = mbean.getObjectName();
+        if (!objname.equals(new ObjectName(LogManager.LOGGING_MXBEAN_NAME))) {
+            throw new RuntimeException("Invalid ObjectName " + objname);
+        }
+
+        // check if the PlatformLoggingMXBean is registered in the platform MBeanServer
+        MBeanServer platformMBS = ManagementFactory.getPlatformMBeanServer();
+        ObjectName objName = new ObjectName(LogManager.LOGGING_MXBEAN_NAME);
+        // We could call mbs.isRegistered(objName) here.
+        // Calling getMBeanInfo will throw exception if not found.
+        platformMBS.getMBeanInfo(objName);
+
+        if (!platformMBS.isInstanceOf(objName, "java.util.logging.PlatformLoggingMXBean") ||
+            !platformMBS.isInstanceOf(objName, "java.util.logging.LoggingMXBean")) {
+            throw new RuntimeException(objName + " is of unexpected type");
+        }
+
+        // test if PlatformLoggingMXBean works properly in a MBeanServer
+        PlatformLoggingMXBeanTest test = new PlatformLoggingMXBeanTest();
+        test.runTest(mbean);
+    }
+}
--- a/test/java/util/regex/RegExTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/util/regex/RegExTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,7 +32,7 @@
  * 4872664 4803179 4892980 4900747 4945394 4938995 4979006 4994840 4997476
  * 5013885 5003322 4988891 5098443 5110268 6173522 4829857 5027748 6376940
  * 6358731 6178785 6284152 6231989 6497148 6486934 6233084 6504326 6635133
- * 6350801 6676425
+ * 6350801 6676425 6878475
  */
 
 import java.util.regex.*;
@@ -3389,9 +3389,9 @@
               "gname",
               "yyy");
 
-        check(Pattern.compile("x+(?<8gname>y+)z+"),
+        check(Pattern.compile("x+(?<gname8>y+)z+"),
               "xxxyyyzzz",
-              "8gname",
+              "gname8",
               "yyy");
 
         //backref
@@ -3430,81 +3430,82 @@
         //replaceFirst/All
         checkReplaceFirst("(?<gn>ab)(c*)",
                           "abccczzzabcczzzabccc",
-                          "$<gn>",
+                          "${gn}",
                           "abzzzabcczzzabccc");
 
         checkReplaceAll("(?<gn>ab)(c*)",
                         "abccczzzabcczzzabccc",
-                        "$<gn>",
+                        "${gn}",
                         "abzzzabzzzab");
 
 
         checkReplaceFirst("(?<gn>ab)(c*)",
                           "zzzabccczzzabcczzzabccczzz",
-                          "$<gn>",
+                          "${gn}",
                           "zzzabzzzabcczzzabccczzz");
 
         checkReplaceAll("(?<gn>ab)(c*)",
                         "zzzabccczzzabcczzzabccczzz",
-                        "$<gn>",
+                        "${gn}",
                         "zzzabzzzabzzzabzzz");
 
         checkReplaceFirst("(?<gn1>ab)(?<gn2>c*)",
                           "zzzabccczzzabcczzzabccczzz",
-                          "$<gn2>",
+                          "${gn2}",
                           "zzzccczzzabcczzzabccczzz");
 
         checkReplaceAll("(?<gn1>ab)(?<gn2>c*)",
                         "zzzabccczzzabcczzzabccczzz",
-                        "$<gn2>",
+                        "${gn2}",
                         "zzzccczzzcczzzccczzz");
 
         //toSupplementaries("(ab)(c*)"));
         checkReplaceFirst("(?<gn1>" + toSupplementaries("ab") +
                            ")(?<gn2>" + toSupplementaries("c") + "*)",
                           toSupplementaries("abccczzzabcczzzabccc"),
-                          "$<gn1>",
+                          "${gn1}",
                           toSupplementaries("abzzzabcczzzabccc"));
 
 
         checkReplaceAll("(?<gn1>" + toSupplementaries("ab") +
                         ")(?<gn2>" + toSupplementaries("c") + "*)",
                         toSupplementaries("abccczzzabcczzzabccc"),
-                        "$<gn1>",
+                        "${gn1}",
                         toSupplementaries("abzzzabzzzab"));
 
         checkReplaceFirst("(?<gn1>" + toSupplementaries("ab") +
                            ")(?<gn2>" + toSupplementaries("c") + "*)",
                           toSupplementaries("abccczzzabcczzzabccc"),
-                          "$<gn2>",
+                          "${gn2}",
                           toSupplementaries("ccczzzabcczzzabccc"));
 
 
         checkReplaceAll("(?<gn1>" + toSupplementaries("ab") +
                         ")(?<gn2>" + toSupplementaries("c") + "*)",
                         toSupplementaries("abccczzzabcczzzabccc"),
-                        "$<gn2>",
+                        "${gn2}",
                         toSupplementaries("ccczzzcczzzccc"));
 
         checkReplaceFirst("(?<dog>Dog)AndCat",
                           "zzzDogAndCatzzzDogAndCatzzz",
-                          "$<dog>",
+                          "${dog}",
                           "zzzDogzzzDogAndCatzzz");
 
 
         checkReplaceAll("(?<dog>Dog)AndCat",
                           "zzzDogAndCatzzzDogAndCatzzz",
-                          "$<dog>",
+                          "${dog}",
                           "zzzDogzzzDogzzz");
 
         // backref in Matcher & String
-        if (!"abcdefghij".replaceFirst("cd(?<gn>ef)gh", "$<gn>").equals("abefij") ||
-            !"abbbcbdbefgh".replaceAll("(?<gn>[a-e])b", "$<gn>").equals("abcdefgh"))
+        if (!"abcdefghij".replaceFirst("cd(?<gn>ef)gh", "${gn}").equals("abefij") ||
+            !"abbbcbdbefgh".replaceAll("(?<gn>[a-e])b", "${gn}").equals("abcdefgh"))
             failCount++;
 
         // negative
         checkExpectedFail("(?<groupnamehasnoascii.in>abc)(def)");
         checkExpectedFail("(?<groupnamehasnoascii_in>abc)(def)");
+        checkExpectedFail("(?<6groupnamestartswithdigit>abc)(def)");
         checkExpectedFail("(?<gname>abc)(def)\\k<gnameX>");
         checkExpectedFail("(?<gname>abc)(?<gname>def)\\k<gnameX>");
         checkExpectedFail(Pattern.compile("(?<gname>abc)(def)").matcher("abcdef"),
--- a/test/java/util/zip/Bounds.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/java/util/zip/Bounds.java	Wed Nov 25 11:08:25 2009 -0800
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4811913
+ * @bug 4811913 6894950
  * @summary Test bounds checking in zip package
  */
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/util/zip/InflateIn_DeflateOut.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,251 @@
+/*
+ * Copyright 2009 Google, 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 4206909
+ * @summary Test basic functionality of DeflaterOutputStream and InflaterInputStream including flush
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.*;
+
+public class InflateIn_DeflateOut {
+
+    private static class PairedInputStream extends ByteArrayInputStream {
+        private PairedOutputStream out = null;
+        private Random random;
+
+        public PairedInputStream() {
+            // The ByteArrayInputStream needs to start with a buffer, but we
+            // need to set it to have no data
+            super(new byte[1]);
+            count = 0;
+            pos = 0;
+            random = new Random(new Date().getTime());
+        }
+
+        public void setPairedOutputStream(PairedOutputStream out) {
+            this.out = out;
+        }
+
+        private void maybeFlushPair() {
+            if (random.nextInt(100) < 10) {
+                out.flush();
+            }
+        }
+
+        public int read() {
+            maybeFlushPair();
+            return super.read();
+        }
+
+        public int read(byte b[], int off, int len) {
+            maybeFlushPair();
+            return super.read(b, off, len);
+        }
+
+        public void addBytes(byte[] bytes, int len) {
+            int oldavail = count - pos;
+            int newcount = oldavail + len;
+            byte[] newbuf = new byte[newcount];
+            System.arraycopy(buf, pos, newbuf, 0, oldavail);
+            System.arraycopy(bytes, 0, newbuf, oldavail, len);
+            pos = 0;
+            count = newcount;
+            buf = newbuf;
+        }
+    }
+
+    private static class PairedOutputStream extends ByteArrayOutputStream {
+      private PairedInputStream pairedStream = null;
+
+      public PairedOutputStream(PairedInputStream inputPair) {
+        super();
+        this.pairedStream = inputPair;
+      }
+
+      public void flush() {
+        if (count > 0) {
+          pairedStream.addBytes(buf, count);
+          reset();
+        }
+      }
+
+      public void close() {
+        flush();
+      }
+    }
+
+    private static boolean readFully(InputStream in, byte[] buf, int length)
+            throws IOException {
+        int pos = 0;
+        int n;
+        while ((n = in.read(buf, pos, length - pos)) > 0) {
+            pos += n;
+            if (pos == length) return true;
+        }
+        return false;
+    }
+
+    private static boolean readLineIfAvailable(InputStream in, StringBuilder sb)
+            throws IOException {
+        try {
+            while (in.available() > 0) {
+                int i = in.read();
+                if (i < 0) break;
+                char c = (char) (((byte) i) & 0xff);
+                sb.append(c);
+                if (c == '\n') return true;
+            }
+        } catch (EOFException e) {
+          // empty
+        }
+        return false;
+    }
+
+    /** Check that written, closed and read */
+    private static void WriteCloseRead() throws Throwable {
+        Random random = new Random(new Date().getTime());
+
+        PairedInputStream pis = new PairedInputStream();
+        InflaterInputStream iis = new InflaterInputStream(pis);
+
+        PairedOutputStream pos = new PairedOutputStream(pis);
+        pis.setPairedOutputStream(pos);
+        DeflaterOutputStream dos = new DeflaterOutputStream(pos, true);
+
+        byte[] data = new byte[random.nextInt(1024 * 1024)];
+        byte[] buf = new byte[data.length];
+        random.nextBytes(data);
+
+        dos.write(data);
+        dos.close();
+        check(readFully(iis, buf, buf.length));
+        check(Arrays.equals(data, buf));
+    }
+
+    /** Check that written, flushed and read */
+    private static void WriteFlushRead() throws Throwable {
+        Random random = new Random(new Date().getTime());
+
+        PairedInputStream pis = new PairedInputStream();
+        InflaterInputStream iis = new InflaterInputStream(pis);
+
+        PairedOutputStream pos = new PairedOutputStream(pis);
+        pis.setPairedOutputStream(pos);
+        DeflaterOutputStream dos = new DeflaterOutputStream(pos, true);
+
+        // Large writes
+        for (int x = 0; x < 200 ; x++) {
+            // byte[] data = new byte[random.nextInt(1024 * 1024)];
+            byte[] data = new byte[1024];
+            byte[] buf = new byte[data.length];
+            random.nextBytes(data);
+
+            dos.write(data);
+            dos.flush();
+            check(readFully(iis, buf, buf.length));
+            check(Arrays.equals(data, buf));
+        }
+
+        // Small writes
+        for (int x = 0; x < 2000 ; x++) {
+            byte[] data = new byte[random.nextInt(20) + 10];
+            byte[] buf = new byte[data.length];
+            random.nextBytes(data);
+
+            dos.write(data);
+            dos.flush();
+            if (!readFully(iis, buf, buf.length)) {
+                fail("Didn't read full buffer of " + buf.length);
+            }
+            check(Arrays.equals(data, buf));
+        }
+
+        String quit = "QUIT\r\n";
+
+        // Close it out
+        dos.write(quit.getBytes());
+        dos.close();
+
+        StringBuilder sb = new StringBuilder();
+        check(readLineIfAvailable(iis, sb));
+        equal(sb.toString(), quit);
+    }
+
+    /** Validate that we need to use flush at least once on a line
+     * oriented protocol */
+    private static void LineOrientedProtocol() throws Throwable {
+        PairedInputStream pis = new PairedInputStream();
+        InflaterInputStream iis = new InflaterInputStream(pis);
+
+        PairedOutputStream pos = new PairedOutputStream(pis);
+        pis.setPairedOutputStream(pos);
+        DeflaterOutputStream dos = new DeflaterOutputStream(pos, true);
+
+        boolean flushed = false;
+        int count = 0;
+
+        // Do at least a certain number of lines, but too many without a
+        // flush means this test isn't testing anything
+        while ((count < 10 && flushed) || (count < 1000 && !flushed)) {
+            String command = "PING " + count + "\r\n";
+            dos.write(command.getBytes());
+
+            StringBuilder buf = new StringBuilder();
+            if (!readLineIfAvailable(iis, buf)) {
+                flushed = true;
+                dos.flush();
+                check(readLineIfAvailable(iis, buf));
+            }
+            equal(buf.toString(), command);
+            count++;
+        }
+        check(flushed);
+    }
+
+    public static void realMain(String[] args) throws Throwable {
+        WriteCloseRead();
+
+        WriteFlushRead();
+
+        LineOrientedProtocol();
+    }
+
+    //--------------------- Infrastructure ---------------------------
+    static volatile int passed = 0, failed = 0;
+    static void pass() {passed++;}
+    static void fail() {failed++; Thread.dumpStack();}
+    static void fail(String msg) {System.out.println(msg); fail();}
+    static void unexpected(Throwable t) {failed++; t.printStackTrace();}
+    static void check(boolean cond) {if (cond) pass(); else fail();}
+    static void equal(Object x, Object y) {
+        if (x == null ? y == null : x.equals(y)) pass();
+        else fail(x + " not equal to " + y);}
+    public static void main(String[] args) throws Throwable {
+        try {realMain(args);} catch (Throwable t) {unexpected(t);}
+        System.out.println("\nPassed = " + passed + " failed = " + failed);
+        if (failed > 0) throw new AssertionError("Some tests failed");}
+}
--- a/test/javax/management/Introspector/AnnotatedMBeanTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,337 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 %M% %I%
- * @bug 6323980
- * @summary Test MBeans defined with &#64;MBean
- * @author Eamonn McManus
- * @run main/othervm -ea AnnotatedMBeanTest
- */
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import javax.management.Attribute;
-import javax.management.Descriptor;
-import javax.management.DescriptorKey;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MXBean;
-import javax.management.MalformedObjectNameException;
-import javax.management.ManagedAttribute;
-import javax.management.ManagedOperation;
-import javax.management.MBean;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeType;
-
-public class AnnotatedMBeanTest {
-    private static MBeanServer mbs;
-    private static final ObjectName objectName;
-    static {
-        try {
-            objectName = new ObjectName("test:type=Test");
-        } catch (MalformedObjectNameException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        if (!AnnotatedMBeanTest.class.desiredAssertionStatus())
-            throw new Exception("Test must be run with -ea");
-
-        File policyFile = File.createTempFile("jmxperms", ".policy");
-        policyFile.deleteOnExit();
-        PrintWriter pw = new PrintWriter(policyFile);
-        pw.println("grant {");
-        pw.println("    permission javax.management.MBeanPermission \"*\", \"*\";");
-        pw.println("    permission javax.management.MBeanServerPermission \"*\";");
-        pw.println("    permission javax.management.MBeanTrustPermission \"*\";");
-        pw.println("};");
-        pw.close();
-
-        System.setProperty("java.security.policy", policyFile.getAbsolutePath());
-        System.setSecurityManager(new SecurityManager());
-
-        String failure = null;
-
-        for (Method m : AnnotatedMBeanTest.class.getDeclaredMethods()) {
-            if (Modifier.isStatic(m.getModifiers()) &&
-                    m.getName().startsWith("test") &&
-                    m.getParameterTypes().length == 0) {
-                mbs = MBeanServerFactory.newMBeanServer();
-                try {
-                    m.invoke(null);
-                    System.out.println(m.getName() + " OK");
-                } catch (InvocationTargetException ite) {
-                    System.out.println(m.getName() + " got exception:");
-                    Throwable t = ite.getCause();
-                    t.printStackTrace(System.out);
-                    failure = m.getName() + ": " + t.toString();
-                }
-            }
-        }
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    public static class Stats {
-        private final int used;
-        private final int size;
-        private final boolean interesting;
-
-        public Stats(int used, int size, boolean interesting) {
-            this.used = used;
-            this.size = size;
-            this.interesting = interesting;
-        }
-
-        public int getUsed() {
-            return used;
-        }
-
-        public int getSize() {
-            return size;
-        }
-
-        public boolean isInteresting() {
-            return interesting;
-        }
-    }
-
-    @Retention(RetentionPolicy.RUNTIME)
-    public static @interface Units {
-        @DescriptorKey("units")
-        String value();
-    }
-
-    @MBean
-    public static class Cache {
-        private int used = 23;
-        private int size = 99;
-
-        @ManagedAttribute
-        @Units("bytes")
-        public int getUsed() {
-            return used;
-        }
-
-        @ManagedAttribute
-        public int getSize() {
-            return size;
-        }
-
-        @ManagedAttribute
-        public void setSize(int x) {
-            this.size = x;
-        }
-
-        @ManagedAttribute
-        public boolean isInteresting() {
-            return false;
-        }
-
-        @ManagedAttribute
-        public Stats getStats() {
-            return new Stats(used, size, false);
-        }
-
-        @ManagedOperation
-        public int dropOldest(int n) {
-            return 55;
-        }
-
-        private void irrelevantMethod() {}
-        private int getIrrelevant() {return 0;}
-        public int getIrrelevant2() {return 0;}
-
-        public int otherIrrelevantMethod() {return 5;}
-    }
-
-    public static class SubCache extends Cache {
-        // SubCache does not have the @MBean annotation
-        // but its parent does.  It doesn't add any @ManagedAttribute or
-        // @ManagedOperation methods, so its management interface
-        // should be the same.
-        private void irrelevantMethod2() {}
-        public int otherIrrelevantMethod3() {return 0;}
-
-        public int getX() {return 0;}
-        public void setX(int x) {}
-    }
-
-    @MXBean
-    public static class CacheMX {
-        private int used = 23;
-        private int size = 99;
-
-        @ManagedAttribute
-        @Units("bytes")
-        public int getUsed() {
-            return used;
-        }
-
-        @ManagedAttribute
-        public int getSize() {
-            return size;
-        }
-
-        @ManagedAttribute
-        public void setSize(int x) {
-            this.size = x;
-        }
-
-        @ManagedAttribute
-        public boolean isInteresting() {
-            return false;
-        }
-
-        @ManagedAttribute
-        public Stats getStats() {
-            return new Stats(used, size, false);
-        }
-
-        @ManagedOperation
-        public int dropOldest(int n) {
-            return 55;
-        }
-
-        private void irrelevantMethod() {}
-        private int getIrrelevant() {return 0;}
-        public int getIrrelevant2() {return 0;}
-
-        public int otherIrrelevantMethod() {return 5;}
-    }
-
-    public static class SubCacheMX extends CacheMX {
-        private void irrelevantMethod2() {}
-        public int otherIrrelevantMethod3() {return 0;}
-
-        public int getX() {return 0;}
-        public void setX(int x) {}
-    }
-
-    private static void testSimpleManagedResource() throws Exception {
-        testResource(new Cache(), false);
-    }
-
-    private static void testSubclassManagedResource() throws Exception {
-        testResource(new SubCache(), false);
-    }
-
-    private static void testMXBeanResource() throws Exception {
-        testResource(new CacheMX(), true);
-    }
-
-    private static void testSubclassMXBeanResource() throws Exception {
-        testResource(new SubCacheMX(), true);
-    }
-
-    private static void testResource(Object resource, boolean mx) throws Exception {
-        mbs.registerMBean(resource, objectName);
-
-        MBeanInfo mbi = mbs.getMBeanInfo(objectName);
-        assert mbi.getDescriptor().getFieldValue("mxbean").equals(Boolean.toString(mx));
-
-        MBeanAttributeInfo[] mbais = mbi.getAttributes();
-
-        assert mbais.length == 4: mbais.length;
-
-        for (MBeanAttributeInfo mbai : mbais) {
-            String name = mbai.getName();
-            if (name.equals("Used")) {
-                assert mbai.isReadable();
-                assert !mbai.isWritable();
-                assert !mbai.isIs();
-                assert mbai.getType().equals("int");
-                assert "bytes".equals(mbai.getDescriptor().getFieldValue("units"));
-            } else if (name.equals("Size")) {
-                assert mbai.isReadable();
-                assert mbai.isWritable();
-                assert !mbai.isIs();
-                assert mbai.getType().equals("int");
-            } else if (name.equals("Interesting")) {
-                assert mbai.isReadable();
-                assert !mbai.isWritable();
-                assert mbai.isIs();
-                assert mbai.getType().equals("boolean");
-            } else if (name.equals("Stats")) {
-                assert mbai.isReadable();
-                assert !mbai.isWritable();
-                assert !mbai.isIs();
-                Descriptor d = mbai.getDescriptor();
-                if (mx) {
-                    assert mbai.getType().equals(CompositeData.class.getName());
-                    assert d.getFieldValue("originalType").equals(Stats.class.getName());
-                    CompositeType ct = (CompositeType) d.getFieldValue("openType");
-                    Set<String> names = new HashSet<String>(
-                            Arrays.asList("used", "size", "interesting"));
-                    assert ct.keySet().equals(names) : ct.keySet();
-                } else {
-                    assert mbai.getType().equals(Stats.class.getName());
-                }
-            } else
-                assert false : name;
-        }
-
-        MBeanOperationInfo[] mbois = mbi.getOperations();
-
-        assert mbois.length == 1: mbois.length;
-
-        MBeanOperationInfo mboi = mbois[0];
-        assert mboi.getName().equals("dropOldest");
-        assert mboi.getReturnType().equals("int");
-        MBeanParameterInfo[] mbpis = mboi.getSignature();
-        assert mbpis.length == 1: mbpis.length;
-        assert mbpis[0].getType().equals("int");
-
-        assert mbs.getAttribute(objectName, "Used").equals(23);
-
-        assert mbs.getAttribute(objectName, "Size").equals(99);
-        mbs.setAttribute(objectName, new Attribute("Size", 55));
-        assert mbs.getAttribute(objectName, "Size").equals(55);
-
-        assert mbs.getAttribute(objectName, "Interesting").equals(false);
-
-        Object stats = mbs.getAttribute(objectName, "Stats");
-        assert (mx ? CompositeData.class : Stats.class).isInstance(stats) : stats.getClass();
-
-        int ret = (Integer) mbs.invoke(
-                objectName, "dropOldest", new Object[] {66}, new String[] {"int"});
-        assert ret == 55;
-    }
-}
--- a/test/javax/management/Introspector/AnnotatedNotificationInfoTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,442 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 6323980 6772779
- * @summary Test &#64;NotificationInfo annotation
- * @author Eamonn McManus
- * @run main/othervm -ea AnnotatedNotificationInfoTest
- */
-
-import java.io.Serializable;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Field;
-import java.util.Arrays;
-import javax.annotation.Resource;
-import javax.management.AttributeChangeNotification;
-import javax.management.Description;
-import javax.management.Descriptor;
-import javax.management.ImmutableDescriptor;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBean;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.MXBean;
-import javax.management.Notification;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationInfo;
-import javax.management.NotificationInfos;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.SendNotification;
-
-public class AnnotatedNotificationInfoTest {
-
-    static final Descriptor expectedDescriptor = new ImmutableDescriptor(
-            "foo=bar", "descriptionResourceBundleBaseName=bundle",
-            "descriptionResourceKey=key");
-    static final MBeanNotificationInfo expected = new MBeanNotificationInfo(
-            new String[] {"foo", "bar"},
-            AttributeChangeNotification.class.getName(),
-            "description",
-            expectedDescriptor);
-
-    // Data for the first kind of test.  This tests that MBeanNotificationInfo
-    // is correctly derived from @NotificationInfo.
-    // Every static field called mbean* is expected to be an MBean
-    // with a single MBeanNotificationInfo that has the same value
-    // in each case.
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static interface Intf1MBean {}
-
-    public static class Intf1
-            extends NotificationBroadcasterSupport implements Intf1MBean {}
-
-    private static Object mbeanIntf1 = new Intf1();
-
-    @NotificationInfos(
-        @NotificationInfo(
-                types = {"foo", "bar"},
-                notificationClass = AttributeChangeNotification.class,
-                description = @Description(
-                    value = "description",
-                    bundleBaseName = "bundle",
-                    key = "key"),
-                descriptorFields = {"foo=bar"}))
-    public static interface Intf2MBean {}
-
-    public static class Intf2
-            extends NotificationBroadcasterSupport implements Intf2MBean {}
-
-    private static Object mbeanIntf2 = new Intf2();
-
-    @NotificationInfos({})
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static interface Intf3MBean {}
-
-    public static class Intf3
-            extends NotificationBroadcasterSupport implements Intf3MBean {}
-
-    private static Object mbeanIntf3 = new Intf3();
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static interface ParentIntf {}
-
-    public static interface Intf4MBean extends Serializable, ParentIntf, Cloneable {}
-
-    public static class Intf4
-            extends NotificationBroadcasterSupport implements Intf4MBean {}
-
-    private static Object mbeanIntf4 = new Intf4();
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static interface Intf5MXBean {}
-
-    public static class Intf5Impl
-            extends NotificationBroadcasterSupport implements Intf5MXBean {}
-
-    private static Object mbeanIntf5 = new Intf5Impl();
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static interface Intf6MBean {}
-
-    public static class Intf6 implements Intf6MBean {
-        @Resource
-        private volatile SendNotification send;
-    }
-
-    private static Object mbeanIntf6 = new Intf6();
-
-    public static interface Impl1MBean {}
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static class Impl1
-            extends NotificationBroadcasterSupport implements Impl1MBean {}
-
-    private static Object mbeanImpl1 = new Impl1();
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static class ParentImpl extends NotificationBroadcasterSupport {}
-
-    public static interface Impl2MBean {}
-
-    public static class Impl2 extends ParentImpl implements Impl2MBean {}
-
-    private static Object mbeanImpl2 = new Impl2();
-
-    public static interface Impl3MXBean {}
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static class Impl3
-            extends NotificationBroadcasterSupport implements Impl3MXBean {}
-
-    private static Object mbeanImpl3 = new Impl3();
-
-    public static class Impl4 extends ParentImpl implements Impl3MXBean {}
-
-    private static Object mbeanImpl4 = new Impl4();
-
-    @MBean
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static class MBean1 extends NotificationBroadcasterSupport {}
-
-    private static Object mbeanMBean1 = new MBean1();
-
-    @MBean
-    public static class MBean2 extends ParentImpl {}
-
-    private static Object mbeanMBean2 = new MBean2();
-
-    @MBean
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static class MBean3 {
-        @Resource
-        private volatile SendNotification send;
-    }
-
-    private static Object mbeanMBean3 = new MBean3();
-
-    @MXBean
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static class MXBean1 extends NotificationBroadcasterSupport {}
-
-    private static Object mbeanMXBean1 = new MXBean1();
-
-    @MXBean
-    public static class MXBean2 extends ParentImpl {}
-
-    private static Object mbeanMXBean2 = new MXBean2();
-
-    // Test that @NotificationInfo and @NotificationInfos are ignored if
-    // the MBean returns a non-empty MBeanNotificationInfo[] from its
-    // NotificationBroadcaster.getNotifications() implementation.
-
-    @NotificationInfo(types={"blim", "blam"})
-    public static interface Explicit1MBean {}
-
-    public static class Explicit1
-            extends NotificationBroadcasterSupport implements Explicit1MBean {
-        public Explicit1() {
-            super(expected);
-        }
-    }
-
-    private static Object mbeanExplicit1 = new Explicit1();
-
-    @NotificationInfos(
-        {
-            @NotificationInfo(types="blim"), @NotificationInfo(types="blam")
-        }
-    )
-    public static interface Explicit2MXBean {}
-
-    public static class Explicit2
-            implements NotificationBroadcaster, Explicit2MXBean {
-        public void addNotificationListener(NotificationListener listener,
-                NotificationFilter filter, Object handback) {}
-
-        public void removeNotificationListener(NotificationListener listener)
-                throws ListenerNotFoundException {}
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            return new MBeanNotificationInfo[] {expected};
-        }
-    }
-
-    // Data for the second kind of test.  This tests that @NotificationInfo is
-    // ignored if the MBean is not a notification source.  Every static
-    // field called ignoredMBean* is expected to be an MBean on which
-    // isInstanceOf(NotificationBroadcaster.class.getName() is false,
-    // addNotificationListener produces an exception, and the
-    // MBeanNotificationInfo array is empty.
-    @NotificationInfo(types={"com.example.notifs.create",
-                             "com.example.notifs.destroy"})
-    public static interface CacheMBean {
-        public int getCachedNum();
-    }
-
-    public static class Cache implements CacheMBean {
-        public int getCachedNum() {
-            return 0;
-        }
-    }
-
-    private static Object ignoredMBean1 = new Cache();
-
-    @NotificationInfos(
-        @NotificationInfo(types={"foo", "bar"})
-    )
-    public static interface Cache2MBean {
-        public int getCachedNum();
-    }
-
-    public static class Cache2 implements Cache2MBean {
-        public int getCachedNum() {
-            return 0;
-        }
-    }
-
-    private static Object ignoredMBean2 = new Cache2();
-
-    private static final NotificationListener nullListener =
-            new NotificationListener() {
-                public void handleNotification(
-                        Notification notification, Object handback) {}
-            };
-
-    // Test that inheriting inconsistent @NotificationInfo annotations is
-    // an error, but not if they are overridden by a non-empty getNotifications()
-
-    @NotificationInfo(types={"blim"})
-    public static interface Inconsistent1 {}
-
-    @NotificationInfo(types={"blam"})
-    public static interface Inconsistent2 {}
-
-    public static interface InconsistentMBean extends Inconsistent1, Inconsistent2 {}
-
-    public static class Inconsistent
-            extends NotificationBroadcasterSupport implements InconsistentMBean {}
-
-    public static class Consistent
-            extends Inconsistent implements NotificationBroadcaster {
-        public void addNotificationListener(NotificationListener listener,
-                NotificationFilter filter, Object handback) {}
-
-        public void removeNotificationListener(NotificationListener listener)
-                throws ListenerNotFoundException {}
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            return new MBeanNotificationInfo[] {expected};
-        }
-    }
-
-    private static Object mbeanConsistent = new Consistent();
-
-    @NotificationInfo(
-            types = {"foo", "bar"},
-            notificationClass = AttributeChangeNotification.class,
-            description = @Description(
-                value = "description",
-                bundleBaseName = "bundle",
-                key = "key"),
-            descriptorFields = {"foo=bar"})
-    public static interface Consistent2MBean extends Inconsistent1, Inconsistent2 {}
-
-    public static class Consistent2
-            extends NotificationBroadcasterSupport implements Consistent2MBean {}
-
-    private static Object mbeanConsistent2 = new Consistent2();
-
-    public static void main(String[] args) throws Exception {
-        if (!AnnotatedNotificationInfoTest.class.desiredAssertionStatus())
-            throw new Exception("Test must be run with -ea");
-
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        ObjectName on = new ObjectName("a:b=c");
-
-        System.out.println("Testing MBeans...");
-        for (Field mbeanField :
-                AnnotatedNotificationInfoTest.class.getDeclaredFields()) {
-            boolean notifier;
-            if (mbeanField.getName().startsWith("mbean"))
-                notifier = true;
-            else if (mbeanField.getName().startsWith("ignoredMBean"))
-                notifier = false;
-            else
-                continue;
-            System.out.println("..." + mbeanField.getName());
-            Object mbean = mbeanField.get(null);
-            mbs.registerMBean(mbean, on);
-            MBeanInfo mbi = mbs.getMBeanInfo(on);
-            MBeanNotificationInfo[] mbnis = mbi.getNotifications();
-            if (notifier) {
-                assert mbnis.length == 1 : mbnis.length;
-                assert mbnis[0].equals(expected) : mbnis[0];
-            } else {
-                assert mbnis.length == 0 : mbnis.length;
-                assert !mbs.isInstanceOf(on, NotificationBroadcaster.class.getName());
-                try {
-                    mbs.addNotificationListener(on, nullListener, null, null);
-                    assert false : "addNotificationListener works";
-                } catch (Exception e) {
-                    // OK: addNL correctly refused
-                }
-            }
-            mbs.unregisterMBean(on);
-        }
-
-        // Test that inconsistent @NotificationInfo annotations produce an
-        // error.
-        try {
-            mbs.registerMBean(new Inconsistent(), on);
-            System.out.println(mbs.getMBeanInfo(on));
-            assert false : "Inconsistent @NotificationInfo not detected";
-        } catch (Exception e) {
-            System.out.println(
-                    "Inconsistent @NotificationInfo correctly produced " + e);
-        }
-    }
-}
--- a/test/javax/management/Introspector/AnnotationTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/Introspector/AnnotationTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,15 +32,22 @@
  * @run main AnnotationTest
  */
 
-import java.lang.annotation.*;
-import java.lang.reflect.*;
-import java.util.*;
-import javax.management.*;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import javax.management.Descriptor;
+import javax.management.DescriptorRead;
+import javax.management.DescriptorKey;
+import javax.management.ImmutableDescriptor;
+import javax.management.MBeanAttributeInfo;
+import javax.management.MBeanConstructorInfo;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
 
 /*
   This test checks that annotations produce Descriptor entries as
-  specified in javax.management.DescriptorKey and javax.management.DescriptorField.
-  It does the following:
+  specified in javax.management.DescriptorKey.  It does two things:
 
   - An annotation consisting of an int and a String, each with an
     appropriate @DescriptorKey annotation, is placed on every program
@@ -62,10 +69,6 @@
     The test checks that in each case the corresponding Descriptor
     appears in the appropriate place inside the MBean's MBeanInfo.
 
- - A @DescriptorFields annotation defining two fields is placed in the
-   same places and again the test checks that the two fields appear
-   in the corresponding MBean*Info objects.
-
   - An annotation consisting of enough other types to ensure coverage
     is placed on a getter.  The test checks that the generated
     MBeanAttributeInfo contains the corresponding Descriptor.  The tested
@@ -111,12 +114,11 @@
         boolean[] booleanArrayValue();
     }
 
-    /* We use the annotations @Pair(x = 3, y = "foo")
-       and @DescriptorFields({"foo=bar", "baz="}) everywhere, and this is
-       the Descriptor that they should produce: */
+    /* We use the annotation @Pair(x = 3, y = "foo") everywhere, and this is
+       the Descriptor that it should produce: */
     private static Descriptor expectedDescriptor =
-        new ImmutableDescriptor(new String[] {"x", "y", "foo", "baz"},
-                                new Object[] {3, "foo", "bar", ""});
+        new ImmutableDescriptor(new String[] {"x", "y"},
+                                new Object[] {3, "foo"});
 
     private static Descriptor expectedFullDescriptor =
         new ImmutableDescriptor(new String[] {
@@ -136,10 +138,8 @@
                                 });
 
     @Pair(x = 3, y = "foo")
-    @DescriptorFields({"foo=bar", "baz="})
     public static interface ThingMBean {
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         @Full(classValue=Full.class,
               enumValue=RetentionPolicy.RUNTIME,
               booleanValue=false,
@@ -151,47 +151,32 @@
         int getReadOnly();
 
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         void setWriteOnly(int x);
 
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         int getReadWrite1();
         void setReadWrite1(int x);
 
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         int getReadWrite2();
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         void setReadWrite2(int x);
 
         int getReadWrite3();
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         void setReadWrite3(int x);
 
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
-        int operation(@Pair(x = 3, y = "foo")
-                      @DescriptorFields({"foo=bar", "baz="})
-                      int p1,
-                      @Pair(x = 3, y = "foo")
-                      @DescriptorFields({"foo=bar", "baz="})
-                      int p2);
+        int operation(@Pair(x = 3, y = "foo") int p1,
+                      @Pair(x = 3, y = "foo") int p2);
     }
 
     public static class Thing implements ThingMBean {
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         public Thing() {}
 
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
-        public Thing(
-                @Pair(x = 3, y = "foo")
-                @DescriptorFields({"foo=bar", "baz="})
-                int p1) {}
+        public Thing(@Pair(x = 3, y = "foo") int p1) {}
 
         public int getReadOnly() {return 0;}
 
@@ -210,20 +195,14 @@
     }
 
     @Pair(x = 3, y = "foo")
-    @DescriptorFields({"foo=bar", "baz="})
     public static interface ThingMXBean extends ThingMBean {}
 
     public static class ThingImpl implements ThingMXBean {
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
         public ThingImpl() {}
 
         @Pair(x = 3, y = "foo")
-        @DescriptorFields({"foo=bar", "baz="})
-        public ThingImpl(
-                @Pair(x = 3, y = "foo")
-                @DescriptorFields({"foo=bar", "baz="})
-                int p1) {}
+        public ThingImpl(@Pair(x = 3, y = "foo") int p1) {}
 
         public int getReadOnly() {return 0;}
 
@@ -241,79 +220,6 @@
         public int operation(int p1, int p2) {return 0;}
     }
 
-    @Retention(RetentionPolicy.RUNTIME)
-    public static @interface DefaultTest {
-        @DescriptorKey(value = "string1", omitIfDefault = true)
-        String string1() default "";
-        @DescriptorKey(value = "string2", omitIfDefault = true)
-        String string2() default "tiddly pom";
-        @DescriptorKey(value = "int", omitIfDefault = true)
-        int intx() default 23;
-        @DescriptorKey(value = "intarray1", omitIfDefault = true)
-        int[] intArray1() default {};
-        @DescriptorKey(value = "intarray2", omitIfDefault = true)
-        int[] intArray2() default {1, 2};
-        @DescriptorKey(value = "stringarray1", omitIfDefault = true)
-        String[] stringArray1() default {};
-        @DescriptorKey(value = "stringarray2", omitIfDefault = true)
-        String[] stringArray2() default {"foo", "bar"};
-    }
-
-    @Retention(RetentionPolicy.RUNTIME)
-    public static @interface Expect {
-        String[] value() default {};
-    }
-
-    public static interface DefaultMBean {
-        @DefaultTest
-        @Expect()
-        public void a();
-
-        @DefaultTest(string1="")
-        @Expect()
-        public void b();
-
-        @DefaultTest(string1="nondefault")
-        @Expect("string1=nondefault")
-        public void c();
-
-        @DefaultTest(string2="tiddly pom")
-        @Expect()
-        public void d();
-
-        @DefaultTest(intx=23)
-        @Expect()
-        public void e();
-
-        @DefaultTest(intx=34)
-        @Expect("int=34")
-        public void f();
-
-        @DefaultTest(intArray1={})
-        @Expect()
-        public void g();
-
-        @DefaultTest(intArray1={2,3})
-        @Expect("intarray1=[2, 3]")
-        public void h();
-
-        @DefaultTest(intArray2={})
-        @Expect("intarray2=[]")
-        public void i();
-
-        @DefaultTest(stringArray1={})
-        @Expect()
-        public void j();
-
-        @DefaultTest(stringArray1={"foo"})
-        @Expect("stringarray1=[foo]")
-        public void k();
-
-        @DefaultTest(stringArray2={})
-        @Expect("stringarray2=[]")
-        public void l();
-    }
-
     public static void main(String[] args) throws Exception {
         System.out.println("Testing that annotations are correctly " +
                            "reflected in Descriptor entries");
@@ -336,43 +242,6 @@
         }
         check(mbs, on);
 
-        System.out.println();
-        System.out.println("Testing that omitIfDefault works");
-        DefaultMBean defaultImpl = (DefaultMBean) Proxy.newProxyInstance(
-                DefaultMBean.class.getClassLoader(),
-                new Class<?>[] {DefaultMBean.class},
-                new InvocationHandler(){
-                    public Object invoke(Object proxy, Method method, Object[] args) {
-                        return null;
-                    }
-                });
-        DynamicMBean mbean = new StandardMBean(defaultImpl, DefaultMBean.class);
-        MBeanOperationInfo[] ops = mbean.getMBeanInfo().getOperations();
-        for (MBeanOperationInfo op : ops) {
-            String name = op.getName();
-            Expect expect =
-                    DefaultMBean.class.getMethod(name).getAnnotation(Expect.class);
-            Descriptor opd = op.getDescriptor();
-            List<String> fields = new ArrayList<String>();
-            for (String fieldName : opd.getFieldNames()) {
-                Object value = opd.getFieldValue(fieldName);
-                String s = Arrays.deepToString(new Object[] {value});
-                s = s.substring(1, s.length() - 1);
-                fields.add(fieldName + "=" + s);
-            }
-            Descriptor opds = new ImmutableDescriptor(fields.toArray(new String[0]));
-            Descriptor expd = new ImmutableDescriptor(expect.value());
-            if (opds.equals(expd))
-                System.out.println("OK: op " + name + ": " + opds);
-            else {
-                String failure = "Bad descriptor for op " + name + ": " +
-                        "expected " + expd + ", got " + opds;
-                System.out.println("NOT OK: " + failure);
-                failed = failure;
-            }
-        }
-        System.out.println();
-
         if (failed == null)
             System.out.println("Test passed");
         else
--- a/test/javax/management/Introspector/ExceptionsDescriptorTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,245 +0,0 @@
-/*
- * 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 %M% %I%
- * @bug 6250014
- * @summary Test that Exceptions are added to the MbeanInfo
- * @author Jean-Francois Denise
- * @run main/othervm ExceptionsDescriptorTest
- */
-import java.lang.management.ManagementFactory;
-import java.util.HashSet;
-import java.util.Set;
-import javax.management.Descriptor;
-import javax.management.JMX;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.ObjectName;
-
-public class ExceptionsDescriptorTest {
-
-    private static final ObjectName OBJECT_NAME = ObjectName.valueOf(":type=Foo");
-    final static String EXCEPTION_NAME = Exception.class.getName();
-    final static String ILLEGAL_ARGUMENT_EXCEPTION_NAME =
-            IllegalArgumentException.class.getName();
-    final static Set<String> ONE_EXCEPTION = new HashSet<String>();
-    final static Set<String> TWO_EXCEPTION = new HashSet<String>();
-    static {
-        ONE_EXCEPTION.add(EXCEPTION_NAME);
-        TWO_EXCEPTION.add(EXCEPTION_NAME);
-        TWO_EXCEPTION.add(ILLEGAL_ARGUMENT_EXCEPTION_NAME);
-    }
-    public interface TestMBean {
-
-        public void doIt();
-
-        public void doIt(String str) throws Exception;
-
-        public void doIt(String str, boolean b) throws Exception,
-                IllegalArgumentException;
-
-        public String getThat();
-
-        public void setThat(String that);
-
-        public String getThe() throws Exception;
-
-        public void setThe(String the);
-
-        public String getThese();
-
-        public void setThese(String the) throws Exception;
-
-        public String getIt() throws Exception;
-
-        public void setIt(String str) throws Exception;
-
-        public String getThis() throws Exception, IllegalArgumentException;
-
-        public void setThose(String str) throws Exception,
-                IllegalArgumentException;
-    }
-
-    public static class Test implements TestMBean {
-
-        public Test() {
-        }
-
-        public Test(int i) throws Exception {
-        }
-
-        public Test(int i, int j) throws Exception, IllegalArgumentException {
-        }
-
-        public void doIt() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void doIt(String str) throws Exception {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void doIt(String str, boolean b) throws Exception, IllegalArgumentException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public String getThat() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setThat(String that) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public String getThe() throws Exception {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setThe(String the) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public String getThese() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setThese(String the) throws Exception {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public String getIt() throws Exception {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setIt(String str) throws Exception {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public String getThis() throws Exception, IllegalArgumentException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setThose(String str) throws Exception, IllegalArgumentException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-    }
-
-    private static void check(Descriptor d,
-            Set<String> exceptionsExpectedValue,
-            boolean exceptionsExpected,
-            Set<String> setExceptionsExpectedValue,
-            boolean setExceptionsExpected) throws Exception {
-        String[] exceptionsValues = (String[]) d.getFieldValue(JMX.EXCEPTIONS_FIELD);
-        String[] setExceptionsValues = (String[]) d.getFieldValue(JMX.SET_EXCEPTIONS_FIELD);
-
-        if (exceptionsExpected && exceptionsValues == null) {
-            throw new Exception("exceptions is expected but null value");
-        }
-        if (!exceptionsExpected && exceptionsValues != null) {
-            throw new Exception("exceptions is not expected but non null value");
-        }
-        if (setExceptionsExpected && setExceptionsValues == null) {
-            throw new Exception("setExceptions is expected but null value");
-        }
-        if (!setExceptionsExpected && setExceptionsValues != null) {
-            throw new Exception("setExceptions is not expected but non null value");
-        }
-
-        if (exceptionsExpected) {
-            checkValues(exceptionsExpectedValue, exceptionsValues);
-        }
-        if (setExceptionsExpected) {
-            checkValues(setExceptionsExpectedValue, setExceptionsValues);
-        }
-    }
-
-    private static void checkValues(Set<String> expectedValuesSet,
-            String[] realValues) throws Exception {
-
-        Set<String> realValuesSet = new HashSet<String>();
-        for (String ex : realValues) {
-            realValuesSet.add(ex);
-        }
-        if (!realValuesSet.equals(expectedValuesSet)) {
-            throw new Exception("Invalid content for exceptions. Was expecting " +
-                    expectedValuesSet + ". Found " + realValuesSet);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        Test t = new Test();
-        ManagementFactory.getPlatformMBeanServer().registerMBean(t, OBJECT_NAME);
-        MBeanInfo info = ManagementFactory.getPlatformMBeanServer().
-                getMBeanInfo(OBJECT_NAME);
-        //Constructors
-        for (MBeanConstructorInfo ctr : info.getConstructors()) {
-            if (ctr.getSignature().length == 0) {
-                check(ctr.getDescriptor(), null, false, null, false);
-            }
-            if (ctr.getSignature().length == 1) {
-                check(ctr.getDescriptor(), ONE_EXCEPTION, true, null, false);
-            }
-            if (ctr.getSignature().length == 2) {
-                check(ctr.getDescriptor(),TWO_EXCEPTION,true, null, false);
-            }
-        }
-        //Attributes
-        for (MBeanAttributeInfo attr : info.getAttributes()) {
-            if (attr.getName().equals("That")) {
-                check(attr.getDescriptor(), null, false, null, false);
-            }
-            if (attr.getName().equals("The")) {
-                check(attr.getDescriptor(), ONE_EXCEPTION,true,null, false);
-            }
-            if (attr.getName().equals("These")) {
-                check(attr.getDescriptor(), null, false, ONE_EXCEPTION,true);
-            }
-            if (attr.getName().equals("It")) {
-                check(attr.getDescriptor(), ONE_EXCEPTION,true,ONE_EXCEPTION,
-                        true);
-            }
-            if (attr.getName().equals("This")) {
-                check(attr.getDescriptor(), TWO_EXCEPTION,true,null,false);
-            }
-            if (attr.getName().equals("Those")) {
-                check(attr.getDescriptor(), null,false,TWO_EXCEPTION,true);
-            }
-        }
-        //Operations
-        for (MBeanOperationInfo oper : info.getOperations()) {
-            if (oper.getSignature().length == 0) {
-                check(oper.getDescriptor(), null, false, null, false);
-            }
-            if (oper.getSignature().length == 1) {
-                check(oper.getDescriptor(), ONE_EXCEPTION, true, null, false);
-            }
-            if (oper.getSignature().length == 2) {
-                check(oper.getDescriptor(), TWO_EXCEPTION,true, null, false);
-            }
-        }
-        System.out.println("Test passed");
-    }
-}
--- a/test/javax/management/Introspector/MBeanDescriptionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,830 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 %M% %I%
- * @bug 6323980
- * @summary Test &#64;Description
- * @author Eamonn McManus
- */
-
-import java.lang.management.ManagementFactory;
-import javax.management.Description;
-import javax.management.IntrospectionException;
-import javax.management.MBean;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanFeatureInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServer;
-import javax.management.MXBean;
-import javax.management.ManagedAttribute;
-import javax.management.ManagedOperation;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-public class MBeanDescriptionTest {
-    private static String failure;
-    private static final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    private static final ObjectName name;
-    static {
-        try {
-            name = new ObjectName("a:b=c");
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public static interface Interface {
-        @Description("A description")
-        public String getA();
-
-        @Description("B description")
-        public int getB();
-        public void setB(int x);
-
-        public boolean isC();
-        @Description("C description")
-        public void setC(boolean x);
-
-        @Description("D description")
-        public void setD(float x);
-
-        @Description("H description")
-        public int getH();
-        @Description("H description")
-        public void setH(int x);
-
-        public String getE();
-
-        public int getF();
-        public void setF(int x);
-
-        public void setG(boolean x);
-
-        @Description("opA description")
-        public int opA(
-                @Description("p1 description")
-                int p1,
-                @Description("p2 description")
-                int p2);
-
-        public void opB(float x);
-    }
-
-    @Description("MBean description")
-    public static interface TestMBean extends Interface {}
-
-    public static class Test implements TestMBean {
-        @Description("0-arg constructor description")
-        public Test() {}
-
-        public Test(String why) {}
-
-        @Description("2-arg constructor description")
-        public Test(
-                @Description("p1 description")
-                int x,
-                @Description("p2 description")
-                String y) {
-        }
-
-        public String getA() {
-            return null;
-        }
-
-        public int getB() {
-            return 0;
-        }
-
-        public void setB(int x) {
-        }
-
-        public boolean isC() {
-            return false;
-        }
-
-        public void setC(boolean x) {
-        }
-
-        public void setD(float x) {
-        }
-
-        public String getE() {
-            return null;
-        }
-
-        public int getF() {
-            return 0;
-        }
-
-        public void setF(int x) {
-        }
-
-        public void setG(boolean x) {
-        }
-
-        public int getH() {
-            return 0;
-        }
-
-        public void setH(int x) {
-        }
-
-        public int opA(int p1, int p2) {
-            return 0;
-        }
-
-        public void opB(float x) {
-        }
-    }
-
-    public static class TestSub extends Test {
-        @Description("0-arg constructor description")
-        public TestSub() {}
-
-        public TestSub(String why) {}
-
-        @Description("2-arg constructor description")
-        public TestSub(
-                @Description("p1 description")
-                int x,
-                @Description("p2 description")
-                String y) {
-        }
-    }
-
-    public static class StandardSub extends StandardMBean implements TestMBean {
-        @Description("0-arg constructor description")
-        public StandardSub() {
-            super(TestMBean.class, false);
-        }
-
-        public StandardSub(String why) {
-            super(TestMBean.class, false);
-        }
-
-        @Description("2-arg constructor description")
-        public StandardSub(
-                @Description("p1 description")
-                int x,
-                @Description("p2 description")
-                String y) {
-            super(TestMBean.class, false);
-        }
-
-        public String getA() {
-            return null;
-        }
-
-        public int getB() {
-            return 0;
-        }
-
-        public void setB(int x) {
-        }
-
-        public boolean isC() {
-            return false;
-        }
-
-        public void setC(boolean x) {
-        }
-
-        public void setD(float x) {
-        }
-
-        public String getE() {
-            return null;
-        }
-
-        public int getF() {
-            return 0;
-        }
-
-        public void setF(int x) {
-        }
-
-        public void setG(boolean x) {
-        }
-
-        public int opA(int p1, int p2) {
-            return 0;
-        }
-
-        public void opB(float x) {
-        }
-
-        public int getH() {
-            return 0;
-        }
-
-        public void setH(int x) {
-        }
-    }
-
-    @Description("MBean description")
-    public static interface TestMXBean extends Interface {}
-
-    public static class TestMXBeanImpl implements TestMXBean {
-        @Description("0-arg constructor description")
-        public TestMXBeanImpl() {}
-
-        public TestMXBeanImpl(String why) {}
-
-        @Description("2-arg constructor description")
-        public TestMXBeanImpl(
-                @Description("p1 description")
-                int x,
-                @Description("p2 description")
-                String y) {
-        }
-
-        public String getA() {
-            return null;
-        }
-
-        public int getB() {
-            return 0;
-        }
-
-        public void setB(int x) {
-        }
-
-        public boolean isC() {
-            return false;
-        }
-
-        public void setC(boolean x) {
-        }
-
-        public void setD(float x) {
-        }
-
-        public String getE() {
-            return null;
-        }
-
-        public int getF() {
-            return 0;
-        }
-
-        public void setF(int x) {
-        }
-
-        public void setG(boolean x) {
-        }
-
-        public int opA(int p1, int p2) {
-            return 0;
-        }
-
-        public void opB(float x) {
-        }
-
-        public int getH() {
-            return 0;
-        }
-
-        public void setH(int x) {
-        }
-    }
-
-    public static class StandardMXSub extends StandardMBean implements TestMXBean {
-        @Description("0-arg constructor description")
-        public StandardMXSub() {
-            super(TestMXBean.class, true);
-        }
-
-        public StandardMXSub(String why) {
-            super(TestMXBean.class, true);
-        }
-
-        @Description("2-arg constructor description")
-        public StandardMXSub(
-                @Description("p1 description")
-                int x,
-                @Description("p2 description")
-                String y) {
-            super(TestMXBean.class, true);
-        }
-
-        public String getA() {
-            return null;
-        }
-
-        public int getB() {
-            return 0;
-        }
-
-        public void setB(int x) {
-        }
-
-        public boolean isC() {
-            return false;
-        }
-
-        public void setC(boolean x) {
-        }
-
-        public void setD(float x) {
-        }
-
-        public String getE() {
-            return null;
-        }
-
-        public int getF() {
-            return 0;
-        }
-
-        public void setF(int x) {
-        }
-
-        public void setG(boolean x) {
-        }
-
-        public int opA(int p1, int p2) {
-            return 0;
-        }
-
-        public void opB(float x) {
-        }
-
-        public int getH() {
-            return 0;
-        }
-
-        public void setH(int x) {
-        }
-    }
-
-    @MBean
-    @Description("MBean description")
-    public static class AnnotatedMBean {
-        @Description("0-arg constructor description")
-        public AnnotatedMBean() {}
-
-        public AnnotatedMBean(String why) {}
-
-        @Description("2-arg constructor description")
-        public AnnotatedMBean(
-                @Description("p1 description")
-                int x,
-                @Description("p2 description")
-                String y) {}
-
-        @ManagedAttribute
-        @Description("A description")
-        public String getA() {
-            return null;
-        }
-
-        @ManagedAttribute
-        @Description("B description")
-        public int getB() {
-            return 0;
-        }
-
-        @ManagedAttribute
-        public void setB(int x) {
-        }
-
-        @ManagedAttribute
-        public boolean isC() {
-            return false;
-        }
-
-        @ManagedAttribute
-        @Description("C description")
-        public void setC(boolean x) {
-        }
-
-        @ManagedAttribute
-        @Description("D description")
-        public void setD(float x) {
-        }
-
-        @ManagedAttribute
-        public String getE() {
-            return null;
-        }
-
-        @ManagedAttribute
-        public int getF() {
-            return 0;
-        }
-
-        @ManagedAttribute
-        public void setF(int x) {
-        }
-
-        @ManagedAttribute
-        public void setG(boolean x) {
-        }
-
-        @ManagedAttribute
-        @Description("H description")
-        public int getH() {
-            return 0;
-        }
-
-        @ManagedAttribute
-        @Description("H description")
-        public void setH(int x) {
-        }
-
-        @ManagedOperation
-        @Description("opA description")
-        public int opA(
-                @Description("p1 description") int p1,
-                @Description("p2 description") int p2) {
-            return 0;
-        }
-
-        @ManagedOperation
-        public void opB(float x) {
-        }
-    }
-
-    @MXBean
-    @Description("MBean description")
-    public static class AnnotatedMXBean {
-        @Description("0-arg constructor description")
-        public AnnotatedMXBean() {}
-
-        public AnnotatedMXBean(String why) {}
-
-        @Description("2-arg constructor description")
-        public AnnotatedMXBean(
-                @Description("p1 description")
-                int x,
-                @Description("p2 description")
-                String y) {}
-
-        @ManagedAttribute
-        @Description("A description")
-        public String getA() {
-            return null;
-        }
-
-        @ManagedAttribute
-        @Description("B description")
-        public int getB() {
-            return 0;
-        }
-
-        @ManagedAttribute
-        public void setB(int x) {
-        }
-
-        @ManagedAttribute
-        public boolean isC() {
-            return false;
-        }
-
-        @ManagedAttribute
-        @Description("C description")
-        public void setC(boolean x) {
-        }
-
-        @ManagedAttribute
-        @Description("D description")
-        public void setD(float x) {
-        }
-
-        @ManagedAttribute
-        public String getE() {
-            return null;
-        }
-
-        @ManagedAttribute
-        public int getF() {
-            return 0;
-        }
-
-        @ManagedAttribute
-        public void setF(int x) {
-        }
-
-        @ManagedAttribute
-        public void setG(boolean x) {
-        }
-
-        @ManagedAttribute
-        @Description("H description")
-        public int getH() {
-            return 0;
-        }
-
-        @ManagedAttribute
-        @Description("H description")
-        public void setH(int x) {
-        }
-
-        @ManagedOperation
-        @Description("opA description")
-        public int opA(
-                @Description("p1 description") int p1,
-                @Description("p2 description") int p2) {
-            return 0;
-        }
-
-        @ManagedOperation
-        public void opB(float x) {
-        }
-    }
-
-    // Negative tests follow.
-
-    // Inconsistent descriptions
-    public static interface BadInterface {
-        @Description("foo")
-        public String getFoo();
-        @Description("bar")
-        public void setFoo(String x);
-    }
-
-    public static interface BadMBean extends BadInterface {}
-
-    public static class Bad implements BadMBean {
-        public String getFoo() {
-            return null;
-        }
-
-        public void setFoo(String x) {
-        }
-    }
-
-    public static interface BadMXBean extends BadInterface {}
-
-    public static class BadMXBeanImpl implements BadMXBean {
-        public String getFoo() {
-            return null;
-        }
-
-        public void setFoo(String x) {
-        }
-    }
-
-    private static interface Defaults {
-        public String defaultAttributeDescription(String name);
-        public String defaultOperationDescription(String name);
-        public String defaultParameterDescription(int index);
-    }
-
-    private static class StandardDefaults implements Defaults {
-        public String defaultAttributeDescription(String name) {
-            return "Attribute exposed for management";
-        }
-
-        public String defaultOperationDescription(String name) {
-            return "Operation exposed for management";
-        }
-
-        public String defaultParameterDescription(int index) {
-            return "";
-        }
-    }
-    private static final Defaults standardDefaults = new StandardDefaults();
-
-    private static class MXBeanDefaults implements Defaults {
-        public String defaultAttributeDescription(String name) {
-            return name;
-        }
-
-        public String defaultOperationDescription(String name) {
-            return name;
-        }
-
-        public String defaultParameterDescription(int index) {
-            return "p" + index;
-        }
-    }
-    private static final Defaults mxbeanDefaults = new MXBeanDefaults();
-
-    private static class TestCase {
-        final String name;
-        final Object mbean;
-        final Defaults defaults;
-        TestCase(String name, Object mbean, Defaults defaults) {
-            this.name = name;
-            this.mbean = mbean;
-            this.defaults = defaults;
-        }
-    }
-
-    private static class ExceptionTest {
-        final String name;
-        final Object mbean;
-        ExceptionTest(String name, Object mbean) {
-            this.name = name;
-            this.mbean = mbean;
-        }
-    }
-
-    private static final TestCase[] tests = {
-        new TestCase("Standard MBean", new Test(), standardDefaults),
-        new TestCase("Standard MBean subclass", new TestSub(), standardDefaults),
-        new TestCase("StandardMBean delegating",
-                new StandardMBean(new Test(), TestMBean.class, false),
-                standardDefaults),
-        new TestCase("StandardMBean delegating to subclass",
-                new StandardMBean(new TestSub(), TestMBean.class, false),
-                standardDefaults),
-        new TestCase("StandardMBean subclass", new StandardSub(), standardDefaults),
-
-        new TestCase("MXBean", new TestMXBeanImpl(), mxbeanDefaults),
-        new TestCase("StandardMBean MXBean delegating",
-                new StandardMBean(new TestMXBeanImpl(), TestMXBean.class, true),
-                mxbeanDefaults),
-        new TestCase("StandardMBean MXBean subclass",
-                new StandardMXSub(), mxbeanDefaults),
-
-        new TestCase("@MBean", new AnnotatedMBean(), standardDefaults),
-        new TestCase("@MXBean", new AnnotatedMXBean(), mxbeanDefaults),
-        new TestCase("StandardMBean @MBean delegating",
-                new StandardMBean(new AnnotatedMBean(), null, false),
-                standardDefaults),
-        new TestCase("StandardMBean @MXBean delegating",
-                new StandardMBean(new AnnotatedMXBean(), null, true),
-                mxbeanDefaults),
-    };
-
-    private static final ExceptionTest[] exceptionTests = {
-        new ExceptionTest("Standard MBean with inconsistent get/set", new Bad()),
-        new ExceptionTest("MXBean with inconsistent get/set", new BadMXBeanImpl()),
-    };
-
-    public static void main(String[] args) throws Exception {
-        System.out.println("=== Testing correct MBeans ===");
-        for (TestCase test : tests) {
-            System.out.println("Testing " + test.name + "...");
-            mbs.registerMBean(test.mbean, name);
-            boolean expectConstructors =
-                    (test.mbean.getClass() != StandardMBean.class);
-            check(mbs.getMBeanInfo(name), test.defaults, expectConstructors);
-            mbs.unregisterMBean(name);
-        }
-        System.out.println();
-
-        System.out.println("=== Testing incorrect MBeans ===");
-        for (ExceptionTest test : exceptionTests) {
-            System.out.println("Testing " + test.name);
-            try {
-                mbs.registerMBean(test.mbean, name);
-                fail("Registration succeeded but should not have");
-                mbs.unregisterMBean(name);
-            } catch (NotCompliantMBeanException e) {
-                // OK
-            } catch (Exception e) {
-                fail("Registration failed with wrong exception: " +
-                        "expected NotCompliantMBeanException, got " +
-                        e.getClass().getName());
-            }
-        }
-        System.out.println();
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static void check(
-            MBeanInfo mbi, Defaults defaults, boolean expectConstructors)
-            throws Exception {
-        assertEquals("MBean description", mbi.getDescription());
-
-        // These attributes have descriptions
-        for (String attr : new String[] {"A", "B", "C", "D", "H"}) {
-            MBeanAttributeInfo mbai = getAttributeInfo(mbi, attr);
-            assertEquals(attr + " description", mbai.getDescription());
-        }
-
-        // These attributes don't have descriptions
-        for (String attr : new String[] {"E", "F", "G"}) {
-            // If we ever change the default description, we'll need to change
-            // this test accordingly.
-            MBeanAttributeInfo mbai = getAttributeInfo(mbi, attr);
-            assertEquals(
-                    defaults.defaultAttributeDescription(attr), mbai.getDescription());
-        }
-
-        // This operation has a description, as do its parameters
-        MBeanOperationInfo opA = getOperationInfo(mbi, "opA");
-        assertEquals("opA description", opA.getDescription());
-        checkSignature(opA.getSignature());
-
-        // This operation has the default description, as does its parameter
-        MBeanOperationInfo opB = getOperationInfo(mbi, "opB");
-        assertEquals(defaults.defaultOperationDescription("opB"), opB.getDescription());
-        MBeanParameterInfo opB0 = opB.getSignature()[0];
-        assertEquals(defaults.defaultParameterDescription(0), opB0.getDescription());
-
-        if (expectConstructors) {
-            // The 0-arg and 2-arg constructors have descriptions
-            MBeanConstructorInfo con0 = getConstructorInfo(mbi, 0);
-            assertEquals("0-arg constructor description", con0.getDescription());
-            MBeanConstructorInfo con2 = getConstructorInfo(mbi, 2);
-            assertEquals("2-arg constructor description", con2.getDescription());
-            checkSignature(con2.getSignature());
-
-            // The 1-arg constructor does not have a description.
-            // The default description for constructors and their
-            // parameters is the same for all types of MBean.
-            MBeanConstructorInfo con1 = getConstructorInfo(mbi, 1);
-            assertEquals("Public constructor of the MBean", con1.getDescription());
-            assertEquals("", con1.getSignature()[0].getDescription());
-        }
-    }
-
-    private static void checkSignature(MBeanParameterInfo[] params) {
-        for (int i = 0; i < params.length; i++) {
-            MBeanParameterInfo mbpi = params[i];
-            assertEquals("p" + (i+1) + " description", mbpi.getDescription());
-        }
-    }
-
-    private static MBeanAttributeInfo getAttributeInfo(MBeanInfo mbi, String attr)
-    throws Exception {
-        return getFeatureInfo(mbi.getAttributes(), attr);
-    }
-
-    private static MBeanOperationInfo getOperationInfo(MBeanInfo mbi, String op)
-    throws Exception {
-        return getFeatureInfo(mbi.getOperations(), op);
-    }
-
-    private static MBeanConstructorInfo getConstructorInfo(MBeanInfo mbi, int nparams)
-    throws Exception {
-        for (MBeanConstructorInfo mbci : mbi.getConstructors()) {
-            if (mbci.getSignature().length == nparams)
-                return mbci;
-        }
-        throw new Exception("Constructor not found: " + nparams);
-    }
-
-    private static <T extends MBeanFeatureInfo> T getFeatureInfo(
-            T[] features, String name) throws Exception {
-        for (T feature : features) {
-            if (feature.getName().equals(name))
-                return feature;
-        }
-        throw new Exception("Feature not found: " + name);
-    }
-
-    private static void assertEquals(Object expected, Object actual) {
-        if (!expected.equals(actual))
-            fail("Expected " + string(expected) + ", got " + string(actual));
-    }
-
-    private static String string(Object x) {
-        if (x instanceof String)
-            return quote((String) x);
-        else
-            return String.valueOf(x);
-    }
-
-    private static String quote(String s) {
-        return '"' + s.replace("\\", "\\\\").replace("\"", "\\\"") + '"';
-    }
-
-    private static void fail(String why) {
-        StackTraceElement[] stack = new Throwable().getStackTrace();
-        int n = 0;
-        for (StackTraceElement elmt : stack) {
-            String method = elmt.getMethodName();
-            if (method.equals("fail") || method.equals("assertEquals") ||
-                    method.equals("checkSignature"))
-                continue;
-            n = elmt.getLineNumber();
-            break;
-        }
-        System.out.println("FAILED: " + why + " (line " + n + ")");
-        failure = why;
-    }
-}
--- a/test/javax/management/Introspector/ObjectNameTemplateTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,343 +0,0 @@
-/*
- * 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 %M% %I%
- * @bug 6675526
- * @summary Test MBeans named with &#64;ObjectNameTemplate
- * @author Jean-Francois Denise
- * @run main/othervm ObjectNameTemplateTest
- */
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Constructor;
-import java.util.ArrayList;
-import java.util.List;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.ImmutableDescriptor;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMX;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.MXBean;
-import javax.management.MBean;
-import javax.management.ManagedAttribute;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.ObjectNameTemplate;
-import javax.management.ReflectionException;
-import javax.management.StandardMBean;
-
-public class ObjectNameTemplateTest {
-
-    private static MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    private static final String NAME_TEMPLATE_MULTI =
-            "com.example:type=MultiStdCache,name={Name}";
-    private static final String NAME_TEMPLATE_MONO =
-            "com.example:{Type}={TypeValue}";
-    private static final String NAME_TEMPLATE_QUOTED =
-            "com.example:type=Quotted,name=\"{Name}\"";
-    private static final String NAME_TEMPLATE_WRAPPED =
-            "com.example:type=MgtInterface,id={Id}";
-    private static final String NAME_TEMPLATE_FULL =
-            "{Naming}";
-    private static final String FULL_NAME = "com.example:type=NotAdvised";
-    private static final String NAME1 = "toto1";
-    private static final String NAME2 = "toto2";
-    private static final String TYPE_KEY = "thisIsTheType";
-    private static final String TYPE_VALUE = "aTypeValue";
-    private static final String INVALID_NAME = "?,=*,\n, ";
-    private static final int ID = 999;
-    private static Object[] EMPTY_PARAMS = {};
-    private static String[] EMPTY_SIGNATURE = {};
-    private static final ObjectName OBJECTNAME_CACHE =
-            ObjectName.valueOf("com.example:type=Cache");
-    private static final ObjectName OBJECTNAME_SUBCACHE =
-            ObjectName.valueOf("com.example:type=SubCache");
-    private static final ObjectName OBJECTNAME_CACHEMX =
-            ObjectName.valueOf("com.example:type=CacheMX");
-    private static final ObjectName OBJECTNAME_SUBCACHEMX =
-            ObjectName.valueOf("com.example:type=SubCacheMX");
-    private static final ObjectName OBJECTNAME_DYNACACHE =
-            ObjectName.valueOf("com.example:type=DynaCache");
-    private static final ObjectName OBJECTNAME_STDCACHE =
-            ObjectName.valueOf("com.example:type=StdCache");
-    private static final ObjectName OBJECTNAME_STDCACHEMX =
-            ObjectName.valueOf("com.example:type=StdCacheMX");
-    private static final ObjectName OBJECTNAME_MULTI_1 =
-            ObjectName.valueOf("com.example:" +
-            "type=MultiStdCache,name=" + NAME1);
-    private static final ObjectName OBJECTNAME_MULTI_2 =
-            ObjectName.valueOf("com.example:" +
-            "type=MultiStdCache,name=" + NAME2);
-    private static final ObjectName OBJECTNAME_MONO =
-            ObjectName.valueOf("com.example:" + TYPE_KEY + "=" +
-            TYPE_VALUE);
-    private static final ObjectName OBJECTNAME_QUOTED =
-            ObjectName.valueOf("com.example:type=Quotted," +
-            "name="+ObjectName.quote(INVALID_NAME));
-    private static final ObjectName OBJECTNAME_WRAPPED_RESOURCE =
-            ObjectName.valueOf("com.example:type=MgtInterface,id=" + ID);
-    private static final ObjectName OBJECTNAME_FULL =
-            ObjectName.valueOf(FULL_NAME);
-
-    private static void test(Class<?> mbean, Object[] params,
-            String[] signature, ObjectName name, String template)
-            throws Exception {
-        mbs.createMBean(mbean.getName(), null, params, signature);
-        test(name, template);
-        List<Class<?>> parameters = new ArrayList<Class<?>>();
-        for (String sig : signature) {
-            parameters.add(Class.forName(sig));
-        }
-        Class<?> classes[] = new Class<?>[parameters.size()];
-        Constructor ctr = mbean.getConstructor(parameters.toArray(classes));
-        Object inst = ctr.newInstance(params);
-        test(inst, name, template);
-    }
-
-    private static void test(Object obj, ObjectName name, String template)
-            throws Exception {
-        mbs.registerMBean(obj, null);
-        test(name, template);
-    }
-
-    private static void test(ObjectName name, String template)
-            throws Exception {
-        if (!mbs.isRegistered(name)) {
-            throw new Exception("Wrong " + name + " name");
-        }
-        if (template != null && !mbs.getMBeanInfo(name).getDescriptor().
-                getFieldValue("objectNameTemplate").equals(template)) {
-            throw new Exception("Invalid Derscriptor");
-        }
-        mbs.unregisterMBean(name);
-    }
-
-    public static void main(String[] args) throws Exception {
-        test(Cache.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_CACHE,
-                OBJECTNAME_CACHE.toString());
-
-        test(CacheMX.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_CACHEMX,
-                OBJECTNAME_CACHEMX.toString());
-
-        test(SubCache.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_SUBCACHE,
-                OBJECTNAME_SUBCACHE.toString());
-
-        test(SubCacheMX.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_SUBCACHEMX,
-                OBJECTNAME_SUBCACHEMX.toString());
-
-        test(DynaCache.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_DYNACACHE,
-                null);
-
-        test(StdCacheMX.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_STDCACHEMX,
-                OBJECTNAME_STDCACHEMX.toString());
-
-        test(StdCache.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_STDCACHE,
-                OBJECTNAME_STDCACHE.toString());
-        String[] sig = {String.class.getName()};
-        Object[] params = {NAME1};
-        test(MultiStdCache.class, params, sig, OBJECTNAME_MULTI_1,
-                NAME_TEMPLATE_MULTI);
-        Object[] params2 = {NAME2};
-        test(MultiStdCache.class, params2, sig, OBJECTNAME_MULTI_2,
-                NAME_TEMPLATE_MULTI);
-
-        test(MonoStdCache.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_MONO,
-                NAME_TEMPLATE_MONO);
-
-        test(Quoted.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_QUOTED,
-                NAME_TEMPLATE_QUOTED);
-
-        test(new StandardMBean(new WrappedResource(), MgtInterface.class),
-                OBJECTNAME_WRAPPED_RESOURCE, NAME_TEMPLATE_WRAPPED);
-
-        test(FullName.class, EMPTY_PARAMS, EMPTY_SIGNATURE, OBJECTNAME_FULL,
-                NAME_TEMPLATE_FULL);
-        try {
-            test(Wrong.class, EMPTY_PARAMS, EMPTY_SIGNATURE, null, null);
-            throw new Exception("No treceived expected Exception");
-        } catch (NotCompliantMBeanException ncex) {
-            if (!(ncex.getCause() instanceof AttributeNotFoundException)) {
-                throw new Exception("Invalid initCause");
-            }
-        }
-    }
-
-    @MBean
-    @ObjectNameTemplate("{Naming}")
-    public static class FullName {
-
-        @ManagedAttribute
-        public String getNaming() {
-            return FULL_NAME;
-        }
-    }
-
-    @ObjectNameTemplate("com.example:type=MgtInterface,id={Id}")
-    public interface MgtInterface {
-
-        public int getId();
-    }
-
-    public static class WrappedResource implements MgtInterface {
-
-        public int getId() {
-            return ID;
-        }
-    }
-
-    @MBean
-    @ObjectNameTemplate("com.example:type=Cache")
-    public static class Cache {
-    }
-
-    @ObjectNameTemplate("com.example:type=SubCache")
-    public static class SubCache extends Cache {
-    }
-
-    @MXBean
-    @ObjectNameTemplate("com.example:type=CacheMX")
-    public static class CacheMX {
-    }
-
-    @ObjectNameTemplate("com.example:type=SubCacheMX")
-    public static class SubCacheMX extends CacheMX {
-    }
-
-    @ObjectNameTemplate("com.example:type=StdCache")
-    public interface StdCacheMBean {
-    }
-
-    public static class StdCache implements StdCacheMBean {
-    }
-
-    @ObjectNameTemplate("com.example:type=StdCacheMX")
-    public interface StdCacheMXBean {
-    }
-
-    public static class StdCacheMX implements StdCacheMXBean {
-    }
-
-    public static class DynaCache implements DynamicMBean {
-
-        public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public AttributeList getAttributes(String[] attributes) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public AttributeList setAttributes(AttributeList attributes) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public MBeanInfo getMBeanInfo() {
-            ImmutableDescriptor d = new ImmutableDescriptor(JMX.OBJECT_NAME_TEMPLATE + "=com.example:type=DynaCache");
-
-            return new MBeanInfo("DynaCache", "Description", null, null, null, null, d);
-        }
-    }
-
-    @ObjectNameTemplate("com.example:type=MultiStdCache,name={Name}")
-    public interface MultiStdCacheMXBean {
-
-        public String getName();
-    }
-
-    public static class MultiStdCache implements MultiStdCacheMXBean {
-
-        private String name;
-
-        public MultiStdCache(String name) {
-            this.name = name;
-        }
-
-        public String getName() {
-            return name;
-        }
-    }
-
-    @ObjectNameTemplate("com.example:{Type}={TypeValue}")
-    public interface MonoStdCacheMXBean {
-
-        public String getTypeValue();
-
-        public String getType();
-    }
-
-    public static class MonoStdCache implements MonoStdCacheMXBean {
-
-        public String getTypeValue() {
-            return TYPE_VALUE;
-        }
-
-        public String getType() {
-            return TYPE_KEY;
-        }
-    }
-
-    @ObjectNameTemplate("com.example:type=Quotted,name=\"{Name}\"")
-    public interface QuottedMXBean {
-
-        public String getName();
-    }
-
-    public static class Quoted implements QuottedMXBean {
-
-        public String getName() {
-            return INVALID_NAME;
-        }
-    }
-
-    @ObjectNameTemplate("com.example:{Type}={TypeValue}, name={Name}")
-    public interface WrongMXBean {
-
-        public String getTypeValue();
-
-        public String getType();
-    }
-
-    public static class Wrong implements WrongMXBean {
-
-        public String getTypeValue() {
-            return TYPE_VALUE;
-        }
-
-        public String getType() {
-            return TYPE_KEY;
-        }
-    }
-}
--- a/test/javax/management/Introspector/ParameterNameTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 %M% %I%
- * @bug 6323980
- * @summary Test that parameter names can be specified with &#64;Name.
- * @author Eamonn McManus
- */
-
-import javax.management.MBean;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MXBean;
-import javax.management.ObjectName;
-
-import annot.Name;
-import javax.management.ManagedOperation;
-
-public class ParameterNameTest {
-    public static interface NoddyMBean {
-        public int add(int x, @Name("y") int y);
-    }
-
-    public static class Noddy implements NoddyMBean {
-        public int add(int x, int y) {
-            return x + y;
-        }
-    }
-
-    public static interface NoddyMXBean {
-        public int add(int x, @Name("y") int y);
-    }
-
-    public static class NoddyImpl implements NoddyMXBean {
-        public int add(int x, int y) {
-            return x + y;
-        }
-    }
-
-    @MBean
-    public static class NoddyAnnot {
-        @ManagedOperation
-        public int add(int x, @Name("y") int y) {
-            return x + y;
-        }
-    }
-
-    @MXBean
-    public static class NoddyAnnotMX {
-        @ManagedOperation
-        public int add(int x, @Name("y") int y) {
-            return x + y;
-        }
-    }
-
-    private static final Object[] mbeans = {
-        new Noddy(), new NoddyImpl(), new NoddyAnnot(), new NoddyAnnotMX(),
-    };
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        ObjectName name = new ObjectName("a:b=c");
-        for (Object mbean : mbeans) {
-            System.out.println("Testing " + mbean.getClass().getName());
-            mbs.registerMBean(mbean, name);
-            MBeanInfo mbi = mbs.getMBeanInfo(name);
-            MBeanOperationInfo[] mbois = mbi.getOperations();
-            assertEquals(1, mbois.length);
-            MBeanParameterInfo[] mbpis = mbois[0].getSignature();
-            assertEquals(2, mbpis.length);
-            boolean mx = Boolean.parseBoolean(
-                    (String) mbi.getDescriptor().getFieldValue("mxbean"));
-            assertEquals(mx ? "p0" : "p1", mbpis[0].getName());
-            assertEquals("y", mbpis[1].getName());
-            mbs.unregisterMBean(name);
-        }
-        System.out.println("TEST PASSED");
-    }
-
-    private static void assertEquals(Object expect, Object actual)
-    throws Exception {
-        boolean eq;
-        if (expect == null)
-            eq = (actual == null);
-        else
-            eq = expect.equals(actual);
-        if (!eq) {
-            throw new Exception(
-                    "TEST FAILED: expected " + expect + ", found " + actual);
-        }
-    }
-}
--- a/test/javax/management/Introspector/ResourceInjectionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,656 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 %M% %I%
- * @bug 6323980
- * @summary Test resource injection via &#64;Resource
- * @author Eamonn McManus
- * @run main/othervm -ea ResourceInjectionTest
- */
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import javax.annotation.Resource;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBean;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MXBean;
-import javax.management.MalformedObjectNameException;
-import javax.management.ManagedAttribute;
-import javax.management.ManagedOperation;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.SendNotification;
-import javax.management.StandardEmitterMBean;
-import javax.management.StandardMBean;
-import javax.management.openmbean.MXBeanMappingFactory;
-
-public class ResourceInjectionTest {
-    private static MBeanServer mbs;
-    private static final ObjectName objectName;
-    static {
-        try {
-            objectName = new ObjectName("test:type=Test");
-        } catch (MalformedObjectNameException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /* This is somewhat nasty.  In the current state of affairs, a
-     * StandardEmitterMBean can only get the
-     * MBeanServer to rewrite the source of a Notification from
-     * the originating object's reference to its ObjectName IF
-     * StandardEmitterMBean.getResource() returns a reference to the
-     * wrapped object.  By default it doesn't, and you need to specify
-     * the option below to make it do so.  We may hope that this is
-     * obscure enough for users to run into it rarely if ever.
-     */
-    private static final StandardMBean.Options withWrappedVisible;
-    private static final StandardMBean.Options withWrappedVisibleMX;
-    static {
-        withWrappedVisible = new StandardMBean.Options();
-        withWrappedVisible.setWrappedObjectVisible(true);
-        withWrappedVisibleMX = withWrappedVisible.clone();
-        withWrappedVisibleMX.setMXBeanMappingFactory(MXBeanMappingFactory.DEFAULT);
-    }
-
-    @Retention(RetentionPolicy.RUNTIME)
-    private static @interface ExpectException {
-        Class<? extends Exception> value();
-    }
-
-    public static void main(String[] args) throws Exception {
-        if (!ResourceInjectionTest.class.desiredAssertionStatus())
-            throw new Exception("Test must be run with -ea");
-
-        File policyFile = File.createTempFile("jmxperms", ".policy");
-        policyFile.deleteOnExit();
-        PrintWriter pw = new PrintWriter(policyFile);
-        pw.println("grant {");
-        pw.println("    permission javax.management.MBeanPermission \"*\", \"*\";");
-        pw.println("    permission javax.management.MBeanServerPermission \"*\";");
-        pw.println("    permission javax.management.MBeanTrustPermission \"*\";");
-        pw.println("};");
-        pw.close();
-
-        System.setProperty("java.security.policy", policyFile.getAbsolutePath());
-        System.setSecurityManager(new SecurityManager());
-
-        String failure = null;
-
-        for (Method m : ResourceInjectionTest.class.getDeclaredMethods()) {
-            if (Modifier.isStatic(m.getModifiers()) &&
-                    m.getName().startsWith("test") &&
-                    m.getParameterTypes().length == 0) {
-                ExpectException expexc = m.getAnnotation(ExpectException.class);
-                mbs = MBeanServerFactory.newMBeanServer();
-                try {
-                    m.invoke(null);
-                    if (expexc != null) {
-                        failure =
-                                m.getName() + " did not got expected exception " +
-                                expexc.value().getName();
-                        System.out.println(failure);
-                    } else
-                        System.out.println(m.getName() + " OK");
-                } catch (InvocationTargetException ite) {
-                    Throwable t = ite.getCause();
-                    String prob = null;
-                    if (expexc != null) {
-                        if (expexc.value().isInstance(t)) {
-                            System.out.println(m.getName() + " OK (got expected " +
-                                    expexc.value().getName() + ")");
-                        } else
-                            prob = "got wrong exception";
-                    } else
-                        prob = "got exception";
-                    if (prob != null) {
-                        failure = m.getName() + ": " + prob + " " +
-                                t.getClass().getName();
-                        System.out.println(failure);
-                        t.printStackTrace(System.out);
-                    }
-                }
-            }
-        }
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static interface Send {
-        public void send();
-    }
-
-    // Test @Resource in MBean defined by annotations
-
-    @MBean
-    public static class Annotated {
-        @Resource
-        private volatile MBeanServer mbeanServer;
-        @Resource
-        private volatile ObjectName myName;
-
-        @ManagedAttribute
-        public ObjectName getMyName() {
-            return myName;
-        }
-
-        @ManagedOperation
-        public void unregisterSelf()
-        throws InstanceNotFoundException, MBeanRegistrationException {
-            mbeanServer.unregisterMBean(myName);
-        }
-    }
-
-    private static void testAnnotated() throws Exception {
-        testMBean(new Annotated());
-    }
-
-    private static void testAnnotatedWrapped() throws Exception {
-        testMBean(new StandardMBean(new Annotated(), null));
-    }
-
-    @MBean
-    public static class AnnotatedSend extends Annotated implements Send {
-        @Resource
-        private volatile SendNotification sender;
-
-        @ManagedOperation
-        public void send() {
-            sender.sendNotification(new Notification("type", this, 0L));
-        }
-    }
-
-    private static void testAnnotatedSend() throws Exception {
-        testMBean(new AnnotatedSend());
-    }
-
-    private static void testAnnotatedSendWrapped() throws Exception {
-        testMBean(new StandardEmitterMBean(
-                new AnnotatedSend(), null, withWrappedVisible, null));
-    }
-
-    // Test @Resource in MXBean defined by annotations
-
-    @MXBean
-    public static class AnnotatedMX {
-        @Resource
-        private volatile MBeanServer mbeanServer;
-        @Resource
-        private volatile ObjectName myName;
-
-        @ManagedAttribute
-        public ObjectName getMyName() {
-            return myName;
-        }
-
-        @ManagedOperation
-        public void unregisterSelf()
-        throws InstanceNotFoundException, MBeanRegistrationException {
-            mbeanServer.unregisterMBean(myName);
-        }
-    }
-
-    private static void testAnnotatedMX() throws Exception {
-        testMBean(new AnnotatedMX());
-    }
-
-    private static void testAnnotatedMXWrapped() throws Exception {
-        testMBean(new StandardMBean(new AnnotatedMX(), null, true));
-    }
-
-    public static class AnnotatedMXSend extends AnnotatedMX implements Send {
-        @Resource
-        private volatile SendNotification sender;
-
-        @ManagedOperation
-        public void send() {
-            sender.sendNotification(new Notification("type", this, 0L));
-        }
-    }
-
-    private static void testAnnotatedMXSend() throws Exception {
-        testMBean(new AnnotatedMXSend());
-    }
-
-    private static void testAnnotatedMXSendWrapped() throws Exception {
-        testMBean(new StandardEmitterMBean(
-                new AnnotatedMXSend(), null, withWrappedVisibleMX, null));
-    }
-
-    // Test @Resource in Standard MBean
-
-    public static interface SimpleStandardMBean {
-        public ObjectName getMyName();
-        public void unregisterSelf() throws Exception;
-    }
-
-    public static class SimpleStandard implements SimpleStandardMBean {
-        @Resource(type = MBeanServer.class)
-        private volatile Object mbeanServer;
-        @Resource(type = ObjectName.class)
-        private volatile Object myName;
-
-        public ObjectName getMyName() {
-            return (ObjectName) myName;
-        }
-
-        public void unregisterSelf() throws Exception {
-            ((MBeanServer) mbeanServer).unregisterMBean(getMyName());
-        }
-    }
-
-    private static void testStandard() throws Exception {
-        testMBean(new SimpleStandard());
-    }
-
-    private static void testStandardWrapped() throws Exception {
-        testMBean(new StandardMBean(new SimpleStandard(), SimpleStandardMBean.class));
-    }
-
-    public static interface SimpleStandardSendMBean extends SimpleStandardMBean {
-        public void send();
-    }
-
-    public static class SimpleStandardSend
-            extends SimpleStandard implements SimpleStandardSendMBean {
-        @Resource(type = SendNotification.class)
-        private volatile Object sender;
-
-        public void send() {
-            ((SendNotification) sender).sendNotification(
-                    new Notification("type", this, 0L));
-        }
-    }
-
-    private static void testStandardSend() throws Exception {
-        testMBean(new SimpleStandardSend());
-    }
-
-    private static void testStandardSendWrapped() throws Exception {
-        testMBean(new StandardEmitterMBean(
-                new SimpleStandardSend(), SimpleStandardSendMBean.class,
-                withWrappedVisible, null));
-    }
-
-    // Test @Resource in MXBean
-
-    public static interface SimpleMXBean {
-        public ObjectName getMyName();
-        public void unregisterSelf() throws Exception;
-    }
-
-    public static class SimpleMX implements SimpleMXBean {
-        @Resource(type = MBeanServer.class)
-        private volatile Object mbeanServer;
-        @Resource(type = ObjectName.class)
-        private volatile Object myName;
-
-        public ObjectName getMyName() {
-            return (ObjectName) myName;
-        }
-
-        public void unregisterSelf() throws Exception {
-            ((MBeanServer) mbeanServer).unregisterMBean(getMyName());
-        }
-    }
-
-    private static void testMX() throws Exception {
-        testMBean(new SimpleMX());
-    }
-
-    private static void testMXWrapped() throws Exception {
-        testMBean(new StandardMBean(new SimpleMX(), SimpleMXBean.class, true));
-    }
-
-    public static interface SimpleMXBeanSend extends SimpleMXBean {
-        public void send();
-    }
-
-    public MBeanServer getMbs() {
-        return mbs;
-    }
-
-    public static class SimpleMXSend extends SimpleMX implements SimpleMXBeanSend {
-        @Resource(type = SendNotification.class)
-        private volatile Object sender;
-
-        public void send() {
-            ((SendNotification) sender).sendNotification(
-                    new Notification("type", this, 0L));
-        }
-    }
-
-    private static void testMXSend() throws Exception {
-        testMBean(new SimpleMXSend());
-    }
-
-    private static void testMXSendWrapped() throws Exception {
-        testMBean(new StandardEmitterMBean(
-                new SimpleMXSend(), SimpleMXBeanSend.class,
-                withWrappedVisibleMX, null));
-    }
-
-    // Test @Resource in Dynamic MBean
-
-    private static class SimpleDynamic implements DynamicMBean {
-        private MBeanServer mbeanServer;
-        private ObjectName myName;
-
-        @Resource
-        private synchronized void setMBeanServer(MBeanServer mbs) {
-            mbeanServer = mbs;
-        }
-
-        @Resource(type = ObjectName.class)
-        private synchronized void setObjectName(Serializable name) {
-            myName = (ObjectName) name;
-        }
-
-        public synchronized Object getAttribute(String attribute)
-        throws AttributeNotFoundException {
-            if (attribute.equals("MyName"))
-                return myName;
-            throw new AttributeNotFoundException(attribute);
-        }
-
-        public void setAttribute(Attribute attribute)
-        throws AttributeNotFoundException {
-            throw new AttributeNotFoundException(attribute.getName());
-        }
-
-        public synchronized AttributeList getAttributes(String[] attributes) {
-            AttributeList list = new AttributeList();
-            for (String name : attributes) {
-                if (name.equals("MyName"))
-                    list.add(new Attribute("MyName", myName));
-            }
-            return list;
-        }
-
-        public AttributeList setAttributes(AttributeList attributes) {
-            return new AttributeList();
-        }
-
-        public synchronized Object invoke(
-                String actionName, Object[] params, String[] signature)
-        throws MBeanException, ReflectionException {
-            if (actionName.equals("unregisterSelf") &&
-                    (params == null || params.length == 0) &&
-                    (signature == null || signature.length == 0)) {
-                try {
-                    mbeanServer.unregisterMBean(myName);
-                    return null;
-                } catch (Exception x) {
-                    throw new MBeanException(x);
-                }
-            } else {
-                Exception x = new NoSuchMethodException(
-                        actionName + Arrays.toString(signature));
-                throw new MBeanException(x);
-            }
-        }
-
-        public MBeanInfo getMBeanInfo() {
-            DynamicMBean mbean = new StandardMBean(
-                    new SimpleStandard(), SimpleStandardMBean.class, false);
-            return mbean.getMBeanInfo();
-        }
-    }
-
-    private static void testDynamic() throws Exception {
-        testMBean(new SimpleDynamic());
-    }
-
-    private static class SimpleDynamicSend extends SimpleDynamic {
-        private SendNotification sender;
-
-        @Resource
-        private synchronized void setSender(SendNotification sender) {
-            this.sender = sender;
-        }
-
-        @Override
-        public synchronized Object invoke(
-                String actionName, Object[] params, String[] signature)
-        throws MBeanException, ReflectionException {
-            if (actionName.equals("send")) {
-                sender.sendNotification(new Notification("type", this, 0L));
-                return null;
-            } else
-                return super.invoke(actionName, params, signature);
-        }
-    }
-
-    private static void testDynamicSend() throws Exception {
-        testMBean(new SimpleDynamicSend());
-    }
-
-    // Test that @Resource classes don't have to be public
-    // They can even be defined within methods!
-    // But you can't have any @ManagedAttributes or @ManagedOperations
-    // in such MBeans so their utility is limited.
-
-    private static void testNonPublic() throws Exception {
-        @MBean
-        class NonPublic {
-            @Resource
-            ObjectName myName;
-        }
-        assert !Modifier.isPublic(NonPublic.class.getModifiers());
-        NonPublic mbean = new NonPublic();
-        mbs.registerMBean(mbean, objectName);
-        assert objectName.equals(mbean.myName);
-    }
-
-    // Test inheritance and multiple injections of the same value
-
-    private static class ManyResources extends AnnotatedSend {
-        @Resource
-        private volatile ObjectName myName;  // same name as in parent!
-        @Resource(type=ObjectName.class)
-        private volatile Object myOtherName;
-        private volatile ObjectName myThirdName;
-        private volatile ObjectName myFourthName;
-        private volatile int methodCalls;
-        @Resource
-        private volatile SendNotification send1;
-        @Resource(type = SendNotification.class)
-        private volatile Object send2;
-
-        @Resource
-        void setMyName(ObjectName name) {
-            myThirdName = name;
-            methodCalls++;
-        }
-
-        @Resource(type=ObjectName.class)
-        private void setMyNameAgain(ObjectName name) {
-            myFourthName = name;
-            methodCalls++;
-        }
-
-        void check() {
-            assert objectName.equals(myName) : myName;
-            for (ObjectName name : new ObjectName[] {
-                (ObjectName)myOtherName, myThirdName, myFourthName
-            }) {
-                assert myName == name : name;
-            }
-            assert methodCalls == 2 : methodCalls;
-            assert send1 != null && send2 == send1;
-        }
-    }
-
-    private static void testManyResources() throws Exception {
-        ManyResources mr = new ManyResources();
-        testMBean(mr);
-        mr.check();
-    }
-
-    // Test that method override doesn't lead to multiple calls of the same method
-
-    private static class ManyResourcesSub extends ManyResources {
-        private boolean called;
-
-        @Override
-        @Resource
-        void setMyName(ObjectName name) {
-            super.setMyName(name);
-            called = true;
-        }
-
-        void check2() {
-            assert called;
-        }
-    }
-
-    private static void testOverride() throws Exception {
-        ManyResourcesSub mrs = new ManyResourcesSub();
-        testMBean(mrs);
-        mrs.check();
-        mrs.check2();
-    }
-
-    // Test that @Resource is illegal on static fields
-
-    @MBean
-    public static class StaticResource {
-        @Resource
-        private static ObjectName name;
-    }
-
-    @ExpectException(NotCompliantMBeanException.class)
-    private static void testStaticResource() throws Exception {
-        testMBean(new StaticResource());
-    }
-
-    // Test that @Resource is illegal on static methods
-
-    @MBean
-    public static class StaticResourceMethod {
-        @Resource
-        private static void setObjectName(ObjectName name) {}
-    }
-
-    @ExpectException(NotCompliantMBeanException.class)
-    private static void testStaticResourceMethod() throws Exception {
-        testMBean(new StaticResourceMethod());
-    }
-
-    // Test that @Resource is illegal on methods that don't return void
-
-    @MBean
-    public static class NonVoidMethod {
-        @Resource
-        private String setObjectName(ObjectName name) {
-            return "oops";
-        }
-    }
-
-    @ExpectException(NotCompliantMBeanException.class)
-    private static void testNonVoidMethod() throws Exception {
-        testMBean(new NonVoidMethod());
-    }
-
-    // Test that @Resource is illegal on methods with no arguments
-
-    @MBean
-    public static class NoArgMethod {
-        @Resource(type=ObjectName.class)
-        private void setObjectName() {}
-    }
-
-    @ExpectException(NotCompliantMBeanException.class)
-    private static void testNoArgMethod() throws Exception {
-        testMBean(new NoArgMethod());
-    }
-
-    // Test that @Resource is illegal on methods with more than one argument
-
-    @MBean
-    public static class MultiArgMethod {
-        @Resource
-        private void setObjectName(ObjectName name, String what) {}
-    }
-
-    @ExpectException(NotCompliantMBeanException.class)
-    private static void testMultiArgMethod() throws Exception {
-        testMBean(new MultiArgMethod());
-    }
-
-    private static class CountListener implements NotificationListener {
-        volatile int count;
-        public void handleNotification(Notification notification, Object handback) {
-            count++;
-        }
-    }
-
-    private static void testMBean(Object mbean) throws Exception {
-        mbs.registerMBean(mbean, objectName);
-
-        final ObjectName name = (ObjectName) mbs.getAttribute(objectName, "MyName");
-        assert objectName.equals(name) : name;
-
-        if (mbean instanceof Send || mbean instanceof NotificationEmitter) {
-            assert mbs.isInstanceOf(name, NotificationEmitter.class.getName());
-            CountListener countL = new CountListener();
-            mbs.addNotificationListener(name, countL, null, null);
-            NotificationListener checkSource = new NotificationListener() {
-                public void handleNotification(Notification n, Object h) {
-                    assert n.getSource().equals(name) : n.getSource();
-                }
-            };
-            mbs.addNotificationListener(name, checkSource, null, null);
-            mbs.invoke(objectName, "send", null, null);
-            assert countL.count == 1;
-            mbs.removeNotificationListener(name, checkSource);
-            mbs.removeNotificationListener(name, countL, null, null);
-        }
-
-        mbs.invoke(objectName, "unregisterSelf", null, null);
-        assert !mbs.isRegistered(objectName);
-    }
-}
--- a/test/javax/management/MBeanServer/AttributeListMapTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/*
- * 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 6336968
- * @summary Test AttributeList.toMap
- * @author Eamonn McManus
- */
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-
-public class AttributeListMapTest {
-
-    private static String failure;
-
-    public static void main(String[] args) throws Exception {
-        AttributeList attrs = new AttributeList(Arrays.asList(
-            new Attribute("Str", "Five"),
-            new Attribute("Int", 5),
-            new Attribute("Flt", 5.0)));
-
-        Map<String, Object> map = attrs.toMap();
-        final Map<String, Object> expectMap = new HashMap<String, Object>();
-        for (Attribute attr : attrs.asList())
-            expectMap.put(attr.getName(), attr.getValue());
-        assertEquals("Initial map", expectMap, map);
-        assertEquals("Initial map size", 3, map.size());
-        assertEquals("Name set", expectMap.keySet(), map.keySet());
-        assertEquals("Values", new HashSet<Object>(expectMap.values()),
-                               new HashSet<Object>(map.values()));
-        assertEquals("Entry set", expectMap.entrySet(), map.entrySet());
-
-        AttributeList attrs2 = new AttributeList(map);
-        assertEquals("AttributeList from Map", attrs, attrs2);
-        // This assumes that the Map conserves the order of the attributes,
-        // which is not specified but true because we use LinkedHashMap.
-
-        // Check that toMap fails if the list contains non-Attribute elements.
-        AttributeList attrs3 = new AttributeList(attrs);
-        attrs3.add("Hello");  // allowed but curious
-        try {
-            map = attrs3.toMap();
-            fail("toMap succeeded on list with non-Attribute elements");
-        } catch (Exception e) {
-            assertEquals("Exception for toMap with non-Atttribute elements",
-                    IllegalArgumentException.class, e.getClass());
-        }
-
-        // Check that the Map does not reflect changes made to the list after
-        // the Map was obtained.
-        AttributeList attrs4 = new AttributeList(attrs);
-        map = attrs4.toMap();
-        attrs4.add(new Attribute("Big", new BigInteger("5")));
-        assertEquals("Map after adding element to list", expectMap, map);
-
-        // Check that if there is more than one Attribute with the same name
-        // then toMap() chooses the last of them.
-        AttributeList attrs5 = new AttributeList(attrs);
-        attrs5.add(new Attribute("Str", "Cinq"));
-        map = attrs5.toMap();
-        assertEquals("Size of Map for list with duplicate attribute name",
-                3, map.size());
-        Object value = map.get("Str");
-        assertEquals("Value of Str in Map for list with two values for it",
-                "Cinq", value);
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static void assertEquals(String what, Object expect, Object actual) {
-        if (eq(expect, actual))
-            System.out.println("OK: " + what);
-        else
-            fail(what + ": expected " + expect + ", got " + actual);
-    }
-
-    private static boolean eq(Object x, Object y) {
-        return (x == null) ? (y == null) : x.equals(y);
-    }
-
-    private static void fail(String why) {
-        System.out.println("FAIL: " + why);
-        failure = why;
-    }
-}
--- a/test/javax/management/MBeanServer/DynamicWrapperMBeanTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,405 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 DynamicWrapperMBeanTest
- * @bug 6624232 6776225
- * @summary Test the DynamicWrapperMBean interface
- * @author Eamonn McManus
- */
-
-import java.lang.management.ManagementFactory;
-import javax.annotation.Resource;
-import javax.management.JMX;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationInfo;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.SendNotification;
-import javax.management.StandardEmitterMBean;
-import javax.management.StandardMBean;
-import javax.management.modelmbean.ModelMBeanInfo;
-import javax.management.modelmbean.ModelMBeanInfoSupport;
-import javax.management.modelmbean.ModelMBeanOperationInfo;
-import javax.management.modelmbean.RequiredModelMBean;
-import static javax.management.StandardMBean.Options;
-
-public class DynamicWrapperMBeanTest {
-    private static String failure;
-
-    public static void main(String[] args) throws Exception {
-        wrapTest();
-        notifTest();
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static final Options wrappedVisOpts = new Options();
-    private static final Options wrappedInvisOpts = new Options();
-    static {
-        wrappedVisOpts.setWrappedObjectVisible(true);
-        wrappedInvisOpts.setWrappedObjectVisible(false);
-    }
-
-    public static interface WrappedMBean {
-        public void sayHello();
-    }
-    public static class Wrapped implements WrappedMBean {
-        public void sayHello() {
-            System.out.println("Hello");
-        }
-    }
-
-    private static void wrapTest() throws Exception {
-        if (Wrapped.class.getClassLoader() ==
-                StandardMBean.class.getClassLoader()) {
-            throw new Exception(
-                    "TEST ERROR: Resource and StandardMBean have same ClassLoader");
-        }
-
-        assertEquals("Options withWrappedObjectVisible(false)",
-                     new Options(), wrappedInvisOpts);
-
-        Wrapped resource = new Wrapped();
-
-        StandardMBean visible =
-                new StandardMBean(resource, WrappedMBean.class, wrappedVisOpts);
-        StandardMBean invisible =
-                new StandardMBean(resource, WrappedMBean.class, wrappedInvisOpts);
-
-        assertEquals("getResource withWrappedObjectVisible(true)",
-                resource, visible.getWrappedObject());
-        assertEquals("getResource withWrappedObjectVisible(false)",
-                invisible, invisible.getWrappedObject());
-
-        System.out.println("===Testing StandardMBean===");
-
-        ObjectName visibleName = new ObjectName("a:type=visible");
-        ObjectName invisibleName = new ObjectName("a:type=invisible");
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        mbs.registerMBean(visible, visibleName);
-        mbs.registerMBean(invisible, invisibleName);
-
-        assertEquals("ClassLoader for visible resource",
-                Wrapped.class.getClassLoader(),
-                mbs.getClassLoaderFor(visibleName));
-        assertEquals("ClassLoader for invisible resource",
-                StandardMBean.class.getClassLoader(),
-                mbs.getClassLoaderFor(invisibleName));
-
-        assertEquals("isInstanceOf(WrappedMBean) for visible wrapped",
-                true, mbs.isInstanceOf(visibleName, WrappedMBean.class.getName()));
-        assertEquals("isInstanceOf(WrappedMBean) for invisible wrapped",
-                false, mbs.isInstanceOf(invisibleName, WrappedMBean.class.getName()));
-        assertEquals("isInstanceOf(StandardMBean) for visible wrapped",
-                false, mbs.isInstanceOf(visibleName, StandardMBean.class.getName()));
-        assertEquals("isInstanceOf(StandardMBean) for invisible wrapped",
-                true, mbs.isInstanceOf(invisibleName, StandardMBean.class.getName()));
-
-        mbs.unregisterMBean(visibleName);
-        mbs.unregisterMBean(invisibleName);
-
-        System.out.println("===Testing RequiredModelMBean===");
-
-        // Godawful Model MBeans...
-        ModelMBeanOperationInfo mmboi = new ModelMBeanOperationInfo(
-                "say hello to the nice man", Wrapped.class.getMethod("sayHello"));
-        ModelMBeanInfo visibleMmbi = new ModelMBeanInfoSupport(
-                Wrapped.class.getName(), "Visible wrapped", null, null,
-                new ModelMBeanOperationInfo[] {mmboi}, null);
-        ModelMBeanInfo invisibleMmbi = new ModelMBeanInfoSupport(
-                Wrapped.class.getName(), "Invisible wrapped", null, null,
-                new ModelMBeanOperationInfo[] {mmboi}, null);
-        RequiredModelMBean visibleRmmb = new RequiredModelMBean(visibleMmbi);
-        RequiredModelMBean invisibleRmmb = new RequiredModelMBean(invisibleMmbi);
-        visibleRmmb.setManagedResource(resource, "VisibleObjectReference");
-        invisibleRmmb.setManagedResource(resource, "ObjectReference");
-
-        mbs.registerMBean(visibleRmmb, visibleName);
-        mbs.registerMBean(invisibleRmmb, invisibleName);
-
-        assertEquals("ClassLoader for visible wrapped",
-                Wrapped.class.getClassLoader(),
-                mbs.getClassLoaderFor(visibleName));
-        assertEquals("ClassLoader for invisible wrapped",
-                StandardMBean.class.getClassLoader(),
-                mbs.getClassLoaderFor(invisibleName));
-
-        assertEquals("isInstanceOf(WrappedMBean) for visible resource",
-                true, mbs.isInstanceOf(visibleName, WrappedMBean.class.getName()));
-        assertEquals("isInstanceOf(WrappedMBean) for invisible resource",
-                false, mbs.isInstanceOf(invisibleName, WrappedMBean.class.getName()));
-        assertEquals("isInstanceOf(RequiredModelMBean) for visible resource",
-                false, mbs.isInstanceOf(visibleName, RequiredModelMBean.class.getName()));
-        assertEquals("isInstanceOf(RequiredModelMBean) for invisible resource",
-                true, mbs.isInstanceOf(invisibleName, RequiredModelMBean.class.getName()));
-
-        mbs.unregisterMBean(visibleName);
-        mbs.unregisterMBean(invisibleName);
-    }
-
-    private static enum WrapType {
-        NBS("NotificationBroadcasterSupport"),
-        INJ("@Resource SendNotification"),
-        STD_MBEAN_NBS("StandardMBean delegating to NotificationBroadcasterSupport"),
-        STD_MBEAN_INJ("StandardMBean delegating to @Resource SendNotification"),
-        STD_MBEAN_SUB_NBS("StandardMBean subclass implementing NotificationBroadcaster"),
-        STD_MBEAN_SUB_INJ("StandardMBean subclass with @Resource SendNotification"),
-        STD_EMIT_MBEAN_NBS("StandardEmitterMBean delegating to NotificationBroadcasterSupport"),
-        STD_EMIT_MBEAN_INJ("StandardEmitterMBean delegating to @Resource SendNotification"),
-        STD_EMIT_MBEAN_SUB("StandardEmitterMBean subclass"),
-        STD_EMIT_MBEAN_SUB_INJ("StandardEmitterMBean subclass with @Resource SendNotification");
-
-        WrapType(String s) {
-            this.s = s;
-        }
-
-        @Override
-        public String toString() {
-            return s;
-        }
-
-        private final String s;
-    }
-
-    @NotificationInfo(
-        types = {"foo", "bar"}
-    )
-    public static interface BroadcasterMBean {
-        public void send(Notification n);
-    }
-
-    public static class Broadcaster
-            extends NotificationBroadcasterSupport implements BroadcasterMBean {
-        public void send(Notification n) {
-            super.sendNotification(n);
-        }
-    }
-
-    public static interface SendNotifMBean extends BroadcasterMBean {
-    }
-
-    public static class SendNotif implements SendNotifMBean {
-        @Resource
-        private volatile SendNotification sendNotif;
-
-        public void send(Notification n) {
-            sendNotif.sendNotification(n);
-        }
-    }
-
-    public static class StdBroadcaster
-            extends StandardMBean
-            implements BroadcasterMBean, NotificationBroadcaster {
-        private final NotificationBroadcasterSupport nbs =
-                new NotificationBroadcasterSupport();
-
-        public StdBroadcaster() throws Exception {
-            super(BroadcasterMBean.class);
-        }
-
-        public void send(Notification n) {
-            nbs.sendNotification(n);
-        }
-
-        public void addNotificationListener(NotificationListener listener,
-                NotificationFilter filter, Object handback) {
-            nbs.addNotificationListener(listener, filter, handback);
-        }
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            return null;
-        }
-
-        public void removeNotificationListener(NotificationListener listener)
-                throws ListenerNotFoundException {
-            nbs.removeNotificationListener(listener);
-        }
-    }
-
-    public static class StdSendNotif
-            extends StandardMBean implements SendNotifMBean {
-        @Resource
-        private volatile SendNotification sendNotif;
-
-        public StdSendNotif() throws Exception {
-            super(SendNotifMBean.class);
-        }
-
-        public void send(Notification n) {
-            sendNotif.sendNotification(n);
-        }
-    }
-
-    public static class StdEmitterBroadcaster // :-)
-            extends StandardEmitterMBean
-            implements BroadcasterMBean {
-
-        public StdEmitterBroadcaster() throws Exception {
-            super(BroadcasterMBean.class, null);
-        }
-
-        public void send(Notification n) {
-            super.sendNotification(n);
-        }
-    }
-
-    // This case is unlikely - if you're using @Resource SendNotification
-    // then there's no point in using StandardEmitterMBean, since
-    // StandardMBean would suffice.
-    public static class StdEmitterSendNotif
-            extends StandardEmitterMBean implements SendNotifMBean {
-        @Resource
-        private volatile SendNotification sendNotif;
-
-        public StdEmitterSendNotif() {
-            super(SendNotifMBean.class, null);
-        }
-
-        public void send(Notification n) {
-            sendNotif.sendNotification(n);
-        }
-    }
-
-    // Test that JMX.isNotificationSource and
-    // mbs.isInstanceOf("NotificationBroadcaster") work correctly even when
-    // the MBean is a broadcaster by virtue of its wrapped resource.
-    // Test that we find the MBeanNotificationInfo[] from the @NotificationInfo
-    // annotation on BroadcasterMBean.  We cover a large number of different
-    // MBean types, but all ultimately implement that interface.
-    private static void notifTest() throws Exception {
-        System.out.println("===Testing notification senders===");
-
-        for (WrapType wrapType : WrapType.values()) {
-            System.out.println("---" + wrapType);
-
-            final Object mbean;
-
-            switch (wrapType) {
-            case NBS:
-                // An MBean that extends NotificationBroadcasterSupport
-                mbean = new Broadcaster();
-                break;
-            case INJ:
-                // An MBean that injects SendNotification
-                mbean = new SendNotif();
-                break;
-            case STD_MBEAN_NBS:
-                // A StandardMBean that delegates to a NotificationBroadcasterSupport
-                mbean = new StandardMBean(
-                        new Broadcaster(), BroadcasterMBean.class, wrappedVisOpts);
-                break;
-            case STD_MBEAN_INJ:
-                // A StandardMBean that delegates to an object that injects
-                // SendNotification
-                mbean = new StandardMBean(
-                        new SendNotif(), BroadcasterMBean.class, wrappedVisOpts);
-                break;
-            case STD_EMIT_MBEAN_NBS: {
-                // A StandardEmitterMBean that delegates to a NotificationBroadcasterSupport
-                Broadcaster broadcaster = new Broadcaster();
-                mbean = new StandardEmitterMBean(
-                        broadcaster, BroadcasterMBean.class, wrappedVisOpts,
-                        broadcaster);
-                break;
-            }
-            case STD_EMIT_MBEAN_INJ: {
-                // A StandardEmitterMBean that delegates to an object that injects
-                // SendNotification
-                SendNotif sendNotif = new SendNotif();
-                mbean = new StandardEmitterMBean(
-                        sendNotif, BroadcasterMBean.class, wrappedVisOpts,
-                        null);
-                break;
-            }
-            case STD_MBEAN_SUB_NBS:
-                // A subclass of StandardMBean that implements NotificationBroadcaster
-                mbean = new StdBroadcaster();
-                break;
-            case STD_MBEAN_SUB_INJ:
-                // A subclass of StandardMBean that injects SendNotification
-                mbean = new StdSendNotif();
-                break;
-            case STD_EMIT_MBEAN_SUB:
-                // A subclass of StandardEmitterMBean
-                mbean = new StdEmitterBroadcaster();
-                break;
-            case STD_EMIT_MBEAN_SUB_INJ:
-                // A subclass of StandardEmitterMBean that injects SendNotification
-                // (which is a rather strange thing to do and probably a user
-                // misunderstanding but we should do the right thing anyway).
-                mbean = new StdEmitterSendNotif();
-                break;
-            default:
-                throw new AssertionError();
-            }
-
-            MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-
-            final ObjectName name = new ObjectName("a:type=Sender");
-            mbs.registerMBean(mbean, name);
-            boolean isBroadcaster = mbs.isInstanceOf(
-                    name, NotificationBroadcaster.class.getName());
-            assertEquals("JMX.isNotificationSource(mbean)",
-                    true, JMX.isNotificationSource(mbean));
-            assertEquals("isInstanceOf(NotificationBroadcaster)",
-                    true, isBroadcaster);
-            MBeanNotificationInfo[] mbnis =
-                    mbs.getMBeanInfo(name).getNotifications();
-            assertEquals("MBeanNotificationInfo not empty",
-                    true, (mbnis.length > 0));
-
-            mbs.unregisterMBean(name);
-        }
-    }
-
-    private static void assertEquals(String what, Object expect, Object actual) {
-        if (equal(expect, actual))
-            System.out.println("OK: " + what + " = " + expect);
-        else
-            fail(what + " should be " + expect + ", is " + actual);
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        return x.equals(y);
-    }
-
-    private static void fail(String why) {
-        failure = why;
-        System.out.println("FAIL: " + why);
-    }
-}
--- a/test/javax/management/MBeanServer/InstanceNotFoundExceptionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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 6669137
- * @summary Test the constructors of InstanceNotFoundExceptionTest.
- * @author Daniel Fuchs
- * @compile InstanceNotFoundExceptionTest.java
- * @run main InstanceNotFoundExceptionTest
- */
-
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
-public class InstanceNotFoundExceptionTest {
-    public static void main(String[] args) throws Exception {
-        final InstanceNotFoundException x =
-                new InstanceNotFoundException();
-        System.out.println("InstanceNotFoundException(): "+x.getMessage());
-
-        final String msg = "who is toto?";
-        final InstanceNotFoundException x2 =
-                new InstanceNotFoundException(msg);
-        if (!msg.equals(x2.getMessage()))
-            throw new Exception("Bad message: expected "+msg+
-                    ", got "+x2.getMessage());
-        System.out.println("InstanceNotFoundException(" +
-                msg+"): "+x2.getMessage());
-
-        final InstanceNotFoundException x3 =
-                new InstanceNotFoundException((String)null);
-        if (x3.getMessage() != null)
-            throw new Exception("Bad message: expected "+null+
-                    ", got "+x3.getMessage());
-        System.out.println("InstanceNotFoundException((String)null): "+
-                x3.getMessage());
-
-        final ObjectName n = new ObjectName("who is toto?:type=msg");
-        final InstanceNotFoundException x4 =
-                new InstanceNotFoundException(n);
-        if (!String.valueOf(n).equals(x4.getMessage()))
-            throw new Exception("Bad message: expected "+n+
-                    ", got "+x4.getMessage());
-        System.out.println("InstanceNotFoundException(" +
-                n+"): "+x4.getMessage());
-
-        final InstanceNotFoundException x5 =
-                new InstanceNotFoundException((ObjectName)null);
-        if (!String.valueOf((ObjectName)null).equals(x5.getMessage()))
-            throw new Exception("Bad message: expected " +
-                    String.valueOf((ObjectName)null)+" got "+x5.getMessage());
-        System.out.println("InstanceNotFoundException((ObjectName)null): "+
-                x5.getMessage());
-    }
-}
--- a/test/javax/management/MBeanServer/MBeanExceptionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/MBeanServer/MBeanExceptionTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -34,8 +34,16 @@
 
 import java.util.Collections;
 import java.util.Set;
-import javax.management.*;
-import javax.management.namespace.MBeanServerSupport;
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.DynamicMBean;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+import javax.management.RuntimeMBeanException;
+import javax.management.StandardMBean;
 
 public class MBeanExceptionTest {
     public static void main(String[] args) throws Exception {
@@ -62,46 +70,41 @@
 
         final boolean[] booleans = {false, true};
 
-        for (boolean mbss : booleans) {
-            for (boolean runtimeX : booleans) {
-                Class<? extends Exception> excC =
-                        runtimeX ? RuntimeMBeanException.class : MBeanException.class;
-                String excS =
-                        runtimeX ? "a RuntimeMBeanException" : "an MBeanException";
-                String mbsS =
-                        mbss ? "a conformant MBeanServerSupport" : "a plain MBeanServer";
-                MBeanServer xmbs =
-                        mbss ? new CreateExceptionMBS() : mbs;
+        for (boolean runtimeX : booleans) {
+            Class<? extends Exception> excC =
+                    runtimeX ? RuntimeMBeanException.class : MBeanException.class;
+            String excS =
+                    runtimeX ? "a RuntimeMBeanException" : "an MBeanException";
+            String mbsS = "a plain MBeanServer";
+            System.out.println(
+                    "Test that, with " + mbsS + ", " + excS + " is wrapped " +
+                    "in " + excS);
+            // E.g. "Test that, with a plain MBeanServer, an MBeanException
+            // is wrapped in an MBeanException".
+            try {
+                mbs.createMBean(
+                        Except.class.getName(), new ObjectName(":name=Oops"),
+                        new Object[] {runtimeX},
+                        new String[] {boolean.class.getName()});
                 System.out.println(
-                        "Test that, with " + mbsS + ", " + excS + " is wrapped " +
-                        "in " + excS);
-                // E.g. "Test that, with a plain MBeanServer, an MBeanException
-                // is wrapped in an MBeanException".
-                try {
-                    mbs.createMBean(
-                            Except.class.getName(), new ObjectName(":name=Oops"),
-                            new Object[] {runtimeX},
-                            new String[] {boolean.class.getName()});
+                        "FAIL: createMBean succeeded but should not have");
+                failures++;
+            } catch (Exception e) {
+                if (!excC.isInstance(e)) {
                     System.out.println(
-                            "FAIL: createMBean succeeded but should not have");
+                            "FAIL: expected " + excC.getName() + " from " +
+                            "createMBean, got " + e);
                     failures++;
-                } catch (Exception e) {
-                    if (!excC.isInstance(e)) {
+                } else {
+                    Throwable cause = e.getCause();
+                    if (!excC.isInstance(cause)) {
                         System.out.println(
-                                "FAIL: expected " + excC.getName() + " from " +
-                                "createMBean, got " + e);
+                                "FAIL: expected " + excC.getName() +
+                                " as cause of " + excC.getName() +
+                                ", got " + e);
                         failures++;
-                    } else {
-                        Throwable cause = e.getCause();
-                        if (!excC.isInstance(cause)) {
-                            System.out.println(
-                                    "FAIL: expected " + excC.getName() +
-                                    " as cause of " + excC.getName() +
-                                    ", got " + e);
-                            failures++;
-                        } else
-                            System.out.println("...ok");
-                    }
+                    } else
+                        System.out.println("...ok");
                 }
             }
         }
@@ -280,28 +283,4 @@
     private static final RuntimeException theUncheckedException =
         new UnsupportedOperationException("The unchecked exception " +
                                           "that should be seen");
-
-    private static class CreateExceptionMBS extends MBeanServerSupport {
-        @Override
-        protected Set<ObjectName> getNames() {
-            return Collections.emptySet();
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            throw new InstanceNotFoundException(name);
-        }
-
-        @Override
-        public ObjectInstance createMBean(String className,
-                ObjectName name, ObjectName loaderName, Object[] params,
-                String[] signature, boolean useCLR)
-                throws ReflectionException, InstanceAlreadyExistsException,
-                MBeanRegistrationException, MBeanException,
-                NotCompliantMBeanException, InstanceNotFoundException {
-            Exception wrapped = new MBeanException(new Exception(), "Bang");
-            throw new MBeanException(wrapped, "Bang");
-        }
-    }
 }
--- a/test/javax/management/MBeanServerFactory/NamedMBeanServerTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,441 +0,0 @@
-/*
- * Copyright 2003-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
- * @summary Test named MBeanServers.
- * @author Daniel Fuchs
- * @bug 6299231
- * @run clean NamedMBeanServerTest
- * @run build NamedMBeanServerTest
- * @run main NamedMBeanServerTest
- */
-
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerBuilder;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerFactory;
-
-/**
- * This test can probably be leveraged in the JCK to test compatibilty
- * of MBeanServerFactory *Name* method implementation.
- * @author dfuchs
- */
-public class NamedMBeanServerTest {
-
-    /**
-     * One enum value for each way of creating an MBeanServer through the
-     * MBeanServerFactory
-     */
-    public static enum Creator {
-        newMBeanServer() {
-            public MBeanServer create(String domain) {
-                return MBeanServerFactory.newMBeanServer(domain);
-            }
-            public String test(MBeanServer server, String domain) {
-                System.out.println(toString()+"("+domain+")");
-                return test(server,
-                        MBeanServerFactory.DEFAULT_MBEANSERVER_NAME,
-                        domain);
-            }
-            public MBeanServer[] servers(Config config) {
-                return config.ndServers;
-            }
-            public String[] strings(Config config) {
-                return domains(config);
-            }
-            public String[] domains(Config config) {
-                return config.newDomains;
-            }
-            public String[] names(Config config) {
-                return null;
-            }
-        },
-        createMBeanServer() {
-            public MBeanServer create(String domain) {
-                return MBeanServerFactory.createMBeanServer(domain);
-            }
-            public String test(MBeanServer server, String domain) {
-                System.out.println(toString()+"("+domain+")");
-                return test(server,MBeanServerFactory.DEFAULT_MBEANSERVER_NAME,
-                        domain);
-            }
-            public MBeanServer[] servers(Config config) {
-                return config.cdServers;
-            }
-            public String[] strings(Config config) {
-                return domains(config);
-            }
-            public String[] domains(Config config) {
-                return config.createDomains;
-            }
-            public String[] names(Config config) {
-                return null;
-            }
-        },
-        newNamedMBeanServer() {
-            public MBeanServer create(String name) {
-                return MBeanServerFactory.newNamedMBeanServer(name,null);
-            }
-            public String test(MBeanServer server, String name) {
-                System.out.println(toString()+"("+name+",null)");
-                return test(server,name,"DefaultDomain");
-            }
-            public MBeanServer[] servers(Config config) {
-                return config.nnServers;
-            }
-            public String[] strings(Config config) {
-                return names(config);
-            }
-            public String[] domains(Config config) {
-                return null;
-            }
-            public String[] names(Config config) {
-                return config.newNames;
-            }
-        },
-        createNamedMBeanServer() {
-            public MBeanServer create(String name) {
-                return MBeanServerFactory.createNamedMBeanServer(name,null);
-            }
-            public String test(MBeanServer server, String name) {
-                System.out.println(toString()+"("+name+",null)");
-                return test(server,name,"DefaultDomain");
-            }
-            public MBeanServer[] servers(Config config) {
-                return config.cnServers;
-            }
-            public String[] strings(Config config) {
-                return names(config);
-            }
-            public String[] domains(Config config) {
-                return null;
-            }
-            public String[] names(Config config) {
-                return config.createNames;
-            }
-        };
-
-        // creates an MBeanServer using the specified input string.
-        // either a domain, (for UNNAMED) or a mbeanServerName (for NAMED)
-        public abstract MBeanServer create(String string);
-
-        // test the created server against the string used as input to create
-        // it.
-        public abstract String test(MBeanServer server, String ref);
-
-        public abstract MBeanServer[] servers(Config config);
-        public abstract String[] strings(Config config);
-        public abstract String[] names(Config config);
-        public abstract String[] domains(Config config);
-
-        public MBeanServer[] servers(Config config, String... refs) {
-            final MBeanServer[] servers = servers(config);
-            final String[] strings = strings(config);
-            final MBeanServer[] res = new MBeanServer[refs.length];
-            for (int i=0;i<refs.length;i++) {
-                for (int j=0;j<strings.length;j++) {
-                    if (strings[j].equals(refs[i]))
-                        res[i]=servers[j];
-                }
-                if (res[i] == null)
-                    throw new IllegalArgumentException(refs[i]);
-            }
-            return res;
-        }
-
-        String test(MBeanServer server, String name, String domain) {
-            // whether the MBeanServer was created throug a "create" method
-            boolean registered = REFERENCED.contains(this);
-            if (!server.getDefaultDomain().equals(domain)) {
-                return "Unexpected default domain: " +
-                        server.getDefaultDomain() + ", should be: " + domain;
-            }
-            if (!MBeanServerFactory.getMBeanServerName(server).
-                    equals(name)) {
-                return " Unexpected name: " +
-                        MBeanServerFactory.getMBeanServerName(server) +
-                        ", should be: " + name;
-            }
-            List<MBeanServer> found =
-                    MBeanServerFactory.findMBeanServerByName(name);
-            if (!registered && found.contains(server))
-                return " Server "+name+" found by name - " +
-                        "but should not be registered";
-            if (!registered &&
-                    !name.equals(MBeanServerFactory.DEFAULT_MBEANSERVER_NAME) &&
-                    found.size()>0)
-                return " Server "+name+" had too many matches: " + found.size();
-            if (registered && !found.contains(server))
-                return " Server "+name+" not found by name - " +
-                        "but is registered!";
-            if (registered &&
-                    !name.equals(MBeanServerFactory.DEFAULT_MBEANSERVER_NAME) &&
-                    !(found.size()==1))
-                return " Server "+name+" had too many matches: " + found.size();
-            return null;
-        }
-
-        public static final EnumSet<Creator> NAMED =
-                EnumSet.of(createNamedMBeanServer, newNamedMBeanServer);
-        public static final EnumSet<Creator> UNNAMED =
-                EnumSet.complementOf(NAMED);
-        public static final EnumSet<Creator> REFERENCED =
-                EnumSet.of(createMBeanServer, createNamedMBeanServer);
-        public static final EnumSet<Creator> UNREFERENCED =
-                EnumSet.complementOf(REFERENCED);
-
-    }
-
-    public static class Config {
-        final String[] newDomains;
-        final String[] createDomains;
-        final String[] newNames;
-        final String[] createNames;
-        final MBeanServer[] ndServers;
-        final MBeanServer[] cdServers;
-        final MBeanServer[] nnServers;
-        final MBeanServer[] cnServers;
-        final Map<String,Set<MBeanServer>> queries;
-        Config(String[][] data) {
-            this(data[0],data[1],data[2],data[3]);
-        }
-        Config(String[] nd, String[] cd, String[] nn, String[] cn) {
-            this.newDomains=nd.clone();
-            this.createDomains=cd.clone();
-            this.newNames=nn.clone();
-            this.createNames=cn.clone();
-            ndServers = new MBeanServer[nd.length];
-            cdServers = new MBeanServer[cd.length];
-            nnServers = new MBeanServer[nn.length];
-            cnServers = new MBeanServer[cn.length];
-            queries = new HashMap<String,Set<MBeanServer>>();
-            init();
-        }
-        private void init() {
-            for (Creator c : Creator.values()) fill(c);
-            addQuery(null,Creator.createMBeanServer.servers(this));
-            addQuery(null,Creator.createNamedMBeanServer.servers(this));
-            addQuery("?*",Creator.createMBeanServer.servers(this));
-            addQuery("?*",Creator.createNamedMBeanServer.servers(this));
-            addQuery("*",Creator.createMBeanServer.servers(this));
-            addQuery("*",Creator.createNamedMBeanServer.servers(this));
-            addQuery(MBeanServerFactory.DEFAULT_MBEANSERVER_NAME,
-                    Creator.createMBeanServer.servers(this));
-        }
-        private void addQuery(String pattern, MBeanServer... servers) {
-            final Set<MBeanServer> s = getQuery(pattern);
-            s.addAll(Arrays.asList(servers));
-        }
-        public Set<MBeanServer> getQuery(String pattern) {
-            final Set<MBeanServer> s = queries.get(pattern);
-            if (s != null) return s;
-            queries.put(pattern,new HashSet<MBeanServer>());
-            return queries.get(pattern);
-        }
-        public Set<String> getPatterns() {
-            return queries.keySet();
-        }
-        private void fill(Creator creator) {
-            fill(creator.servers(this),creator.strings(this),creator);
-        }
-        private void fill(MBeanServer[] dest, String[] src, Creator creator) {
-            for(int i=0;i<src.length;i++) dest[i]=creator.create(src[i]);
-        }
-
-    }
-
-    static String[] domains(String... str) {
-        return str;
-    }
-    static String[] names(String... str) {
-        return str;
-    }
-    final static Config test1  = new Config(domains("foo1","foo2","foo3"),
-            domains("foobar1","foobar2","foobar3","foobar4"),
-            names("bar1","bar2"),
-            names("barfoo1","barfoo2","barfoo3","batfox1","catfog2","foofoo3"));
-    static {
-        test1.addQuery("b*",Creator.createNamedMBeanServer.servers(test1,
-                "barfoo1","barfoo2","barfoo3","batfox1"));
-        test1.addQuery("*arf*",Creator.createNamedMBeanServer.servers(test1,
-                "barfoo1","barfoo2","barfoo3"));
-        test1.addQuery("*a?f*",Creator.createNamedMBeanServer.servers(test1,
-                "barfoo1","barfoo2","barfoo3","batfox1","catfog2"));
-        test1.addQuery("",new MBeanServer[0]);
-        test1.addQuery("-",new MBeanServer[0]);
-        test1.addQuery("def*",Creator.createMBeanServer.servers(test1));
-    }
-
-    public static void test(Config config) throws Exception {
-        for (Creator c : Creator.values()) {
-            final MBeanServer[] s = c.servers(config);
-            final String[] ref = c.strings(config);
-            for (int i=0;i<s.length;i++) {
-                final String msg = c.test(s[i], ref[i]);
-                if (msg != null)
-                    throw new Exception(String.valueOf(c)+"["+i+"]: "+msg);
-            }
-        }
-        for (String pat : config.getPatterns()) {
-            System.out.print("findMBeanServerByName(\""+pat+"\"): [");
-            final List<MBeanServer> found =
-                    MBeanServerFactory.findMBeanServerByName(pat);
-            String sep=" ";
-            for (MBeanServer m : found) {
-                System.out.print(sep+MBeanServerFactory.getMBeanServerName(m));
-                sep=", ";
-            }
-            System.out.println(" ]");
-            final Set<MBeanServer> founds = new HashSet<MBeanServer>();
-            founds.addAll(found);
-            if (!founds.equals(config.getQuery(pat))) {
-                final String msg =
-                        "bad result for findMBeanServerByName(\""+
-                        pat+"\"): expected "+config.getQuery(pat).size()+", "+
-                        "got "+founds.size();
-                throw new Exception(msg);
-            }
-        }
-    }
-
-    public static void testexception(Creator c, String name,
-            Class<? extends Exception> error) throws Exception {
-        Exception failed = null;
-        MBeanServer server = null;
-        try {
-            server = c.create(name);
-        } catch (Exception x) {
-            failed = x;
-        } finally {
-            if (Creator.REFERENCED.contains(c) && server!=null) {
-                MBeanServerFactory.releaseMBeanServer(server);
-            }
-        }
-        if (failed == null && error != null) {
-            throw new Exception("Expected "+error.getName()+
-                    " for "+c+"("+name+")");
-        }
-        if (error != null && !error.isInstance(failed))
-            throw new Exception("Expected "+error.getName()+
-                    " for "+c+"("+name+"), caught "+failed);
-        System.out.println(""+c+"("+name+") PASSED: "+
-                (failed==null?"no exception":String.valueOf(failed)));
-    }
-
-    private static final Map<String,Class<? extends Exception>> failures =
-            new LinkedHashMap<String,Class<? extends Exception>>();
-    private static final Map<String,Class<? extends Exception>> legacy =
-            new LinkedHashMap<String,Class<? extends Exception>>();
-    private static final String[] illegalnames = {
-        "", "-", ":", ";", "?", "*", "wom?bat", "ran:tan.plan",
-        "rin;tin.tin", "tab*mow"
-
-    };
-    private static final String[] legalnames = {
-        "wombat", "top.tip", "ran.tan.plan", "rin.tin.tin!"
-    };
-    private static final String[] nofailures = {
-       MBeanServerFactory.DEFAULT_MBEANSERVER_NAME, "default", null
-    };
-    static {
-        for (String s:illegalnames)
-            failures.put(s, IllegalArgumentException.class);
-        for (String s:nofailures)
-            failures.put(s, null);
-        legacy.putAll(failures);
-        for (String s:legalnames)
-            legacy.put(s, UnsupportedOperationException.class);
-
-    }
-
-    public static void test2(Map<String,Class<? extends Exception>> config)
-        throws Exception {
-        for (Creator c:Creator.NAMED) {
-            for (String s:config.keySet()) testexception(c, s, config.get(s));
-        }
-    }
-
-    public static class LegacyBuilder extends MBeanServerBuilder {
-
-        @Override
-        public MBeanServerDelegate newMBeanServerDelegate() {
-            return new MBeanServerDelegate() {
-                @Override
-                public synchronized String getMBeanServerId() {
-                    return "gloups";
-                }
-            };
-        }
-
-    }
-    public static class LegacyBuilder2 extends MBeanServerBuilder {
-
-        @Override
-        public MBeanServerDelegate newMBeanServerDelegate() {
-            return new MBeanServerDelegate() {
-                @Override
-                public synchronized String getMBeanServerId() {
-                    return "c'est la vie...";
-                }
-                @Override
-                public synchronized void setMBeanServerName(String name) {
-                }
-
-            };
-        }
-
-    }
-
-    public static void test3(Map<String,Class<? extends Exception>> config,
-            String builderClassName)
-        throws Exception {
-        final String builder =
-                System.getProperty("javax.management.builder.initial");
-        System.setProperty("javax.management.builder.initial",
-                builderClassName);
-        try {
-            test2(config);
-        } finally {
-            if (builder != null)
-                System.setProperty("javax.management.builder.initial", builder);
-            else
-                System.clearProperty("javax.management.builder.initial");
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        test(test1);
-        test2(failures);
-        test3(legacy,LegacyBuilder.class.getName());
-        test3(legacy,LegacyBuilder2.class.getName());
-    }
-}
--- a/test/javax/management/ObjectName/ApplyWildcardTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/ObjectName/ApplyWildcardTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,13 +28,10 @@
  *          with wildcards in the key properties value part.
  * @author Luis-Miguel Alventosa
  * @run clean ApplyWildcardTest
- * @compile -XDignore.symbol.file=true ApplyWildcardTest.java
  * @run build ApplyWildcardTest
  * @run main ApplyWildcardTest
  */
 
-import com.sun.jmx.mbeanserver.Repository;
-import com.sun.jmx.mbeanserver.Util;
 import javax.management.ObjectName;
 
 public class ApplyWildcardTest {
@@ -77,75 +74,6 @@
         { "d:k1=\"a?b\",k2=\"c*d\"", "d:k1=\"axb\",k2=\"cyzd\"" },
         { "d:k1=\"a?b\",k2=\"c*d\",*", "d:k1=\"axb\",k2=\"cyzd\",k3=\"v3\"" },
         { "d:*,k1=\"a?b\",k2=\"c*d\"", "d:k1=\"axb\",k2=\"cyzd\",k3=\"v3\"" },
-
-        // with namespaces
-
-        { "*//:*", "d//:k=v" },
-        { "//?:*", "///:k=v" },
-        { "z*x//:*", "zaxcx//:k=v" },
-        { "*//:*", "d/xx/q//:k=v" },
-        { "z*x//:*", "z/a/x/c/x//:k=v" },
-        { "*x?//:*", "dbdbdxk//:k=v" },
-        { "z*x?x//:*", "zaxcx//:k=v" },
-        { "*x?f//:*", "d/xxf/qxbf//:k=v" },
-        { "z*x?c*x//:*", "z/a/x/c/x//:k=v" },
-
-        { "*//*:*", "d/c/v//x/vgh/:k=v" },
-        { "z*x//z*x:*", "zaxcx//zaxcxcx:k=v" },
-        { "//*//:*", "//d/xx/q//:k=v" },
-        { "z*//*//:*", "z/x/x/z//z/a/x/c/x//:k=v" },
-        { "*x?//blur?g*:*", "dbdbdxk//blurhgblurgh/x/:k=v" },
-        { "z*x??x//??:*", "zaxcxccx///.:k=v" },
-        { "*x?f//?:*", "d/xxf/qxbf///:k=v" },
-        { "z*x?c*x//*//z????//g:*", "z/a/x/c/x//gloubs/././/zargh//g:k=v" },
-        { "z*x?c*x//*//:*", "z/a/x/c/x//gloubs/././/:k=v"},
-        { "*//*//:*", "aza//bzb//:k=v" },
-        { "*//:*", "aza//:k=v" },
-
-        // with or without namespaces, * can also match nothing
-        { "x*z:*", "xz:k=v"},
-
-        { "*//:*", "//:k=v" },
-        { "z*x//:*", "zx//:k=v" },
-        { "*x?//:*", "xk//:k=v" },
-        { "z*x?x//:*", "zxcx//:k=v" },
-        { "*x?f//:*", "xbf//:k=v" },
-        { "z*x?c*x//:*", "zx/cx//:k=v" },
-
-        { "*//*:*", "//:k=v" },
-        { "z*x//z*x:*", "zx//zx:k=v" },
-        { "//*//:*", "////:k=v" },
-        { "z*//*//:*", "z////:k=v" },
-        { "*x?//blur?g*:*", "xk//blurhg:k=v" },
-        { "z*x??x//??:*", "zxccx///.:k=v" },
-        { "*x?f//?:*", "xbf///:k=v" },
-        { "z*x?c*x//*//z????//g:*", "zx/cx////zargh//g:k=v" },
-        { "z*x?c*x//*//:*", "zx/cx////:k=v"},
-        { "*//*//:*", "////:k=v" },
-        { "*//:*", "//:k=v" },
-
-        // recursive namespace meta-wildcard
-        {"**//D:k=v", "a//D:k=v"},
-        {"**//D:k=v", "a//b//c//D:k=v"},
-        {"a//**//D:k=v", "a//b//c//D:k=v"},
-        {"a//**//d//D:k=v", "a//b//c//d//D:k=v"},
-        {"a//**//d//D:k=v", "a//b//c//d//d//D:k=v"},
-        {"a//**//d//D:k=v", "a//a//b//c//d//d//D:k=v"},
-        {"a//**//d//**//e//D:k=v", "a//a//b//d//c//d//e//D:k=v"},
-
-        // special cases for names ending with //
-        { "*:*", "d//:k=v" },
-        { "z*x*:*", "zaxcx//:k=v" },
-        { "*:*", "d/xx/q//:k=v" },
-        { "z*x??:*", "z/a/x/c/x//:k=v" },
-        { "*x???:*", "dbdbdxk//:k=v" },
-        { "z*x?c*x*:*", "z/a/x/c/x//:k=v" },
-        { "?/*/?:*", "d/xx/q//:k=v" },
-        { "**//*:*", "a//b//jmx.rmi:k=v"},
-        { "**//*:*", "a//b//jmx.rmi//:k=v"},
-        { "*//*:*", "wombat//:type=Wombat" },
-        { "**//*:*", "jmx.rmi//:k=v"},
-
     };
 
     private static final String negativeTests[][] = {
@@ -186,33 +114,6 @@
         { "d:k1=\"a?b\",k2=\"c*d\"", "d:k1=\"ab\",k2=\"cd\"" },
         { "d:k1=\"a?b\",k2=\"c*d\",*", "d:k1=\"ab\",k2=\"cd\",k3=\"v3\"" },
         { "d:*,k1=\"a?b\",k2=\"c*d\"", "d:k1=\"ab\",k2=\"cd\",k3=\"v3\"" },
-
-        // with namespaces
-
-        { "z*x?x*:*", "zaxcx//blougs:k=v" },
-        { "*x?f??rata:*", "d/xxf/qxbf//rata:k=v" },
-        { "z*x?c*x*b*:*", "z/a/x/c/x//b//:k=v" },
-
-        { "*:*", "d/c/v//x/vgh/:k=v" },
-        { "z*x??z*x:*", "zaxcx//zaxcxcx:k=v" },
-        { "?/*/?:*", "//d/xx/q//:k=v" },
-        { "z*/?*/?:*", "z/x/x/z//z/a/x/c/x//:k=v" },
-        { "*x?/?blur?g*:*", "dbdbdxk//blurhgblurgh/x/:k=v" },
-        { "z*x??x/???:*", "zaxcxccx///.:k=v" },
-        { "*x?f?/?:*", "d/xxf/qxbf///:k=v" },
-        { "z*x?c*x/?*z????*g:*", "z/a/x/c/x//gloubs/././/zargh//g:k=v" },
-
-        // recursive namespace meta-wildcard
-        {"**//D:k=v", "D:k=v"},
-        {"b//**//D:k=v", "a//b//c//D:k=v"},
-        {"a//**//D:k=v", "a//D:k=v"},
-        {"a//**//d//D:k=v", "a//b//c//d//e//D:k=v"},
-        {"a//**//d//D:k=v", "a//b//c//D:k=v"},
-        {"a//**//d//D:k=v", "a//b//c//d//d//e//D:k=v"},
-        {"a//**//d//**//e//D:k=v", "a//a//b//c//d//e//D:k=v"},
-        {"a//**//d//**//e//D:k=v", "a//a//b//c//e//D:k=v"},
-        { "**//*:*", "jmx.rmi:k=v"},
-
     };
 
     private static int runPositiveTests() {
@@ -228,8 +129,6 @@
                 if (result == false) {
                     error++;
                     System.out.println("Test failed!");
-                    throw new Error("test failed for "+
-                            "\"" + on1 + "\".apply(\"" + on2 + "\")");
                 } else {
                     System.out.println("Test passed!");
                 }
@@ -269,85 +168,10 @@
         return error;
     }
 
-    private static int runRepositoryPositiveTests() {
-        int error = 0;
-        for (int i = 0; i < positiveTests.length; i++) {
-            try {
-                ObjectName on1 = ObjectName.getInstance(positiveTests[i][0]);
-                ObjectName on2 = ObjectName.getInstance(positiveTests[i][1]);
-                if (on1.isPropertyPattern()) {
-                    if (!on1.getKeyPropertyListString().equals("")) continue;
-                } else if (!on1.getCanonicalKeyPropertyListString()
-                            .equals(on2.getCanonicalKeyPropertyListString())) {
-                    continue;
-                }
-                System.out.println("Repository Positive Match Test ---------------");
-                final String dom1 = on1.getDomain();
-                final String dom2 = on2.getDomain();
-                System.out.println("Util.wildpathmatch(\"" + dom2 + "\",\"" + dom1 + "\")");
-                boolean result =
-                        Util.wildpathmatch(dom2,dom1);
-                System.out.println("Result = " + result);
-                if (result == false) {
-                    error++;
-                    System.out.println("Test failed!");
-                } else {
-                    System.out.println("Test passed!");
-                }
-            } catch (Exception e) {
-                error++;
-                System.out.println("Got Unexpected Exception = " + e.toString());
-                System.out.println("Test failed!");
-            }
-            System.out.println("----------------------------------------------");
-        }
-        return error;
-    }
-
-    private static int runRepositoryNegativeTests() {
-        int error = 0;
-        for (int i = 0; i < negativeTests.length; i++) {
-            try {
-                ObjectName on1 = ObjectName.getInstance(negativeTests[i][0]);
-                ObjectName on2 = ObjectName.getInstance(negativeTests[i][1]);
-                if (on1.isPropertyPattern()) {
-                    if (!on1.getKeyPropertyListString().equals("")) continue;
-                } else if (!on1.getCanonicalKeyPropertyListString()
-                            .equals(on2.getCanonicalKeyPropertyListString())) {
-                    continue;
-                }
-                System.out.println("Repository Negative Match Test ---------------");
-                final String dom1 = on1.getDomain();
-                final String dom2 = on2.getDomain();
-                System.out.println("Util.wildpathmatch(\"" + dom2 + "\",\"" + dom1 + "\")");
-                boolean result =
-                        Util.wildpathmatch(dom2,dom1);
-                System.out.println("Result = " + result);
-                if (result == true) {
-                    error++;
-                    System.out.println("Test failed!");
-                } else {
-                    System.out.println("Test passed!");
-                }
-            } catch (Exception e) {
-                error++;
-                System.out.println("Got Unexpected Exception = " + e.toString());
-                System.out.println("Test failed!");
-            }
-            System.out.println("----------------------------------------------");
-        }
-        return error;
-    }
-
     public static void main(String[] args) throws Exception {
 
-
         int error = 0;
 
-        if (!(new ObjectName("z*x*:*").apply(new ObjectName("zaxcx//:k=v"))))
-                throw new Exception();
-
-
         // Check null values
         //
         System.out.println("----------------------------------------------");
@@ -429,10 +253,6 @@
 
         error += runPositiveTests();
         error += runNegativeTests();
-        System.out.println("----------------------------------------------");
-        error += runRepositoryPositiveTests();
-        System.out.println("----------------------------------------------");
-        error += runRepositoryNegativeTests();
 
         if (error > 0) {
             final String msg = "Test FAILED! Got " + error + " error(s)";
--- a/test/javax/management/ObjectName/ValueOfTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,175 +0,0 @@
-/*
- * 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 6734813
- * @summary Test the ObjectName.valueOf methods
- * @author Eamonn McManus
- */
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Hashtable;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-public class ValueOfTest {
-    public static void main(String[] args) throws Exception {
-        // Calls that should work
-        testPositive("d:foo=bar,baz=buh");
-        testPositive("foo", "bar", "baz");
-        Hashtable<String, String> h = new Hashtable<String, String>();
-        h.put("foo", "bar");
-        h.put("baz", "buh");
-        testPositive("domain", h);
-
-        // Calls that should not work
-        testNegative("d");
-        testNegative("d:");
-        testNegative("d::foo=bar");
-        testNegative("d:", "foo", "bar");
-        testNegative("d", "foo=", "bar");
-        testNegative("d:", h);
-        testNegative("d", new Hashtable<String, String>());
-    }
-
-    private static void testPositive(Object... args) throws Exception {
-        Method valueOf = valueOfMethod(args);
-        Method getInstance = getInstanceMethod(args);
-        Constructor<?> constructor = constructor(args);
-
-        Object valueOfValue = valueOf.invoke(null, args);
-        Object getInstanceValue = getInstance.invoke(null, args);
-        Object constructorValue = constructor.newInstance(args);
-
-        String argString =
-                Arrays.toString(args).replace('[', '(').replace(']', ')');
-
-        if (!valueOfValue.equals(getInstanceValue)) {
-            throw new Exception(
-                    "valueOf" + argString + " differs from getInstance" +
-                    argString);
-        }
-
-        if (!valueOfValue.equals(constructorValue)) {
-            throw new Exception(
-                    "valueOf" + argString + " differs from new ObjectName " +
-                    argString);
-        }
-
-        System.out.println("OK: valueOf" + argString);
-    }
-
-    private static void testNegative(Object... args) throws Exception {
-        Method valueOf = valueOfMethod(args);
-        Method getInstance = getInstanceMethod(args);
-
-        String argString =
-                Arrays.toString(args).replace('[', '(').replace(']', ')');
-
-        final Throwable valueOfException;
-        try {
-            valueOf.invoke(null, args);
-            throw new Exception("valueOf" + argString + " did not fail but should");
-        } catch (InvocationTargetException e) {
-            valueOfException = e.getCause();
-        }
-        if (!(valueOfException instanceof IllegalArgumentException)) {
-            throw new Exception(
-                    "valueOf" + argString + " threw " +
-                    valueOfException.getClass().getName() + " instead of " +
-                    "IllegalArgumentException", valueOfException);
-        }
-
-        final Throwable valueOfCause = valueOfException.getCause();
-        if (!(valueOfCause instanceof MalformedObjectNameException)) {
-            throw new Exception(
-                    "valueOf" + argString + " threw exception with wrong " +
-                    "type of cause", valueOfCause);
-        }
-
-        if (!valueOfException.getMessage().equals(valueOfCause.getMessage())) {
-            // The IllegalArgumentException should have the same message as
-            // the MalformedObjectNameException it wraps.
-            // This isn't specified but is desirable.
-            throw new Exception(
-                    "valueOf" + argString + ": message in wrapping " +
-                    "IllegalArgumentException (" + valueOfException.getMessage() +
-                    ") differs from message in wrapped " +
-                    "MalformedObjectNameException (" + valueOfCause.getMessage() +
-                    ")");
-        }
-
-        final Throwable getInstanceException;
-        try {
-            getInstance.invoke(null, args);
-            throw new Exception("getInstance" + argString + " did not fail but should");
-        } catch (InvocationTargetException e) {
-            getInstanceException = e.getCause();
-        }
-        if (!(getInstanceException instanceof MalformedObjectNameException)) {
-            throw new Exception(
-                    "getInstance" + argString + " threw wrong exception",
-                    getInstanceException);
-        }
-
-        if (!valueOfException.getMessage().equals(getInstanceException.getMessage())) {
-            // Again this is not specified.
-            throw new Exception(
-                    "Exception message from valueOf" + argString + " (" +
-                    valueOfException.getMessage() + ") differs from message " +
-                    "from getInstance" + argString + " (" +
-                    getInstanceException.getMessage() + ")");
-        }
-
-        System.out.println("OK (correct exception): valueOf" + argString);
-    }
-
-    private static Method valueOfMethod(Object[] args) throws Exception {
-        return method("valueOf", args);
-    }
-
-    private static Method getInstanceMethod(Object[] args) throws Exception {
-        return method("getInstance", args);
-    }
-
-    private static Method method(String name, Object[] args) throws Exception {
-        Class<?>[] argTypes = argTypes(args);
-        return ObjectName.class.getMethod(name, argTypes);
-    }
-
-    private static Constructor<?> constructor(Object[] args) throws Exception {
-        Class<?>[] argTypes = argTypes(args);
-        return ObjectName.class.getConstructor(argTypes);
-    }
-
-    private static Class<?>[] argTypes(Object[] args) {
-        Class<?>[] argTypes = new Class<?>[args.length];
-        for (int i = 0; i < args.length; i++)
-            argTypes[i] = args[i].getClass();
-        return argTypes;
-    }
-}
--- a/test/javax/management/context/ContextForwarderTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-/*
- * 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 5072267
- * @summary Test that a context forwarder can be created and then installed.
- * @author Eamonn McManus
- */
-
-/* The specific thing we're testing for is that the forwarder can be created
- * with a null "next", and then installed with a real "next".  An earlier
- * defect meant that in this case the simulated jmx.context// namespace had a
- * null handler that never changed.
- */
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.management.ClientContext;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.MBeanServerForwarder;
-
-public class ContextForwarderTest {
-    private static String failure;
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
-        Map<String, String> env = new HashMap<String, String>();
-        env.put(JMXConnectorServer.CONTEXT_FORWARDER, "false");
-        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
-                url, env, mbs);
-        MBeanServerForwarder sysMBSF = cs.getSystemMBeanServerForwarder();
-        MBeanServerForwarder mbsf = ClientContext.newContextForwarder(mbs, sysMBSF);
-        sysMBSF.setMBeanServer(mbsf);
-
-        int localCount = mbs.getMBeanCount();
-
-        cs.start();
-        try {
-            JMXConnector cc = JMXConnectorFactory.connect(cs.getAddress());
-            MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-            mbsc = ClientContext.withContext(mbsc, "foo", "bar");
-            int contextCount = mbsc.getMBeanCount();
-            if (localCount + 1 != contextCount) {
-                fail("Local MBean count %d, context MBean count %d",
-                        localCount, contextCount);
-            }
-            Set<ObjectName> localNames =
-                    new TreeSet<ObjectName>(mbs.queryNames(null, null));
-            ObjectName contextNamespaceObjectName =
-                    new ObjectName(ClientContext.NAMESPACE + "//:type=JMXNamespace");
-            if (!localNames.add(contextNamespaceObjectName))
-                fail("Local names already contained context namespace handler");
-            Set<ObjectName> contextNames = mbsc.queryNames(null, null);
-            if (!localNames.equals(contextNames)) {
-                fail("Name set differs locally and in context: " +
-                        "local: %s; context: %s", localNames, contextNames);
-            }
-        } finally {
-            cs.stop();
-        }
-        if (failure != null)
-            throw new Exception("TEST FAILED: " + failure);
-        else
-            System.out.println("TEST PASSED");
-    }
-
-    private static void fail(String msg, Object... params) {
-        failure = String.format(msg, params);
-        System.out.println("FAIL: " + failure);
-    }
-}
--- a/test/javax/management/context/ContextTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,534 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 ContextTest
- * @bug 5072267
- * @summary Test client contexts.
- * @author Eamonn McManus
- * TODO: Try registering with a null name replaced by preRegister (for example
- * from the MLet class) and see if it now works.
- */
-
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.Callable;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.ClientContext;
-import javax.management.DynamicMBean;
-import javax.management.JMX;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.loading.MLet;
-import javax.management.namespace.JMXNamespace;
-
-import javax.management.remote.MBeanServerForwarder;
-import static java.util.Collections.emptyMap;
-import static java.util.Collections.singletonMap;
-
-public class ContextTest {
-    private static String failure;
-    private static final Map<String, String> emptyContext = emptyMap();
-
-    public static interface ShowContextMBean {
-        public Map<String, String> getContext();
-        public Map<String, String> getCreationContext();
-        public Set<String> getCalledOps();
-        public String getThing();
-        public void setThing(String x);
-        public int add(int x, int y);
-    }
-
-    public static class ShowContext
-            extends NotificationBroadcasterSupport
-            implements ShowContextMBean, MBeanRegistration {
-        private final Map<String, String> creationContext;
-        private final Set<String> calledOps = new HashSet<String>();
-
-        public ShowContext() {
-            creationContext = getContext();
-        }
-
-        public Map<String, String> getContext() {
-            return ClientContext.getContext();
-        }
-
-        public Map<String, String> getCreationContext() {
-            return creationContext;
-        }
-
-        public Set<String> getCalledOps() {
-            return calledOps;
-        }
-
-        public String getThing() {
-            return "x";
-        }
-
-        public void setThing(String x) {
-        }
-
-        public int add(int x, int y) {
-            return x + y;
-        }
-
-        public ObjectName preRegister(MBeanServer server, ObjectName name) {
-            assertEquals("preRegister context", creationContext, getContext());
-            calledOps.add("preRegister");
-            return name;
-        }
-
-        public void postRegister(Boolean registrationDone) {
-            assertEquals("postRegister context", creationContext, getContext());
-            calledOps.add("postRegister");
-        }
-
-        // The condition checked here is not guaranteed universally true,
-        // but is true every time we unregister an instance of this MBean
-        // in this test.
-        public void preDeregister() throws Exception {
-            assertEquals("preDeregister context", creationContext, getContext());
-        }
-
-        public void postDeregister() {
-            assertEquals("postDeregister context", creationContext, getContext());
-        }
-
-        // Same remark as for preDeregister
-        @Override
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            calledOps.add("getNotificationInfo");
-            return super.getNotificationInfo();
-        }
-
-        @Override
-        public void addNotificationListener(
-                NotificationListener listener, NotificationFilter filter, Object handback) {
-            calledOps.add("addNotificationListener");
-            super.addNotificationListener(listener, filter, handback);
-        }
-
-        @Override
-        public void removeNotificationListener(
-                NotificationListener listener)
-        throws ListenerNotFoundException {
-            calledOps.add("removeNL1");
-            super.removeNotificationListener(listener);
-        }
-
-        @Override
-        public void removeNotificationListener(
-                NotificationListener listener, NotificationFilter filter, Object handback)
-        throws ListenerNotFoundException {
-            calledOps.add("removeNL3");
-            super.removeNotificationListener(listener, filter, handback);
-        }
-    }
-
-    private static class LogRecord {
-        final String op;
-        final Object[] params;
-        final Map<String, String> context;
-        LogRecord(String op, Object[] params, Map<String, String> context) {
-            this.op = op;
-            this.params = params;
-            this.context = context;
-        }
-
-        @Override
-        public String toString() {
-            return op + Arrays.deepToString(params) + " " + context;
-        }
-    }
-
-    /*
-     * InvocationHandler that forwards all methods to a contained object
-     * but also records each forwarded method.  This allows us to check
-     * that the appropriate methods were called with the appropriate
-     * parameters.  It's similar to what's typically available in
-     * Mock Object frameworks.
-     */
-    private static class LogIH implements InvocationHandler {
-        private final Object wrapped;
-        Queue<LogRecord> log = new LinkedList<LogRecord>();
-
-        LogIH(Object wrapped) {
-            this.wrapped = wrapped;
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-        throws Throwable {
-            if (method.getDeclaringClass() != Object.class) {
-                LogRecord lr =
-                    new LogRecord(
-                        method.getName(), args, ClientContext.getContext());
-                log.add(lr);
-            }
-            try {
-                return method.invoke(wrapped, args);
-            } catch (InvocationTargetException e) {
-                throw e.getCause();
-            }
-        }
-    }
-
-    private static <T> T newSnoop(Class<T> wrappedClass, LogIH logIH) {
-        return wrappedClass.cast(Proxy.newProxyInstance(
-                wrappedClass.getClassLoader(),
-                new Class<?>[] {wrappedClass},
-                logIH));
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        System.out.println(mbs.queryNames(null, null));
-        ObjectName name = new ObjectName("a:b=c");
-        mbs.registerMBean(new ShowContext(), name);
-        final ShowContextMBean show =
-                JMX.newMBeanProxy(mbs, name, ShowContextMBean.class);
-
-        // Test local setting and getting within the MBeanServer
-
-        assertEquals("initial context", emptyContext, show.getContext());
-        ClientContext.doWithContext(singletonMap("foo", "bar"), new Callable<Void>() {
-            public Void call() {
-                assertEquals("context in doWithContext",
-                        singletonMap("foo", "bar"), show.getContext());
-                return null;
-            }
-        });
-        assertEquals("initial context after doWithContext",
-                emptyContext, show.getContext());
-        String got = ClientContext.doWithContext(
-                singletonMap("foo", "baz"), new Callable<String>() {
-            public String call() {
-                return ClientContext.getContext().get("foo");
-            }
-        });
-        assertEquals("value extracted from context", "baz", got);
-
-        Map<String, String> combined = ClientContext.doWithContext(
-                singletonMap("foo", "baz"), new Callable<Map<String, String>>() {
-            public Map<String, String> call() throws Exception {
-                return ClientContext.doWithContext(
-                        singletonMap("fred", "jim"),
-                        new Callable<Map<String, String>>() {
-                    public Map<String, String> call() {
-                        return ClientContext.getContext();
-                    }
-                });
-            }
-        });
-        assertEquals("nested doWithContext context",
-                singletonMap("fred", "jim"), combined);
-
-        final String ugh = "a!\u00c9//*=:\"% ";
-        ClientContext.doWithContext(singletonMap(ugh, ugh), new Callable<Void>() {
-            public Void call() {
-                assertEquals("context with tricky encoding",
-                        singletonMap(ugh, ugh), show.getContext());
-                return null;
-            }
-        });
-        Map<String, String> ughMap = new TreeMap<String, String>();
-        ughMap.put(ugh, ugh);
-        ughMap.put("fred", "jim");
-        // Since this is a TreeMap and "fred" is greater than ugh (which begins
-        // with "a"), we will see the encoding of ugh first in the output string.
-        String encoded = ClientContext.encode(ughMap);
-        String expectedUghCoding = "a%21%C3%89%2F%2F%2A%3D%3A%22%25+";
-        String expectedUghMapCoding =
-                ClientContext.NAMESPACE + "//" + expectedUghCoding + "=" +
-                expectedUghCoding + ";fred=jim";
-        assertEquals("hairy context encoded as string",
-                expectedUghMapCoding, encoded);
-
-        // Wrap the MBeanServer with a context MBSF so we can test withContext.
-        // Also check the simulated namespace directly.
-
-        LogIH mbsIH = new LogIH(mbs);
-        MBeanServer snoopMBS = newSnoop(MBeanServer.class, mbsIH);
-        MBeanServerForwarder ctxMBS =
-                ClientContext.newContextForwarder(snoopMBS, null);
-
-        // The MBSF returned by ClientContext is actually a compound of two
-        // forwarders, but that is supposed to be hidden by changing the
-        // behaviour of get/setMBeanServer.  Check that it is indeed so.
-        assertEquals("next MBS of context forwarder",
-                snoopMBS, ctxMBS.getMBeanServer());
-        // If the above assertion fails you may get a confusing message
-        // because the toString() of the two objects is likely to be the same
-        // so it will look as if they should be equal.
-        ctxMBS.setMBeanServer(null);
-        assertEquals("next MBS of context forwarder after setting it null",
-                null, ctxMBS.getMBeanServer());
-        ctxMBS.setMBeanServer(snoopMBS);
-
-        // The MBSF should look the same as the original MBeanServer except
-        // that it has the JMXNamespace for the simulated namespace.
-
-        Set<ObjectName> origNames = mbs.queryNames(null, null);
-        Set<ObjectName> mbsfNames = ctxMBS.queryNames(null, null);
-        assertEquals("number of MBeans returned by queryNames within forwarder",
-                origNames.size() + 1, mbsfNames.size());
-        assertEquals("MBeanCount within forwarder",
-                mbsfNames.size(), ctxMBS.getMBeanCount());
-        assertCalled(mbsIH, "queryNames", emptyContext);
-        assertCalled(mbsIH, "getMBeanCount", emptyContext);
-
-        ObjectName ctxNamespaceName = new ObjectName(
-                ClientContext.NAMESPACE + "//:" + JMXNamespace.TYPE_ASSIGNMENT);
-        origNames.add(ctxNamespaceName);
-        assertEquals("MBeans within forwarder", origNames, mbsfNames);
-        Set<String> domains = new HashSet<String>(Arrays.asList(ctxMBS.getDomains()));
-        assertEquals("domains include context namespace MBean",
-                true, domains.contains(ClientContext.NAMESPACE + "//"));
-        assertCalled(mbsIH, "getDomains", emptyContext);
-
-        // Now test ClientContext.withContext.
-
-        MBeanServer ughMBS = ClientContext.withContext(ctxMBS, ugh, ugh);
-
-        ShowContextMBean ughshow =
-                JMX.newMBeanProxy(ughMBS, name, ShowContextMBean.class);
-        Map<String, String> ughCtx = ughshow.getContext();
-        Map<String, String> ughExpect = singletonMap(ugh, ugh);
-        assertEquals("context seen by MBean accessed within namespace",
-                ughExpect, ughCtx);
-        assertCalled(mbsIH, "getAttribute", ughExpect, name, "Context");
-
-        MBeanServer cmbs = ClientContext.withContext(
-                ctxMBS, "mickey", "mouse");
-        ShowContextMBean cshow =
-                JMX.newMBeanProxy(cmbs, name, ShowContextMBean.class);
-        assertEquals("context seen by MBean accessed within namespace",
-                singletonMap("mickey", "mouse"), cshow.getContext());
-
-        MBeanServer ccmbs = ClientContext.withContext(
-                cmbs, "donald", "duck");
-        ShowContextMBean ccshow =
-                JMX.newMBeanProxy(ccmbs, name, ShowContextMBean.class);
-        Map<String, String> disney = new HashMap<String, String>();
-        disney.put("mickey", "mouse");
-        disney.put("donald", "duck");
-        assertEquals("context seen by MBean in nested namespace",
-                disney, ccshow.getContext());
-
-        // Test that all MBS ops produce reasonable results
-
-        ObjectName logger = new ObjectName("a:type=Logger");
-        DynamicMBean showMBean =
-                new StandardMBean(new ShowContext(), ShowContextMBean.class);
-        LogIH mbeanLogIH = new LogIH(showMBean);
-        DynamicMBean logMBean = newSnoop(DynamicMBean.class, mbeanLogIH);
-        ObjectInstance loggerOI = ccmbs.registerMBean(logMBean, logger);
-        assertEquals("ObjectName returned by createMBean",
-                logger, loggerOI.getObjectName());
-
-        // We get an getMBeanInfo call to determine the className in the
-        // ObjectInstance to return from registerMBean.
-        assertCalled(mbeanLogIH, "getMBeanInfo", disney);
-
-        ccmbs.getAttribute(logger, "Thing");
-        assertCalled(mbeanLogIH, "getAttribute", disney);
-
-        ccmbs.getAttributes(logger, new String[] {"Thing", "Context"});
-        assertCalled(mbeanLogIH, "getAttributes", disney);
-
-        ccmbs.setAttribute(logger, new Attribute("Thing", "bar"));
-        assertCalled(mbeanLogIH, "setAttribute", disney);
-
-        ccmbs.setAttributes(logger, new AttributeList(
-                Arrays.asList(new Attribute("Thing", "baz"))));
-        assertCalled(mbeanLogIH, "setAttributes", disney);
-
-        ccmbs.getMBeanInfo(logger);
-        assertCalled(mbeanLogIH, "getMBeanInfo", disney);
-
-        Set<ObjectName> names = ccmbs.queryNames(null, null);
-        Set<ObjectName> expectedNames = new HashSet<ObjectName>(
-                Collections.singleton(MBeanServerDelegate.DELEGATE_NAME));
-        assertEquals("context namespace query includes expected names",
-                true, names.containsAll(expectedNames));
-
-        Set<ObjectName> nsNames = ccmbs.queryNames(new ObjectName("*//:*"), null);
-        Set<ObjectName> expectedNsNames = new HashSet<ObjectName>(
-                Arrays.asList(
-                new ObjectName(ClientContext.NAMESPACE +
-                ObjectName.NAMESPACE_SEPARATOR + ":" +
-                JMXNamespace.TYPE_ASSIGNMENT)));
-        assertEquals("context namespace query includes namespace MBean",
-                true, nsNames.containsAll(expectedNsNames));
-
-
-
-        Set<ObjectInstance> insts = ccmbs.queryMBeans(
-                MBeanServerDelegate.DELEGATE_NAME, null);
-        assertEquals("size of set from MBeanServerDelegate query", 1, insts.size());
-        assertEquals("ObjectName from MBeanServerDelegate query",
-                MBeanServerDelegate.DELEGATE_NAME,
-                insts.iterator().next().getObjectName());
-
-        ObjectName createdName = new ObjectName("a:type=Created");
-        ObjectInstance createdOI =
-                ccmbs.createMBean(ShowContext.class.getName(), createdName);
-        assertEquals("class name from createMBean",
-                ShowContext.class.getName(), createdOI.getClassName());
-        assertEquals("ObjectName from createMBean",
-                createdName, createdOI.getObjectName());
-        assertEquals("context within createMBean",
-                disney, ccmbs.getAttribute(createdName, "CreationContext"));
-
-        NotificationListener nothingListener = new NotificationListener() {
-            public void handleNotification(Notification n, Object h) {}
-        };
-        ccmbs.addNotificationListener(createdName, nothingListener, null, null);
-        ccmbs.removeNotificationListener(createdName, nothingListener, null, null);
-        ccmbs.addNotificationListener(createdName, nothingListener, null, null);
-        ccmbs.removeNotificationListener(createdName, nothingListener);
-        Set<String> expectedOps = new HashSet<String>(Arrays.asList(
-                "preRegister", "postRegister", "addNotificationListener",
-                "removeNL1", "removeNL3", "getNotificationInfo"));
-        assertEquals("operations called on MBean",
-                expectedOps, ccmbs.getAttribute(createdName, "CalledOps"));
-
-        assertEquals("ClassLoader for MBean",
-                ShowContext.class.getClassLoader(),
-                ccmbs.getClassLoaderFor(createdName));
-
-        assertEquals("isRegistered", true, ccmbs.isRegistered(createdName));
-        assertEquals("isInstanceOf", true, ccmbs.isInstanceOf(createdName,
-                ShowContext.class.getName()));
-        assertEquals("isInstanceOf", false, ccmbs.isInstanceOf(createdName,
-                DynamicMBean.class.getName()));
-        ccmbs.unregisterMBean(createdName);
-        assertEquals("isRegistered after unregister",
-                false, ccmbs.isRegistered(createdName));
-
-        MLet mlet = new MLet();
-        ObjectName defaultMLetName = new ObjectName("DefaultDomain:type=MLet");
-
-        ccmbs.registerMBean(mlet, defaultMLetName);
-
-        assertEquals("getClassLoader", mlet, ccmbs.getClassLoader(defaultMLetName));
-
-        assertEquals("number of MBean operations", 0, mbeanLogIH.log.size());
-
-        // Test that contexts still work when we can't combine two encoded contexts.
-        // Here, we wrap cmbs (mickey=mouse) so that ccmbs2 (donald=duck) cannot
-        // see that it already contains a context and therefore cannot combine
-        // into mickey=mouse;donald=duck.  We don't actually use the snoop
-        // capabilities of the returned object -- we just want an opaque
-        // MBeanServer wrapper
-        MBeanServer cmbs2 = newSnoop(MBeanServer.class, new LogIH(cmbs));
-        MBeanServer ccmbs2 = ClientContext.withContext(cmbs2, "donald", "duck");
-        assertEquals("context when combination is impossible",
-                disney, ccmbs2.getAttribute(name, "Context"));
-
-        // Test failure cases of ClientContext.encode
-        final List<Map<String, String>> badEncodeArgs =
-                Arrays.asList(
-                    null,
-                    Collections.<String,String>singletonMap(null, "foo"),
-                    Collections.<String,String>singletonMap("foo", null));
-        for (Map<String, String> bad : badEncodeArgs) {
-            try {
-                String oops = ClientContext.encode(bad);
-                failed("ClientContext.encode(" + bad + ") should have failed: "
-                        + oops);
-            } catch (Exception e) {
-                assertEquals("Exception for ClientContext.encode(" + bad + ")",
-                        IllegalArgumentException.class, e.getClass());
-            }
-        }
-
-        // ADD NEW TESTS HERE ^^^
-
-        if (failure != null)
-            throw new Exception(failure);
-    }
-
-    private static void assertEquals(String what, Object x, Object y) {
-        if (!equal(x, y))
-            failed(what + ": expected " + string(x) + "; got " + string(y));
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        if (x.getClass().isArray())
-            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
-        return x.equals(y);
-    }
-
-    private static String string(Object x) {
-        String s = Arrays.deepToString(new Object[] {x});
-        return s.substring(1, s.length() - 1);
-    }
-
-    private static void assertCalled(
-            LogIH logIH, String op, Map<String, String> expectedContext) {
-        assertCalled(logIH, op, expectedContext, (Object[]) null);
-    }
-
-    private static void assertCalled(
-            LogIH logIH, String op, Map<String, String> expectedContext,
-            Object... params) {
-        LogRecord lr = logIH.log.remove();
-        assertEquals("called operation", op, lr.op);
-        if (params != null)
-            assertEquals("operation parameters", params, lr.params);
-        assertEquals("operation context", expectedContext, lr.context);
-    }
-
-    private static void failed(String why) {
-        failure = why;
-        new Throwable("FAILED: " + why).printStackTrace(System.out);
-    }
-}
--- a/test/javax/management/context/LocaleAwareBroadcasterTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,328 +0,0 @@
-/*
- * 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 5072267
- * @summary Test that an MBean can handle localized Notification messages.
- * @author Eamonn McManus
- */
-
-import java.util.Collections;
-import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.TimeUnit;
-import javax.management.ClientContext;
-import javax.management.JMX;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.SendNotification;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class LocaleAwareBroadcasterTest {
-    static final ObjectName mbeanName = ObjectName.valueOf("d:type=LocaleAware");
-
-    static final String
-            messageKey = "broken.window",
-            defaultMessage = "broken window",
-            frenchMessage = "fen\u00eatre bris\u00e9e",
-            irishMessage = "fuinneog briste";
-
-    public static class Bundle extends ListResourceBundle {
-        @Override
-        protected Object[][] getContents() {
-            return new Object[][] {
-                {messageKey, defaultMessage},
-            };
-        }
-    }
-
-    public static class Bundle_fr extends ListResourceBundle {
-        @Override
-        protected Object[][] getContents() {
-            return new Object[][] {
-                {messageKey, frenchMessage},
-            };
-        }
-    }
-
-    public static class Bundle_ga extends ListResourceBundle {
-        @Override
-        protected Object[][] getContents() {
-            return new Object[][] {
-                {messageKey, irishMessage},
-            };
-        }
-    }
-
-    static volatile String failure;
-
-    public static interface LocaleAwareMBean {
-        public void sendNotification(Notification n);
-    }
-
-    public static class LocaleAware
-            implements LocaleAwareMBean, NotificationEmitter, SendNotification {
-
-        private final ConcurrentMap<Locale, NotificationBroadcasterSupport>
-                localeToEmitter = newConcurrentMap();
-
-        public void sendNotification(Notification n) {
-            for (Map.Entry<Locale, NotificationBroadcasterSupport> entry :
-                    localeToEmitter.entrySet()) {
-                Notification localizedNotif =
-                        localizeNotification(n, entry.getKey());
-                entry.getValue().sendNotification(localizedNotif);
-            }
-        }
-
-        public void addNotificationListener(
-                NotificationListener listener,
-                NotificationFilter filter,
-                Object handback)
-                throws IllegalArgumentException {
-            Locale locale = ClientContext.getLocale();
-            NotificationBroadcasterSupport broadcaster;
-            broadcaster = localeToEmitter.get(locale);
-            if (broadcaster == null) {
-                broadcaster = new NotificationBroadcasterSupport();
-                NotificationBroadcasterSupport old =
-                        localeToEmitter.putIfAbsent(locale, broadcaster);
-                if (old != null)
-                    broadcaster = old;
-            }
-            broadcaster.addNotificationListener(listener, filter, handback);
-        }
-
-        public void removeNotificationListener(NotificationListener listener)
-                throws ListenerNotFoundException {
-            Locale locale = ClientContext.getLocale();
-            NotificationBroadcasterSupport broadcaster =
-                    localeToEmitter.get(locale);
-            if (broadcaster == null)
-                throw new ListenerNotFoundException();
-            broadcaster.removeNotificationListener(listener);
-        }
-
-        public void removeNotificationListener(
-                NotificationListener listener,
-                NotificationFilter filter,
-                Object handback)
-                throws ListenerNotFoundException {
-            Locale locale = ClientContext.getLocale();
-            NotificationBroadcasterSupport broadcaster =
-                    localeToEmitter.get(locale);
-            if (broadcaster == null)
-                throw new ListenerNotFoundException();
-            broadcaster.removeNotificationListener(listener, filter, handback);
-        }
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            return new MBeanNotificationInfo[0];
-        }
-    }
-
-    // Localize notif using the convention that the message looks like
-    // [resourcebundlename:resourcekey]defaultmessage
-    // for example [foo.bar.Resources:unknown.problem]
-    static Notification localizeNotification(Notification n, Locale locale) {
-        String msg = n.getMessage();
-        if (!msg.startsWith("["))
-            return n;
-        int close = msg.indexOf(']');
-        if (close < 0)
-            throw new IllegalArgumentException("Bad notification message: " + msg);
-        int colon = msg.indexOf(':');
-        if (colon < 0 || colon > close)
-            throw new IllegalArgumentException("Bad notification message: " + msg);
-        String bundleName = msg.substring(1, colon);
-        String key = msg.substring(colon + 1, close);
-        ClassLoader loader = LocaleAwareBroadcasterTest.class.getClassLoader();
-        ResourceBundle bundle =
-                ResourceBundle.getBundle(bundleName, locale, loader);
-        try {
-            msg = bundle.getString(key);
-        } catch (MissingResourceException e) {
-            msg = msg.substring(close + 1);
-        }
-        n = (Notification) n.clone();
-        n.setMessage(msg);
-        return n;
-    }
-
-    public static void main(String[] args) throws Exception {
-        Locale.setDefault(new Locale("en"));
-        testLocal();
-        testRemote();
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    static interface AddListenerInLocale {
-        public void addListenerInLocale(
-                MBeanServerConnection mbsc,
-                NotificationListener listener,
-                Locale locale) throws Exception;
-    }
-
-    private static void testLocal() throws Exception {
-        System.out.println("Test local MBeanServer using doWithContext");
-        MBeanServer mbs = makeMBS();
-        AddListenerInLocale addListener = new AddListenerInLocale() {
-            public void addListenerInLocale(
-                    final MBeanServerConnection mbsc,
-                    final NotificationListener listener,
-                    Locale locale) throws Exception {
-                Map<String, String> localeContext = Collections.singletonMap(
-                        ClientContext.LOCALE_KEY, locale.toString());
-                ClientContext.doWithContext(
-                        localeContext, new Callable<Void>() {
-                    public Void call() throws Exception {
-                        mbsc.addNotificationListener(
-                                mbeanName, listener, null, null);
-                        return null;
-                    }
-                });
-            }
-        };
-        test(mbs, addListener);
-    }
-
-    private static void testRemote() throws Exception {
-        System.out.println("Test remote MBeanServer using withLocale");
-        MBeanServer mbs = makeMBS();
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
-        JMXConnectorServer cs =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
-        cs.start();
-        JMXServiceURL addr = cs.getAddress();
-        JMXConnector cc = JMXConnectorFactory.connect(addr);
-        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-        AddListenerInLocale addListenerInLocale = new AddListenerInLocale() {
-            public void addListenerInLocale(
-                    MBeanServerConnection mbsc,
-                    NotificationListener listener,
-                    Locale locale) throws Exception {
-                mbsc = ClientContext.withLocale(mbsc, locale);
-                mbsc.addNotificationListener(mbeanName, listener, null, null);
-            }
-        };
-        try {
-            test(mbsc, addListenerInLocale);
-        } finally {
-            try {
-                cc.close();
-            } catch (Exception e) {}
-            cs.stop();
-        }
-    }
-
-    static class QueueListener implements NotificationListener {
-        final BlockingQueue<Notification> queue =
-                new ArrayBlockingQueue<Notification>(10);
-
-        public void handleNotification(Notification notification,
-                                       Object handback) {
-            queue.add(notification);
-        }
-    }
-
-    private static void test(
-            MBeanServerConnection mbsc, AddListenerInLocale addListener)
-            throws Exception {
-        QueueListener defaultListener = new QueueListener();
-        QueueListener frenchListener = new QueueListener();
-        QueueListener irishListener = new QueueListener();
-        mbsc.addNotificationListener(mbeanName, defaultListener, null, null);
-        addListener.addListenerInLocale(mbsc, frenchListener, new Locale("fr"));
-        addListener.addListenerInLocale(mbsc, irishListener, new Locale("ga"));
-
-        LocaleAwareMBean proxy =
-                JMX.newMBeanProxy(mbsc, mbeanName, LocaleAwareMBean.class);
-        String notifMsg = "[" + Bundle.class.getName() + ":" + messageKey + "]" +
-                "broken window (default message that should never be seen)";
-        Notification notif = new Notification(
-                "notif.type", mbeanName, 0L, notifMsg);
-        proxy.sendNotification(notif);
-
-        final Object[][] expected = {
-            {defaultListener, defaultMessage},
-            {frenchListener, frenchMessage},
-            {irishListener, irishMessage},
-        };
-        for (Object[] exp : expected) {
-            QueueListener ql = (QueueListener) exp[0];
-            String msg = (String) exp[1];
-            System.out.println("Checking: " + msg);
-            Notification n = ql.queue.poll(1, TimeUnit.SECONDS);
-            if (n == null)
-                fail("Did not receive expected notif: " + msg);
-            if (!n.getMessage().equals(msg)) {
-                fail("Received notif with wrong message: got " +
-                        n.getMessage() + ", expected " + msg);
-            }
-            n = ql.queue.poll(2, TimeUnit.MILLISECONDS);
-            if (n != null)
-                fail("Received unexpected extra notif: " + n);
-        }
-    }
-
-    private static MBeanServer makeMBS() throws Exception {
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        LocaleAware aware = new LocaleAware();
-        mbs.registerMBean(aware, mbeanName);
-        return mbs;
-    }
-
-    static <K, V> ConcurrentMap<K, V> newConcurrentMap() {
-        return new ConcurrentHashMap<K, V>();
-    }
-
-    static void fail(String why) {
-        System.out.println("FAIL: " + why);
-        failure = why;
-    }
-}
--- a/test/javax/management/context/LocaleTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 LocaleTest.java
- * @bug 5072267
- * @summary Test client locales.
- * @author Eamonn McManus
- */
-
-import java.lang.management.ManagementFactory;
-import java.util.Collections;
-import java.util.ListResourceBundle;
-import java.util.Locale;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.concurrent.Callable;
-import javax.management.ClientContext;
-import java.util.Arrays;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-public class LocaleTest {
-    private static String failure;
-
-    public static void main(String[] args) throws Exception {
-
-        // Test the translation String -> Locale
-
-        Locale[] locales = Locale.getAvailableLocales();
-        System.out.println("Testing String->Locale for " + locales.length +
-                " locales");
-        for (Locale loc : locales) {
-            Map<String, String> ctx = Collections.singletonMap(
-                    ClientContext.LOCALE_KEY, loc.toString());
-            Locale loc2 = ClientContext.doWithContext(
-                    ctx, new Callable<Locale>() {
-                public Locale call() {
-                    return ClientContext.getLocale();
-                }
-            });
-            assertEquals(loc, loc2);
-        }
-
-        // Test that a locale-sensitive attribute works
-
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        mbs = ClientContext.newContextForwarder(mbs, null);
-        ObjectName name = new ObjectName("a:type=LocaleSensitive");
-        mbs.registerMBean(new LocaleSensitive(), name);
-        Locale.setDefault(Locale.US);
-
-        assertEquals("spectacular failure",
-                mbs.getAttribute(name, "LastProblemDescription"));
-
-        MBeanServer frmbs = ClientContext.withContext(
-                mbs, ClientContext.LOCALE_KEY, Locale.FRANCE.toString());
-        assertEquals("\u00e9chec r\u00e9tentissant",
-                frmbs.getAttribute(name, "LastProblemDescription"));
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    public static interface LocaleSensitiveMBean {
-        public String getLastProblemDescription();
-    }
-
-    public static class LocaleSensitive implements LocaleSensitiveMBean {
-        public String getLastProblemDescription() {
-            Locale loc = ClientContext.getLocale();
-            ResourceBundle rb = ResourceBundle.getBundle(
-                    MyResources.class.getName(), loc);
-            return rb.getString("spectacular");
-        }
-    }
-
-    public static class MyResources extends ListResourceBundle {
-        protected Object[][] getContents() {
-            return new Object[][] {
-                {"spectacular", "spectacular failure"},
-            };
-        }
-    }
-
-    public static class MyResources_fr extends ListResourceBundle {
-        protected Object[][] getContents() {
-            return new Object[][] {
-                {"spectacular", "\u00e9chec r\u00e9tentissant"},
-            };
-        }
-    }
-
-    private static void assertEquals(Object x, Object y) {
-        if (!equal(x, y))
-            failed("expected " + string(x) + "; got " + string(y));
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        if (x.getClass().isArray())
-            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
-        return x.equals(y);
-    }
-
-    private static String string(Object x) {
-        String s = Arrays.deepToString(new Object[] {x});
-        return s.substring(1, s.length() - 1);
-    }
-
-    private static void failed(String why) {
-        failure = why;
-        new Throwable("FAILED: " + why).printStackTrace(System.out);
-    }
-}
--- a/test/javax/management/context/LocalizableTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 LocalizableTest
- * @bug 5072267 6635499
- * @summary Test localizable MBeanInfo using LocalizableMBeanFactory.
- * @author Eamonn McManus
- */
-
-import java.lang.management.ManagementFactory;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import javax.management.ClientContext;
-import javax.management.Description;
-import javax.management.JMX;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import localizable.MBeanDescriptions_fr;
-import localizable.Whatsit;
-
-import static localizable.WhatsitMBean.*;
-
-public class LocalizableTest {
-    // If you change the order of the array elements or their number then
-    // you must also change these constants.
-    private static final int
-            MBEAN = 0, ATTR = 1, OPER = 2, PARAM = 3, CONSTR = 4,
-            CONSTR_PARAM = 5;
-    private static final String[] englishDescriptions = {
-        englishMBeanDescription, englishAttrDescription, englishOperDescription,
-        englishParamDescription, englishConstrDescription,
-        englishConstrParamDescription,
-    };
-    private static final String[] defaultDescriptions = englishDescriptions.clone();
-    static {
-        defaultDescriptions[MBEAN] = defaultMBeanDescription;
-    }
-    private static final String[] frenchDescriptions = {
-        frenchMBeanDescription, frenchAttrDescription, frenchOperDescription,
-        frenchParamDescription, frenchConstrDescription,
-        frenchConstrParamDescription,
-    };
-
-    private static String failure;
-
-    @Description(unlocalizedMBeanDescription)
-    public static interface UnlocalizedMBean {}
-    public static class Unlocalized implements UnlocalizedMBean {}
-
-    public static void main(String[] args) throws Exception {
-        ResourceBundle frenchBundle = new MBeanDescriptions_fr();
-        // The purpose of the previous line is to force that class to be compiled
-        // when the test is run so it will be available for reflection.
-        // Yes, we could do this with a @build tag.
-
-        MBeanServer plainMBS = ManagementFactory.getPlatformMBeanServer();
-        MBeanServer unlocalizedMBS =
-                ClientContext.newContextForwarder(plainMBS, null);
-        MBeanServer localizedMBS =
-                ClientContext.newLocalizeMBeanInfoForwarder(plainMBS);
-        localizedMBS = ClientContext.newContextForwarder(localizedMBS, null);
-        ObjectName name = new ObjectName("a:b=c");
-
-        Whatsit whatsit = new Whatsit();
-        Object[][] locales = {
-            {null, englishDescriptions},
-            {"en", englishDescriptions},
-            {"fr", frenchDescriptions},
-        };
-
-        for (Object[] localePair : locales) {
-            String locale = (String) localePair[0];
-            String[] localizedDescriptions = (String[]) localePair[1];
-            System.out.println("===Testing locale " + locale + "===");
-            for (boolean localized : new boolean[] {false, true}) {
-                String[] descriptions = localized ?
-                    localizedDescriptions : defaultDescriptions;
-                MBeanServer mbs = localized ? localizedMBS : unlocalizedMBS;
-                System.out.println("Testing MBean " + whatsit + " with " +
-                        "localized=" + localized);
-                mbs.registerMBean(whatsit, name);
-                System.out.println(mbs.getMBeanInfo(name));
-                try {
-                    test(mbs, name, locale, descriptions);
-                } catch (Exception e) {
-                    fail("Caught exception: " + e);
-                } finally {
-                    mbs.unregisterMBean(name);
-                }
-            }
-        }
-
-        System.out.println("===Testing unlocalizable MBean===");
-        Object mbean = new Unlocalized();
-        localizedMBS.registerMBean(mbean, name);
-        try {
-            MBeanInfo mbi = localizedMBS.getMBeanInfo(name);
-            assertEquals("MBean description", unlocalizedMBeanDescription,
-                    mbi.getDescription());
-        } finally {
-            localizedMBS.unregisterMBean(name);
-        }
-
-        System.out.println("===Testing MBeanInfo.localizeDescriptions===");
-        plainMBS.registerMBean(whatsit, name);
-        MBeanInfo mbi = plainMBS.getMBeanInfo(name);
-        Locale french = new Locale("fr");
-        mbi = mbi.localizeDescriptions(french, whatsit.getClass().getClassLoader());
-        checkDescriptions(mbi, frenchDescriptions);
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: Last failure: " + failure);
-    }
-
-    private static void test(MBeanServer mbs, ObjectName name, String locale,
-                             String[] expectedDescriptions)
-    throws Exception {
-        if (locale != null)
-            mbs = ClientContext.withLocale(mbs, new Locale(locale));
-        MBeanInfo mbi = mbs.getMBeanInfo(name);
-        checkDescriptions(mbi, expectedDescriptions);
-    }
-
-    private static void checkDescriptions(MBeanInfo mbi,
-                                          String[] expectedDescriptions) {
-        assertEquals("MBean description",
-                     expectedDescriptions[MBEAN], mbi.getDescription());
-        MBeanAttributeInfo mbai = mbi.getAttributes()[0];
-        assertEquals("Attribute description",
-                     expectedDescriptions[ATTR], mbai.getDescription());
-        MBeanOperationInfo mboi = mbi.getOperations()[0];
-        assertEquals("Operation description",
-                     expectedDescriptions[OPER], mboi.getDescription());
-        MBeanParameterInfo mbpi = mboi.getSignature()[0];
-        assertEquals("Parameter description",
-                     expectedDescriptions[PARAM], mbpi.getDescription());
-        MBeanConstructorInfo[] mbcis = mbi.getConstructors();
-        assertEquals("Number of constructors", 2, mbcis.length);
-        for (MBeanConstructorInfo mbci : mbcis) {
-            MBeanParameterInfo[] mbcpis = mbci.getSignature();
-            String constrName = mbcpis.length + "-arg constructor";
-            assertEquals(constrName + " description",
-                    expectedDescriptions[CONSTR], mbci.getDescription());
-            if (mbcpis.length > 0) {
-                assertEquals(constrName + " parameter description",
-                        expectedDescriptions[CONSTR_PARAM],
-                        mbcpis[0].getDescription());
-            }
-        }
-    }
-
-    private static void assertEquals(String what, Object expect, Object actual) {
-        if (expect.equals(actual))
-            System.out.println("...OK: " + what + " = " + expect);
-        else
-            fail(what + " should be " + expect + ", was " + actual);
-    }
-
-    private static void fail(String why) {
-        System.out.println("FAIL: " + why);
-        failure = why;
-    }
-}
--- a/test/javax/management/context/RemoteContextTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,496 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 RemoteContextTest.java
- * @bug 5072267
- * @summary Test client contexts with namespaces.
- * @author Eamonn McManus, Daniel Fuchs
- */
-
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.net.URLEncoder;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.Callable;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.ClientContext;
-import javax.management.DynamicMBean;
-import javax.management.JMX;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerDelegate;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.loading.MLet;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXRemoteNamespace;
-import javax.management.namespace.JMXNamespace;
-
-import static java.util.Collections.singletonMap;
-import javax.management.MBeanServerFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class RemoteContextTest {
-    private static String failure;
-
-    public static interface ShowContextMBean {
-        public Map<String, String> getContext();
-        public Map<String, String> getCreationContext();
-        public Set<String> getCalledOps();
-        public String getThing();
-        public void setThing(String x);
-        public int add(int x, int y);
-    }
-
-    public static class ShowContext
-            extends NotificationBroadcasterSupport
-            implements ShowContextMBean, MBeanRegistration {
-        private final Map<String, String> creationContext;
-        private final Set<String> calledOps = new HashSet<String>();
-
-        public ShowContext() {
-            creationContext = getContext();
-        }
-
-        public Map<String, String> getContext() {
-            return ClientContext.getContext();
-        }
-
-        public Map<String, String> getCreationContext() {
-            return creationContext;
-        }
-
-        public Set<String> getCalledOps() {
-            return calledOps;
-        }
-
-        public String getThing() {
-            return "x";
-        }
-
-        public void setThing(String x) {
-        }
-
-        public int add(int x, int y) {
-            return x + y;
-        }
-
-        public ObjectName preRegister(MBeanServer server, ObjectName name) {
-            assertEquals(creationContext, getContext());
-            calledOps.add("preRegister");
-            return name;
-        }
-
-        public void postRegister(Boolean registrationDone) {
-            assertEquals(creationContext, getContext());
-            calledOps.add("postRegister");
-        }
-
-        // The condition checked here is not guaranteed universally true,
-        // but is true every time we unregister an instance of this MBean
-        // in this test.
-        public void preDeregister() throws Exception {
-            assertEquals(creationContext, getContext());
-        }
-
-        public void postDeregister() {
-            assertEquals(creationContext, getContext());
-        }
-
-        // Same remark as for preDeregister
-        @Override
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            calledOps.add("getNotificationInfo");
-            return super.getNotificationInfo();
-        }
-
-        @Override
-        public void addNotificationListener(
-                NotificationListener listener, NotificationFilter filter, Object handback) {
-            calledOps.add("addNotificationListener");
-            super.addNotificationListener(listener, filter, handback);
-        }
-
-        @Override
-        public void removeNotificationListener(
-                NotificationListener listener)
-        throws ListenerNotFoundException {
-            calledOps.add("removeNL1");
-            super.removeNotificationListener(listener);
-        }
-
-        @Override
-        public void removeNotificationListener(
-                NotificationListener listener, NotificationFilter filter, Object handback)
-        throws ListenerNotFoundException {
-            calledOps.add("removeNL3");
-            super.removeNotificationListener(listener, filter, handback);
-        }
-    }
-
-    private static class LogRecord {
-        final String op;
-        final Object[] params;
-        final Map<String, String> context;
-        LogRecord(String op, Object[] params, Map<String, String> context) {
-            this.op = op;
-            this.params = params;
-            this.context = context;
-        }
-
-        @Override
-        public String toString() {
-            return op + Arrays.deepToString(params) + " " + context;
-        }
-    }
-
-    private static class LogIH implements InvocationHandler {
-        private final Object wrapped;
-        Queue<LogRecord> log = new LinkedList<LogRecord>();
-
-        LogIH(Object wrapped) {
-            this.wrapped = wrapped;
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-        throws Throwable {
-            if (method.getDeclaringClass() != Object.class) {
-                LogRecord lr =
-                    new LogRecord(
-                        method.getName(), args, ClientContext.getContext());
-                log.add(lr);
-            }
-            try {
-                return method.invoke(wrapped, args);
-            } catch (InvocationTargetException e) {
-                throw e.getCause();
-            }
-        }
-    }
-
-    private static <T> T newSnoop(Class<T> wrappedClass, LogIH logIH) {
-        return wrappedClass.cast(Proxy.newProxyInstance(
-                wrappedClass.getClassLoader(),
-                new Class<?>[] {wrappedClass},
-                logIH));
-    }
-
-    public static void main(String[] args) throws Exception {
-        final String subnamespace = "sub";
-        final ObjectName locname = new ObjectName("a:b=c");
-        final ObjectName name = JMXNamespaces.insertPath(subnamespace,locname);
-        final MBeanServer mbs = ClientContext.newContextForwarder(
-                ManagementFactory.getPlatformMBeanServer(), null);
-        final MBeanServer sub = ClientContext.newContextForwarder(
-                MBeanServerFactory.newMBeanServer(), null);
-        final JMXServiceURL anonym = new JMXServiceURL("rmi",null,0);
-        final Map<String, Object> env = Collections.emptyMap();
-        final Map<String, String> emptyContext = Collections.emptyMap();
-        final JMXConnectorServer srv =
-                JMXConnectorServerFactory.newJMXConnectorServer(anonym,env,sub);
-        sub.registerMBean(new ShowContext(), locname);
-
-        srv.start();
-
-        try {
-        JMXRemoteNamespace subns = JMXRemoteNamespace.
-            newJMXRemoteNamespace(srv.getAddress(),null);
-        mbs.registerMBean(subns, JMXNamespaces.getNamespaceObjectName("sub"));
-        mbs.invoke(JMXNamespaces.getNamespaceObjectName("sub"),
-               "connect", null,null);
-        final ShowContextMBean show =
-                JMX.newMBeanProxy(mbs, name, ShowContextMBean.class);
-
-        assertEquals(emptyContext, show.getContext());
-        ClientContext.doWithContext(singletonMap("foo", "bar"), new Callable<Void>() {
-            public Void call() {
-                assertEquals(singletonMap("foo", "bar"), show.getContext());
-                return null;
-            }
-        });
-        assertEquals(emptyContext, show.getContext());
-        String got = ClientContext.doWithContext(
-                singletonMap("foo", "baz"), new Callable<String>() {
-            public String call() {
-                return ClientContext.getContext().get("foo");
-            }
-        });
-        assertEquals("baz", got);
-
-        Map<String, String> combined = ClientContext.doWithContext(
-                singletonMap("foo", "baz"), new Callable<Map<String, String>>() {
-            public Map<String, String> call() throws Exception {
-                return ClientContext.doWithContext(
-                        singletonMap("fred", "jim"),
-                        new Callable<Map<String, String>>() {
-                    public Map<String, String> call() {
-                        return ClientContext.getContext();
-                    }
-                });
-            }
-        });
-        assertEquals(singletonMap("fred", "jim"), combined);
-
-        final String ugh = "a!?//*=:\"% ";
-        ClientContext.doWithContext(singletonMap(ugh, ugh), new Callable<Void>() {
-            public Void call() {
-                assertEquals(Collections.singletonMap(ugh, ugh),
-                        ClientContext.getContext());
-                return null;
-            }
-        });
-
-        // Basic withContext tests
-
-        LogIH mbsIH = new LogIH(mbs);
-        MBeanServer snoopMBS = newSnoop(MBeanServer.class, mbsIH);
-        MBeanServer ughMBS = ClientContext.withContext(snoopMBS, ugh, ugh);
-        // ughMBS is never referenced but we check that the withContext call
-        // included a call to snoopMBS.isRegistered.
-        String encodedUgh = URLEncoder.encode(ugh, "UTF-8").replace("*", "%2A");
-        ObjectName expectedName = new ObjectName(
-                ClientContext.NAMESPACE + ObjectName.NAMESPACE_SEPARATOR +
-                encodedUgh + "=" + encodedUgh +
-                ObjectName.NAMESPACE_SEPARATOR + ":" +
-                JMXNamespace.TYPE_ASSIGNMENT);
-        assertCalled(mbsIH, "isRegistered", new Object[] {expectedName},
-                emptyContext);
-
-        // Test withDynamicContext
-
-        MBeanServerConnection dynamicSnoop =
-                ClientContext.withDynamicContext(snoopMBS);
-        assertCalled(mbsIH, "isRegistered",
-                new Object[] {
-                    JMXNamespaces.getNamespaceObjectName(ClientContext.NAMESPACE)
-                },
-                emptyContext);
-        final ShowContextMBean dynamicShow =
-                JMX.newMBeanProxy(dynamicSnoop, name, ShowContextMBean.class);
-        assertEquals(Collections.emptyMap(), dynamicShow.getContext());
-        assertCalled(mbsIH, "getAttribute", new Object[] {name, "Context"},
-                emptyContext);
-
-        Map<String, String> expectedDynamic =
-                Collections.singletonMap("gladstone", "gander");
-        Map<String, String> dynamic = ClientContext.doWithContext(
-                expectedDynamic,
-                new Callable<Map<String, String>>() {
-                    public Map<String, String> call() throws Exception {
-                        return dynamicShow.getContext();
-                    }
-                });
-        assertEquals(expectedDynamic, dynamic);
-        ObjectName expectedDynamicName = new ObjectName(
-                ClientContext.encode(expectedDynamic) +
-                ObjectName.NAMESPACE_SEPARATOR + name);
-        assertCalled(mbsIH, "getAttribute",
-                new Object[] {expectedDynamicName, "Context"}, dynamic);
-
-        MBeanServer cmbs = ClientContext.withContext(
-                mbs, "mickey", "mouse");
-        ShowContextMBean cshow =
-                JMX.newMBeanProxy(cmbs, name, ShowContextMBean.class);
-        assertEquals(Collections.singletonMap("mickey", "mouse"), cshow.getContext());
-
-        MBeanServer ccmbs = ClientContext.withContext(
-                cmbs, "donald", "duck");
-        ShowContextMBean ccshow =
-                JMX.newMBeanProxy(ccmbs, name, ShowContextMBean.class);
-        Map<String, String> disney = new HashMap<String, String>();
-        disney.put("mickey", "mouse");
-        disney.put("donald", "duck");
-        assertEquals(disney, ccshow.getContext());
-
-        // Test that all MBS ops produce reasonable results
-
-        ObjectName logger = new ObjectName("a:type=Logger");
-        DynamicMBean showMBean =
-                new StandardMBean(new ShowContext(), ShowContextMBean.class);
-        LogIH mbeanLogIH = new LogIH(showMBean);
-        DynamicMBean logMBean = newSnoop(DynamicMBean.class, mbeanLogIH);
-        ObjectInstance loggerOI = ccmbs.registerMBean(logMBean, logger);
-        assertEquals(logger, loggerOI.getObjectName());
-
-        // We get a getMBeanInfo call to determine the className in the
-        // ObjectInstance to return from registerMBean.
-        assertCalled(mbeanLogIH, "getMBeanInfo", disney);
-
-        ccmbs.getAttribute(logger, "Thing");
-        assertCalled(mbeanLogIH, "getAttribute", disney);
-
-        ccmbs.getAttributes(logger, new String[] {"Thing", "Context"});
-        assertCalled(mbeanLogIH, "getAttributes", disney);
-
-        ccmbs.setAttribute(logger, new Attribute("Thing", "bar"));
-        assertCalled(mbeanLogIH, "setAttribute", disney);
-
-        ccmbs.setAttributes(logger, new AttributeList(
-                Arrays.asList(new Attribute("Thing", "baz"))));
-        assertCalled(mbeanLogIH, "setAttributes", disney);
-
-        ccmbs.getMBeanInfo(logger);
-        assertCalled(mbeanLogIH, "getMBeanInfo", disney);
-
-        Set<ObjectName> names = ccmbs.queryNames(null, null);
-        Set<ObjectName> expectedNames = new HashSet<ObjectName>(
-                Collections.singleton(MBeanServerDelegate.DELEGATE_NAME));
-        expectedNames.removeAll(names);
-        assertEquals(0, expectedNames.size());
-
-        Set<ObjectName> nsNames =
-                ccmbs.queryNames(new ObjectName("**?*?//:*"), null);
-        Set<ObjectName> expectedNsNames = new HashSet<ObjectName>(
-                Arrays.asList(
-                new ObjectName(ClientContext.NAMESPACE +
-                ObjectName.NAMESPACE_SEPARATOR + ":" +
-                JMXNamespace.TYPE_ASSIGNMENT)));
-        expectedNsNames.removeAll(nsNames);
-        assertEquals(0, expectedNsNames.size());
-
-        Set<ObjectInstance> insts = ccmbs.queryMBeans(
-                MBeanServerDelegate.DELEGATE_NAME, null);
-        assertEquals(1, insts.size());
-        assertEquals(MBeanServerDelegate.DELEGATE_NAME,
-                insts.iterator().next().getObjectName());
-
-        ObjectName createdName = new ObjectName("a:type=Created");
-        ObjectInstance createdOI =
-                ccmbs.createMBean(ShowContext.class.getName(), createdName);
-        assertEquals(ShowContext.class.getName(), createdOI.getClassName());
-        assertEquals(createdName, createdOI.getObjectName());
-        assertEquals(disney, ccmbs.getAttribute(createdName, "CreationContext"));
-
-        NotificationListener nothingListener = new NotificationListener() {
-            public void handleNotification(Notification n, Object h) {}
-        };
-        ccmbs.addNotificationListener(createdName, nothingListener, null, null);
-        ccmbs.removeNotificationListener(createdName, nothingListener, null, null);
-        ccmbs.addNotificationListener(createdName, nothingListener, null, null);
-        ccmbs.removeNotificationListener(createdName, nothingListener);
-        Set<String> expectedOps = new HashSet<String>(Arrays.asList(
-                "preRegister", "postRegister", "addNotificationListener",
-                "removeNL1", "removeNL3", "getNotificationInfo"));
-        assertEquals(expectedOps, ccmbs.getAttribute(createdName, "CalledOps"));
-
-        assertEquals(ShowContext.class.getClassLoader(),
-                ccmbs.getClassLoaderFor(createdName));
-
-        assertEquals(true, ccmbs.isRegistered(createdName));
-        assertEquals(true, ccmbs.isInstanceOf(createdName,
-                ShowContext.class.getName()));
-        assertEquals(false, ccmbs.isInstanceOf(createdName,
-                DynamicMBean.class.getName()));
-        ccmbs.unregisterMBean(createdName);
-        assertEquals(false, ccmbs.isRegistered(createdName));
-
-        MLet mlet = new MLet();
-        ObjectName defaultMLetName = new ObjectName("DefaultDomain:type=MLet");
-
-        ccmbs.registerMBean(mlet, defaultMLetName);
-
-        assertEquals(mlet, ccmbs.getClassLoader(defaultMLetName));
-
-        assertEquals(0, mbeanLogIH.log.size());
-
-        // Test that contexts still work when we can't combine two encoded contexts.
-        // Here, we wrap cmbs (mickey=mouse) so that ccmbs2 (donald=duck) cannot
-        // see that it already contains a context and therefore cannot combine
-        // into mickey=mouse;donald=duck.  We don't actually use the snoop
-        // capabilities of the returned object -- we just want an opaque
-        // MBeanServer wrapper
-        MBeanServer cmbs2 = newSnoop(MBeanServer.class, new LogIH(cmbs));
-        MBeanServer ccmbs2 = ClientContext.withContext(cmbs2, "donald", "duck");
-        assertEquals(disney, ccmbs2.getAttribute(name, "Context"));
-
-        // ADD NEW TESTS HERE ^^^
-
-        if (failure != null)
-            throw new Exception(failure);
-        } finally {
-            srv.stop();
-        }
-    }
-
-    private static void assertEquals(Object x, Object y) {
-        if (!equal(x, y))
-            failed("expected " + string(x) + "; got " + string(y));
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        if (x.getClass().isArray())
-            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
-        return x.equals(y);
-    }
-
-    private static String string(Object x) {
-        String s = Arrays.deepToString(new Object[] {x});
-        return s.substring(1, s.length() - 1);
-    }
-
-    private static void assertCalled(
-            LogIH logIH, String op, Map<String, String> expectedContext) {
-        assertCalled(logIH, op, null, expectedContext);
-    }
-
-    private static void assertCalled(
-            LogIH logIH, String op, Object[] params,
-            Map<String, String> expectedContext) {
-        LogRecord lr = logIH.log.remove();
-        assertEquals(op, lr.op);
-        if (params != null)
-            assertEquals(params, lr.params);
-        assertEquals(expectedContext, lr.context);
-    }
-
-    private static void failed(String why) {
-        failure = why;
-        new Throwable("FAILED: " + why).printStackTrace(System.out);
-    }
-}
--- a/test/javax/management/context/localizable/MBeanDescriptions.properties	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-# This is the default description ResourceBundle for MBeans in this package.
-# Resources here override the descriptions specified with @Description
-# but only when localization is happening and when there is not a more
-# specific resource for the description (for example from MBeanDescriptions_fr).
-
-WhatsitMBean.mbean = A whatsit
-# This must be the same as WhatsitMBean.englishMBeanDescription for the
-# purposes of this test.
-
--- a/test/javax/management/context/localizable/MBeanDescriptions_fr.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 localizable;
-
-import java.util.ListResourceBundle;
-import static localizable.WhatsitMBean.*;
-
-public class MBeanDescriptions_fr extends ListResourceBundle {
-    @Override
-    protected Object[][] getContents() {
-        String constrProp = "WhatsitMBean.constructor." + Whatsit.class.getName();
-        return new Object[][] {
-            {"WhatsitMBean.mbean", frenchMBeanDescription},
-            {"WhatsitMBean.attribute.Whatsit", frenchAttrDescription},
-            {"WhatsitMBean.operation.frob", frenchOperDescription},
-            {"WhatsitMBean.operation.frob.p1", frenchParamDescription},
-            {constrProp, frenchConstrDescription},
-            {constrProp + ".p1", frenchConstrParamDescription},
-        };
-    }
-}
--- a/test/javax/management/context/localizable/Whatsit.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 localizable;
-
-import javax.management.Description;
-
-public class Whatsit implements WhatsitMBean {
-    /**
-     * Attribute : NewAttribute0
-     */
-    private String newAttribute0;
-    @Description(englishConstrDescription)
-    public Whatsit() {}
-
-    @Description(englishConstrDescription)
-    public Whatsit(@Description(englishConstrParamDescription) int type) {}
-
-    public String getWhatsit() {
-        return "whatsit";
-    }
-
-    public void frob(String whatsit) {
-    }
-
-    /**
-     * Get Tiddly
-     */
-    public String getNewAttribute0() {
-        return newAttribute0;
-    }
-
-    /**
-     * Set Tiddly
-     */
-    public void setNewAttribute0(String value) {
-        newAttribute0 = value;
-    }
-}
--- a/test/javax/management/context/localizable/WhatsitMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 localizable;
-
-import javax.management.Description;
-
-@Description(WhatsitMBean.defaultMBeanDescription)
-public interface WhatsitMBean {
-    public static final String
-            defaultMBeanDescription = "Default whatsit MBean description",
-            englishMBeanDescription = "A whatsit",
-            // Previous description appears in MBeanDescriptions.properties
-            // so it overrides the @Description when that file is used.
-            frenchMBeanDescription = "Un bidule",
-            englishAttrDescription = "The whatsit",
-            frenchAttrDescription = "Le bidule",
-            englishOperDescription = "Frob the whatsit",
-            frenchOperDescription = "Frober le bidule",
-            englishParamDescription = "The whatsit to frob",
-            frenchParamDescription = "Le bidule \u00e0 frober",
-            englishConstrDescription = "Make a whatsit",
-            frenchConstrDescription = "Fabriquer un bidule",
-            englishConstrParamDescription = "Type of whatsit to make",
-            frenchConstrParamDescription = "Type de bidule \u00e0 fabriquer",
-            unlocalizedMBeanDescription = "Unlocalized MBean";
-
-    @Description(englishAttrDescription)
-    public String getWhatsit();
-
-    @Description(englishOperDescription)
-    public void frob(@Description(englishParamDescription) String whatsit);
-}
--- a/test/javax/management/descriptor/DescriptorConstructorTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- * Copyright 2004-2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 6501362
- * @summary DescriptorSupport(String) could recognize "name=value" as well as XML format
- * @author Jean-Francois Denise
- * @run clean DescriptorConstructorTest
- * @run build DescriptorConstructorTest
- * @run main DescriptorConstructorTest
- */
-
-import javax.management.modelmbean.DescriptorSupport;
-
-public class DescriptorConstructorTest {
-    public static void main(String[] args) throws Exception {
-        DescriptorSupport d1 = new DescriptorSupport("MyName1=MyValue1");
-        if(!d1.getFieldValue("MyName1").equals("MyValue1"))
-            throw new Exception("Invalid parsing");
-        DescriptorSupport d2 = new DescriptorSupport("<Descriptor>" +
-                "<field name=\"MyName2\" value=\"MyValue2\"></field></Descriptor>");
-        if(!d2.getFieldValue("MyName2").equals("MyValue2"))
-            throw new Exception("Invalid parsing");
-    }
-}
--- a/test/javax/management/eventService/AddRemoveListenerTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,371 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 AddRemoveListenerTest.java
- * @bug 5108776
- * @summary Basic test for EventClient to see internal thread management.
- * @author Shanliang JIANG
- * @run clean AddRemoveListenerTest
- * @run build AddRemoveListenerTest
- * @run main AddRemoveListenerTest
- */
-
-import java.io.IOException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.FetchingEventRelay;
-import javax.management.event.RMIPushEventRelay;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-
-// This thread creates a single MBean that emits a number of parallel
-// sequences of notifications.  Each sequence is distinguished by an id
-// and each id corresponds to a thread that is filtering the notifications
-// so it only sees its own ones.  The notifications for a given id have
-// contiguous sequence numbers and each thread checks that the notifications
-// it receives do indeed have these numbers.  If notifications are lost or
-// if the different sequences interfere with each other then the test will
-// fail.  As an added tweak, a "noise" thread periodically causes notifications
-// to be emitted that do not correspond to any sequence and do not have any id.
-public class AddRemoveListenerTest {
-
-    private static MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
-    private static ObjectName emitter;
-    private static NotificationSender emitterImpl;
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-
-    private static int toSend = 100;
-    private static final long bigWaiting = 10000;
-    private static int counter = 0;
-    private static int jobs = 10;
-    private static int endedJobs = 0;
-
-    private static volatile String failure;
-
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> Test on multiple adding/removing listeners.");
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        emitter = new ObjectName("Default:name=NotificationSender");
-        emitterImpl = new NotificationSender();
-        mbeanServer.registerMBean(emitterImpl, emitter);
-
-        String[] types = new String[]{"PushEventRelay", "FetchingEventRelay"};
-        String[] protos = new String[]{"rmi", "iiop", "jmxmp"};
-        for (String prot : protos) {
-            url = new JMXServiceURL(prot, null, 0);
-
-            try {
-                server =
-                        JMXConnectorServerFactory.newJMXConnectorServer(url,
-                        null, mbeanServer);
-                server.start();
-            } catch (Exception e) {
-                System.out.println(">>> Skip "+prot+", not supported.");
-                continue;
-            }
-
-            url = server.getAddress();
-
-            // noise
-            Thread noise = new Thread(new Runnable() {
-                public void run() {
-                    while (true) {
-                        emitterImpl.sendNotif(1, null);
-                        try {
-                            Thread.sleep(10);
-                        } catch (Exception e) {
-                            // OK
-                        }
-                    }
-                }
-            });
-            noise.setDaemon(true);
-            noise.start();
-
-            try {
-                for (String type: types) {
-                    System.out.println("\n\n>>> Testing "+type+" on "+url+" ...");
-                    JMXConnector conn = newConn();
-                    try {
-                        testType(type, conn);
-                    } finally {
-                        conn.close();
-                        System.out.println(">>> Testing "+type+" on "+url+" ... done");
-                    }
-                }
-            } finally {
-                server.stop();
-            }
-        }
-    }
-
-    private static void testType(String type, JMXConnector conn) throws Exception {
-        Thread[] threads = new Thread[jobs];
-        for (int i=0; i<jobs; i++) {
-            threads[i] = new Thread(new Job(type, conn));
-            threads[i].setDaemon(true);
-            threads[i].start();
-        }
-
-        // to wait
-        long toWait = bigWaiting*jobs;
-        long stopTime = System.currentTimeMillis() + toWait;
-
-        synchronized(AddRemoveListenerTest.class) {
-            while (endedJobs < jobs && toWait > 0 && failure == null) {
-                AddRemoveListenerTest.class.wait(toWait);
-                toWait = stopTime - System.currentTimeMillis();
-            }
-        }
-
-        if (endedJobs != jobs && failure == null) {
-            throw new RuntimeException("Need to set bigger waiting timeout?");
-        }
-
-        endedJobs = 0;
-    }
-
-    public static class Job implements Runnable {
-        public Job(String type, JMXConnector conn) {
-            this.type = type;
-            this.conn = conn;
-        }
-        public void run() {
-            try {
-                test(type, conn);
-
-                synchronized(AddRemoveListenerTest.class) {
-                    endedJobs++;
-                    if (endedJobs>=jobs) {
-                        AddRemoveListenerTest.class.notify();
-                    }
-                }
-            } catch (RuntimeException re) {
-                throw re;
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        private final String type;
-        private final JMXConnector conn;
-    }
-
-    private static void test(String type, JMXConnector conn) throws Exception {
-        EventClient ec = newEventClient(type, conn);
-        try {
-            test(type, conn, ec);
-        } finally {
-            ec.close();
-        }
-    }
-
-    private static void test(String type, JMXConnector conn, EventClient ec)
-            throws Exception {
-        String id = getId();
-
-        Listener listener = new Listener(id);
-        Filter filter = new Filter(id);
-
-        System.out.println(">>> ("+id+") To receive notifications "+toSend);
-        ec.addNotificationListener(emitter,
-                listener, filter, null);
-
-        emitterImpl.sendNotif(toSend, id);
-        listener.waitNotifs(bigWaiting, toSend);
-        if (listener.received != toSend) {
-            throw new RuntimeException(">>> ("+id+") Expected to receive: "
-                    +toSend+", but got: "+listener.received);
-        }
-
-        listener.clear();
-        ec.removeNotificationListener(emitter, listener, filter, null);
-
-        System.out.println(">>> ("+id+") Repeat adding and removing ...");
-        for (int j=0; j<10; j++) {
-            ec.addNotificationListener(emitter, dummyListener, null, id);
-            Thread.yield(); // allow to start listening
-            ec.removeNotificationListener(emitter, dummyListener, null, id);
-        }
-
-        System.out.println(">>> ("+id+") To receive again notifications "+toSend);
-        ec.addNotificationListener(emitter,
-                listener, filter, null);
-
-        emitterImpl.sendNotif(toSend, id);
-        listener.waitNotifs(bigWaiting, toSend);
-        Thread.yield(); //any duplicated?
-        if (listener.received != toSend) {
-            throw new RuntimeException("("+id+") Expected to receive: "
-                    +toSend+", but got: "+listener.received);
-        }
-    }
-
-//--------------------------
-// private classes
-//--------------------------
-
-    private static class Listener implements NotificationListener {
-        public Listener(String id) {
-            this.id = id;
-        }
-        public void handleNotification(Notification notif, Object handback) {
-            if (!id.equals(notif.getUserData())) {
-                System.out.println("("+id+") Filter error, my id is: "+id+
-                        ", but got "+notif.getUserData());
-                System.exit(1);
-            }
-
-            synchronized (this) {
-                received++;
-
-                if(++sequenceNB != notif.getSequenceNumber()) {
-                    fail("(" + id + ") Wrong sequence number, expected: "
-                            +sequenceNB+", but got: "+notif.getSequenceNumber());
-                }
-                if (received >= toSend || failure != null) {
-                    this.notify();
-                }
-            }
-        }
-
-        public void waitNotifs(long timeout, int nb) throws Exception {
-            long toWait = timeout;
-            long stopTime = System.currentTimeMillis() + timeout;
-            synchronized(this) {
-                while (received < nb && toWait > 0 && failure == null) {
-                    this.wait(toWait);
-                    toWait = stopTime - System.currentTimeMillis();
-                }
-            }
-        }
-
-        public void clear() {
-            synchronized(this) {
-                received = 0;
-                sequenceNB = -1;
-            }
-        }
-
-        private String id;
-        private int received = 0;
-
-        private long sequenceNB = -1;
-    }
-
-    private static class Filter implements NotificationFilter {
-        public Filter(String id) {
-            this.id = id;
-        }
-
-        public boolean isNotificationEnabled(Notification n) {
-            return id.equals(n.getUserData());
-        }
-        private String id;
-    }
-
-    private static NotificationListener dummyListener = new NotificationListener() {
-        public void handleNotification(Notification notif, Object handback) {
-        }
-    };
-
-    public static class NotificationSender extends NotificationBroadcasterSupport
-            implements NotificationSenderMBean {
-
-        /**
-         * Send Notification objects.
-         *
-         * @param nb The number of notifications to send
-         */
-        public void sendNotif(int nb, String userData) {
-            long sequenceNumber = 0;
-            for (int i = 0; i<nb; i++) {
-                Notification notif = new Notification(myType, this, sequenceNumber++);
-                notif.setUserData(userData);
-                sendNotification(notif);
-            }
-        }
-
-
-        private final String myType = "notification.my_notification";
-    }
-
-    public interface NotificationSenderMBean {
-        public void sendNotif(int nb, String userData);
-    }
-
-    private static JMXConnector newConn() throws IOException {
-        return JMXConnectorFactory.connect(url);
-    }
-
-    private static EventClient newEventClient(String type, JMXConnector conn)
-            throws Exception {
-        EventClientDelegateMBean proxy =
-                EventClientDelegate.getProxy(conn.getMBeanServerConnection());
-        if (type.equals("PushEventRelay")) {
-            return new EventClient(proxy,
-                    new RMIPushEventRelay(proxy), null, null, 60000);
-        } else if (type.equals("FetchingEventRelay")) {
-            return new EventClient(proxy,
-                    new FetchingEventRelay(proxy), null, null, 60000);
-        } else {
-            throw new RuntimeException("Wrong event client type: "+type);
-        }
-    }
-
-    private static String getId() {
-        synchronized(AddRemoveListenerTest.class) {
-            return String.valueOf(counter++);
-        }
-    }
-
-    private static void fail(String msg) {
-        System.out.println("FAIL: " + msg);
-        failure = msg;
-    }
-}
--- a/test/javax/management/eventService/CustomForwarderTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,395 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 CustomForwarderTest
- * @bug 5108776 6759619
- * @summary Test that a custom EventForwarder can be added
- * @author Eamonn McManus
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.management.ManagementFactory;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.SocketAddress;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.EventForwarder;
-import javax.management.event.EventReceiver;
-import javax.management.event.EventRelay;
-import javax.management.remote.MBeanServerForwarder;
-import javax.management.remote.NotificationResult;
-import javax.management.remote.TargetedNotification;
-
-public class CustomForwarderTest {
-    public static class UdpEventRelay implements EventRelay {
-        private final EventClientDelegateMBean delegate;
-        private final DatagramSocket socket;
-        private final AtomicBoolean closed = new AtomicBoolean();
-        private final String clientId;
-        private EventReceiver receiver;
-
-        public UdpEventRelay(EventClientDelegateMBean delegate)
-        throws IOException {
-            this.delegate = delegate;
-            this.socket = new DatagramSocket();
-            try {
-                clientId = delegate.addClient(
-                        UdpEventForwarder.class.getName(),
-                        new Object[] {socket.getLocalSocketAddress()},
-                        new String[] {SocketAddress.class.getName()});
-            } catch (IOException e) {
-                throw e;
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                final IOException ioe =
-                        new IOException("Exception creating EventForwarder");
-                ioe.initCause(e);
-                throw ioe;
-            }
-            Thread t = new Thread(new Receiver());
-            t.setDaemon(true);
-            t.start();
-        }
-
-        public String getClientId() throws IOException {
-            return clientId;
-        }
-
-        public void setEventReceiver(EventReceiver eventReceiver) {
-            this.receiver = eventReceiver;
-        }
-
-        public void stop() throws IOException {
-            closed.set(true);
-            socket.close();
-        }
-
-        void simulateNonFatal() {
-            receiver.nonFatal(new Exception("NonFatal"));
-        }
-
-        void simulateFailed() {
-            receiver.failed(new Error("Failed"));
-        }
-
-        private class Receiver implements Runnable {
-            public void run() {
-                byte[] buf = new byte[1024];
-                DatagramPacket packet = new DatagramPacket(buf, buf.length);
-                while (true) {
-                    try {
-                        socket.receive(packet);
-                    } catch (IOException e) {
-                        if (closed.get()) {
-                            System.out.println("Receiver got exception: " + e);
-                            System.out.println("Normal because it has been closed");
-                            return;
-                        } else {
-                            System.err.println("UNEXPECTED EXCEPTION IN RECEIVER:");
-                            e.printStackTrace();
-                            System.exit(1);
-                        }
-                    }
-                    try {
-                        ByteArrayInputStream bin = new ByteArrayInputStream(buf);
-                        ObjectInputStream oin = new ObjectInputStream(bin);
-                        NotificationResult nr = (NotificationResult)
-                                oin.readObject();
-                        receiver.receive(nr);
-                    } catch (Exception e) {
-                        System.err.println("UNEXPECTED EXCEPTION IN RECEIVER:");
-                        e.printStackTrace();
-                        System.exit(1);
-                    }
-                }
-            }
-        }
-    }
-
-    public static class UdpEventForwarder implements EventForwarder {
-        private final DatagramSocket socket;
-        private final AtomicLong seqNo = new AtomicLong(0);
-        private static volatile boolean drop;
-
-        public UdpEventForwarder(SocketAddress addr) throws IOException {
-            this.socket = new DatagramSocket();
-            socket.connect(addr);
-        }
-
-        public static void setDrop(boolean drop) {
-            UdpEventForwarder.drop = drop;
-        }
-
-        public void forward(Notification n, Integer listenerId) throws IOException {
-            long nextSeqNo = seqNo.incrementAndGet();
-            long thisSeqNo = nextSeqNo - 1;
-            TargetedNotification tn = new TargetedNotification(n, listenerId);
-            NotificationResult nr = new NotificationResult(
-                    thisSeqNo, nextSeqNo, new TargetedNotification[] {tn});
-            ByteArrayOutputStream bout = new ByteArrayOutputStream();
-            ObjectOutputStream oout = new ObjectOutputStream(bout);
-            oout.writeObject(nr);
-            oout.close();
-            byte[] bytes = bout.toByteArray();
-            DatagramPacket packet = new DatagramPacket(bytes, bytes.length);
-            if (!drop)
-                socket.send(packet);
-        }
-
-        public void close() throws IOException {
-            socket.close();
-        }
-
-        public void setClientId(String clientId) throws IOException {
-            // Nothing to do.
-        }
-    }
-
-    public static interface EmptyMBean {}
-
-    public static class Empty
-            extends NotificationBroadcasterSupport implements EmptyMBean {
-        public void send(Notification n) {
-            super.sendNotification(n);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        MBeanServerForwarder mbsf = EventClientDelegate.newForwarder(mbs, null);
-        mbs = mbsf;
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbs.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbs.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbs),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        ObjectName name = new ObjectName("a:b=c");
-        Empty mbean = new Empty();
-        mbs.registerMBean(mbean, name);
-
-        EventClientDelegateMBean delegate = (EventClientDelegateMBean)
-            MBeanServerInvocationHandler.newProxyInstance(
-                mbs,
-                EventClientDelegateMBean.OBJECT_NAME,
-                EventClientDelegateMBean.class,
-                false);
-        UdpEventRelay relay = new UdpEventRelay(delegate);
-        EventClient client = new EventClient(delegate, relay, null, null, 0L);
-
-        final Semaphore lostCountSema = new Semaphore(0);
-        final BlockingQueue<Notification> nonFatalNotifs =
-                new ArrayBlockingQueue<Notification>(1);
-        final BlockingQueue<Notification> failedNotifs =
-                new ArrayBlockingQueue<Notification>(1);
-        NotificationListener lostListener = new NotificationListener() {
-            public void handleNotification(Notification notification, Object handback) {
-                if (notification.getType().equals(EventClient.NOTIFS_LOST)) {
-                    System.out.println("Got lost-notifs notif: count=" +
-                            notification.getUserData());
-                    lostCountSema.release(((Long) notification.getUserData()).intValue());
-                } else if (notification.getType().equals(EventClient.NONFATAL)) {
-                    System.out.println("Got nonFatal notif");
-                    nonFatalNotifs.add(notification);
-                } else if (notification.getType().equals(EventClient.FAILED)) {
-                    System.out.println("Got failed notif");
-                    failedNotifs.add(notification);
-                } else
-                    System.out.println("Mysterious EventClient notif: " + notification);
-            }
-        };
-        client.addEventClientListener(lostListener, null, null);
-
-        final BlockingQueue<Notification> notifQueue =
-                new ArrayBlockingQueue<Notification>(10);
-        NotificationListener countListener = new NotificationListener() {
-            public void handleNotification(Notification notification, Object handback) {
-                System.out.println("Received: " + notification);
-                notifQueue.add(notification);
-                if (!"tiddly".equals(handback)) {
-                    System.err.println("TEST FAILED: bad handback: " + handback);
-                    System.exit(1);
-                }
-            }
-        };
-
-        final AtomicInteger filterCount = new AtomicInteger(0);
-        NotificationFilter countFilter = new NotificationFilter() {
-            private static final long serialVersionUID = 1234L;
-
-            public boolean isNotificationEnabled(Notification notification) {
-                System.out.println("Filter called for: " + notification);
-                filterCount.incrementAndGet();
-                return true;
-            }
-        };
-
-        client.addNotificationListener(name, countListener, countFilter, "tiddly");
-
-        assertEquals("Initial notif count", 0, notifQueue.size());
-        assertEquals("Initial filter count", 0, filterCount.get());
-
-        Notification n = nextNotif(name);
-        mbean.send(n);
-
-        System.out.println("Waiting for notification to arrive...");
-
-        Notification n1 = notifQueue.poll(10, TimeUnit.SECONDS);
-
-        assertEquals("Received notif", n, n1);
-        assertEquals("Notif queue size after receive", 0, notifQueue.size());
-        assertEquals("Filter count after notif", 1, filterCount.get());
-        assertEquals("Lost notif count", 0, lostCountSema.availablePermits());
-
-        System.out.println("Dropping notifs");
-
-        UdpEventForwarder.setDrop(true);
-        for (int i = 0; i < 3; i++)
-            mbean.send(nextNotif(name));
-        UdpEventForwarder.setDrop(false);
-
-        Thread.sleep(2);
-        assertEquals("Notif queue size after drops", 0, notifQueue.size());
-
-        System.out.println("Turning off dropping and sending a notif");
-        n = nextNotif(name);
-        mbean.send(n);
-
-        System.out.println("Waiting for dropped notifications to be detected...");
-        boolean acquired = lostCountSema.tryAcquire(3, 5, TimeUnit.SECONDS);
-        assertEquals("Correct count of lost notifs", true, acquired);
-
-        n1 = notifQueue.poll(10, TimeUnit.SECONDS);
-        assertEquals("Received non-dropped notif", n, n1);
-
-        assertEquals("Notif queue size", 0, notifQueue.size());
-        assertEquals("Filter count after drops", 5, filterCount.get());
-
-        Thread.sleep(10);
-        assertEquals("Further lost-notifs", 0, lostCountSema.availablePermits());
-
-        System.out.println("Testing error notifs");
-        relay.simulateNonFatal();
-        n = nonFatalNotifs.poll(10, TimeUnit.SECONDS);
-        assertEquals("Exception message for non-fatal exception", "NonFatal",
-                ((Throwable) n.getSource()).getMessage());
-        relay.simulateFailed();
-        n = failedNotifs.poll(10, TimeUnit.SECONDS);
-        assertEquals("Exception message for failed exception", "Failed",
-                ((Throwable) n.getSource()).getMessage());
-
-        // 6759619
-        System.out.println("Test EventClient.getEventClientNotificationInfo");
-        MBeanNotificationInfo[] mbnis = client.getEventClientNotificationInfo();
-        final String[] expectedTypes = {
-            EventClient.NOTIFS_LOST, EventClient.NONFATAL, EventClient.FAILED
-        };
-    check:
-        for (String type : expectedTypes) {
-            for (MBeanNotificationInfo mbni : mbnis) {
-                for (String t : mbni.getNotifTypes()) {
-                    if (type.equals(t)) {
-                        System.out.println("...found " + type);
-                        continue check;
-                    }
-                }
-            }
-            throw new Exception("TEST FAILED: Did not find notif type " + type);
-        }
-
-        client.close();
-
-        System.out.println("TEST PASSED");
-    }
-
-    private static AtomicLong nextSeqNo = new AtomicLong(0);
-    private static Notification nextNotif(ObjectName name) {
-        long n = nextSeqNo.incrementAndGet();
-        return new Notification("type", name, n, "" + n);
-    }
-
-    private static void assertEquals(String what, Object expected, Object got) {
-        if (equals(expected, got))
-            System.out.println(what + " = " + expected + ", as expected");
-        else {
-            Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
-            for (Thread t : traces.keySet()) {
-                System.out.println(t.getName());
-                for (StackTraceElement elmt : traces.get(t)) {
-                    System.out.println("    " + elmt);
-                }
-            }
-            throw new RuntimeException(
-                    "TEST FAILED: " + what + " is " + got + "; should be " +
-                    expected);
-        }
-    }
-
-    private static boolean equals(Object expected, Object got) {
-        if (!(expected instanceof Notification))
-            return expected.equals(got);
-        if (expected.getClass() != got.getClass())
-            return false;
-        // Notification doesn't override Object.equals so two distinct
-        // notifs are never equal even if they have the same contents.
-        // Although the test doesn't serialize the notifs, if at some
-        // stage it did then it would fail because the deserialized notif
-        // was not equal to the original one.  Therefore we compare enough
-        // notif fields to detect when notifs really are different.
-        Notification en = (Notification) expected;
-        Notification gn = (Notification) got;
-        return (en.getType().equals(gn.getType()) &&
-                en.getSource().equals(gn.getSource()) &&
-                en.getSequenceNumber() == gn.getSequenceNumber());
-    }
-}
--- a/test/javax/management/eventService/EventClientExecutorTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * 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 5108776
- * @summary Test that the various Executor parameters in an EventClient do
- * what they are supposed to.
- * @author Eamonn McManus
- */
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ThreadFactory;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.FetchingEventRelay;
-import javax.management.remote.MBeanServerForwarder;
-
-public class EventClientExecutorTest {
-    private static volatile String failure;
-    private static final Set testedPrefixes = new HashSet();
-
-    public static void main(String[] args) throws Exception {
-        Executor fetchExecutor = Executors.newSingleThreadExecutor(
-                new NamedThreadFactory("FETCH"));
-        Executor listenerExecutor = Executors.newSingleThreadExecutor(
-                new NamedThreadFactory("LISTENER"));
-        ScheduledExecutorService leaseScheduler =
-            Executors.newSingleThreadScheduledExecutor(
-                new NamedThreadFactory("LEASE"));
-
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        MBeanServerForwarder mbsf = EventClientDelegate.newForwarder(mbs, null);
-        mbs = mbsf;
-
-        EventClientDelegateMBean ecd = EventClientDelegate.getProxy(mbs);
-        ecd = (EventClientDelegateMBean) Proxy.newProxyInstance(
-                EventClientDelegateMBean.class.getClassLoader(),
-                new Class<?>[] {EventClientDelegateMBean.class},
-                new DelegateCheckIH(ecd));
-
-        ObjectName mbeanName = new ObjectName("d:type=Notifier");
-        Notifier notifier = new Notifier();
-        mbs.registerMBean(notifier, mbeanName);
-
-        FetchingEventRelay eventRelay = new FetchingEventRelay(
-                ecd, fetchExecutor);
-        EventClient ec = new EventClient(
-                ecd, eventRelay, listenerExecutor, leaseScheduler, 1000L);
-        NotificationListener checkListener = new NotificationListener() {
-            public void handleNotification(Notification notification,
-                                           Object handback) {
-                assertThreadName("listener dispatch", "LISTENER");
-            }
-        };
-        ec.addNotificationListener(mbeanName, checkListener, null, null);
-
-        mbs.invoke(mbeanName, "send", null, null);
-
-        // Now wait until we have seen all three thread types.
-        long deadline = System.currentTimeMillis() + 5000;
-        synchronized (testedPrefixes) {
-            while (testedPrefixes.size() < 3 && failure == null) {
-                long remain = deadline - System.currentTimeMillis();
-                if (remain <= 0) {
-                    fail("Timed out waiting for all three thread types to show, " +
-                            "saw only " + testedPrefixes);
-                    break;
-                }
-                try {
-                    testedPrefixes.wait(remain);
-                } catch (InterruptedException e) {
-                    fail("Unexpected InterruptedException");
-                    break;
-                }
-            }
-        }
-
-        // We deliberately don't close the EventClient to check that it has
-        // not created any non-daemon threads.
-
-        if (failure != null)
-            throw new Exception("TEST FAILED: " + failure);
-        else
-            System.out.println("TEST PASSED");
-    }
-
-    public static interface NotifierMBean {
-        public void send();
-    }
-
-    public static class Notifier extends NotificationBroadcasterSupport
-            implements NotifierMBean {
-        public void send() {
-            Notification n = new Notification("a.b.c", this, 0L);
-            sendNotification(n);
-        }
-    }
-
-    static void fail(String why) {
-        System.out.println("FAIL: " + why);
-        failure = why;
-    }
-
-    static void assertThreadName(String what, String prefix) {
-        String name = Thread.currentThread().getName();
-        if (!name.startsWith(prefix)) {
-            fail("Wrong thread for " + what + ": " + name);
-            return;
-        }
-
-        synchronized (testedPrefixes) {
-            if (testedPrefixes.add(prefix))
-                testedPrefixes.notify();
-        }
-    }
-
-    private static class DelegateCheckIH implements InvocationHandler {
-        private final EventClientDelegateMBean ecd;
-
-        public DelegateCheckIH(EventClientDelegateMBean ecd) {
-            this.ecd = ecd;
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-                throws Throwable {
-            String methodName = method.getName();
-            if (methodName.equals("fetchNotifications"))
-                assertThreadName("fetchNotifications", "FETCH");
-            else if (methodName.equals("lease"))
-                assertThreadName("lease renewal", "LEASE");
-            try {
-                return method.invoke(ecd, args);
-            } catch (InvocationTargetException e) {
-                throw e.getCause();
-            }
-        }
-    }
-
-    private static class NamedThreadFactory implements ThreadFactory {
-        private final String namePrefix;
-        private int count;
-
-        NamedThreadFactory(String namePrefix) {
-            this.namePrefix = namePrefix;
-        }
-
-        public synchronized Thread newThread(Runnable r) {
-            Thread t = new Thread(r);
-            t.setName(namePrefix + " " + ++count);
-            t.setDaemon(true);
-            return t;
-        }
-    }
-}
--- a/test/javax/management/eventService/EventClientThreadTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-/*
- * 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 6747411
- * @summary Check that EventClient instances don't leak threads.
- * @author Eamonn McManus
- */
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadInfo;
-import java.lang.management.ThreadMXBean;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerNotification;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class EventClientThreadTest {
-    private static final int MAX_TIME_SECONDS = 20;
-
-    private static final BlockingQueue<Notification> queue =
-            new ArrayBlockingQueue(100);
-
-    private static final NotificationListener queueListener =
-            new NotificationListener() {
-        public void handleNotification(Notification notification,
-                                       Object handback) {
-            queue.add(notification);
-        }
-    };
-
-    private static final NotificationFilter dummyFilter =
-            new NotificationFilter() {
-        public boolean isNotificationEnabled(Notification notification) {
-            return true;
-        }
-    };
-
-    public static void main(String[] args) throws Exception {
-        long start = System.currentTimeMillis();
-        long deadline = start + MAX_TIME_SECONDS * 1000;
-
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
-        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
-                url, null, mbs);
-        cs.start();
-        JMXServiceURL addr = cs.getAddress();
-        JMXConnector cc = JMXConnectorFactory.connect(addr);
-        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-
-        ThreadMXBean threads = ManagementFactory.getThreadMXBean();
-
-        System.out.println("Opening and closing some EventClients...");
-        // If we create a connection, then create and destroy EventClients
-        // over it, then close it, there should be no "JMX *" threads left.
-        for (int i = 0; i < 5; i++)
-            test(mbsc);
-
-        cc.close();
-
-        showTime("opening and closing initial EventClients", start);
-
-        Set<String> jmxThreads = threadsMatching("JMX .*");
-        while (!jmxThreads.isEmpty() && System.currentTimeMillis() < deadline) {
-            Set<String> jmxThreadsNow = threadsMatching("JMX .*");
-            Set<String> gone = new TreeSet<String>(jmxThreads);
-            gone.removeAll(jmxThreadsNow);
-            for (String s : gone)
-                showTime("expiry of \"" + s + "\"", start);
-            jmxThreads = jmxThreadsNow;
-            Thread.sleep(10);
-        }
-        if (System.currentTimeMillis() >= deadline) {
-            showThreads(threads);
-            throw new Exception("Timed out waiting for JMX threads to expire");
-        }
-
-        showTime("waiting for JMX threads to expire", start);
-
-        System.out.println("TEST PASSED");
-    }
-
-    static void showThreads(ThreadMXBean threads) throws Exception {
-        long[] ids = threads.getAllThreadIds();
-        for (long id : ids) {
-            ThreadInfo ti = threads.getThreadInfo(id);
-            String name = (ti == null) ? "(defunct)" : ti.getThreadName();
-            System.out.printf("%4d %s\n", id, name);
-        }
-    }
-
-    static void showTime(String what, long start) {
-        long elapsed = System.currentTimeMillis() - start;
-        System.out.printf("Time after %s: %.3f s\n", what, elapsed / 1000.0);
-    }
-
-    static Set<String> threadsMatching(String pattern) {
-        Set<String> matching = new TreeSet<String>();
-        ThreadMXBean threads = ManagementFactory.getThreadMXBean();
-        long[] ids = threads.getAllThreadIds();
-        for (long id : ids) {
-            ThreadInfo ti = threads.getThreadInfo(id);
-            String name = (ti == null) ? "(defunct)" : ti.getThreadName();
-            if (name.matches(pattern))
-                matching.add(name);
-        }
-        return matching;
-    }
-
-    static void test(MBeanServerConnection mbsc) throws Exception {
-        final ObjectName delegateName = MBeanServerDelegate.DELEGATE_NAME;
-        final ObjectName testName = new ObjectName("test:type=Test");
-        EventClient ec = new EventClient(mbsc);
-        ec.addNotificationListener(delegateName, queueListener, null, null);
-        mbsc.createMBean(MBeanServerDelegate.class.getName(), testName);
-        mbsc.unregisterMBean(testName);
-        final String[] expectedTypes = {
-            MBeanServerNotification.REGISTRATION_NOTIFICATION,
-            MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
-        };
-        for (String s : expectedTypes) {
-            Notification n = queue.poll(3, TimeUnit.SECONDS);
-            if (n == null)
-                throw new Exception("Timed out waiting for notif: " + s);
-            if (!(n instanceof MBeanServerNotification))
-                throw new Exception("Got notif of wrong class: " + n.getClass());
-            if (!n.getType().equals(s)) {
-                throw new Exception("Got notif of wrong type: " + n.getType() +
-                        " (expecting " + s + ")");
-            }
-        }
-        ec.removeNotificationListener(delegateName, queueListener);
-
-        ec.addNotificationListener(delegateName, queueListener, dummyFilter, "foo");
-        ec.removeNotificationListener(delegateName, queueListener, dummyFilter, "foo");
-
-        ec.close();
-    }
-}
\ No newline at end of file
--- a/test/javax/management/eventService/EventDelegateSecurityTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,289 +0,0 @@
-/*
- * 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 5108776
- * @summary Test that the EventClientDelegate MBean does not require extra
- * permissions compared with plain addNotificationListener.
- * @author Eamonn McManus
- * @run main/othervm -Dxjava.security.debug=policy,access,failure EventDelegateSecurityTest
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.security.AccessControlContext;
-import java.security.AccessController;
-import java.security.AllPermission;
-import java.security.PrivilegedExceptionAction;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.SynchronousQueue;
-import java.util.concurrent.TimeUnit;
-import javax.management.MBeanPermission;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.remote.JMXAuthenticator;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXPrincipal;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.MBeanServerForwarder;
-import javax.security.auth.Subject;
-
-public class EventDelegateSecurityTest {
-    private static final BlockingQueue<Notification> notifQ =
-            new SynchronousQueue<Notification>();
-
-    private static volatile long seqNo;
-    private static volatile long expectSeqNo;
-
-    private static class QueueListener implements NotificationListener {
-        public void handleNotification(Notification notification,
-                                       Object handback) {
-            try {
-                notifQ.put(notification);
-            } catch (InterruptedException e) {
-                throw new AssertionError(e);
-            }
-        }
-    }
-    private static final NotificationListener queueListener = new QueueListener();
-
-    public static interface SenderMBean {
-        public void send();
-    }
-
-    public static class Sender
-            extends NotificationBroadcasterSupport implements SenderMBean {
-        public void send() {
-            Notification n = new Notification("x", this, seqNo++);
-            sendNotification(n);
-        }
-    }
-
-    private static class LimitInvocationHandler implements InvocationHandler {
-        private MBeanServer nextMBS;
-        private final Set<String> allowedMethods = new HashSet<String>();
-
-        void allow(String... names) {
-            synchronized (allowedMethods) {
-                allowedMethods.addAll(Arrays.asList(names));
-            }
-        }
-
-        public Object invoke(Object proxy, Method m, Object[] args)
-                throws Throwable {
-            System.out.println(
-                    "filter: " + m.getName() +
-                    ((args == null) ? "[]" : Arrays.deepToString(args)));
-            String name = m.getName();
-
-            if (name.equals("getMBeanServer"))
-                return nextMBS;
-
-            if (name.equals("setMBeanServer")) {
-                nextMBS = (MBeanServer) args[0];
-                return null;
-            }
-
-            if (m.getDeclaringClass() == Object.class ||
-                    allowedMethods.contains(name)) {
-                try {
-                    return m.invoke(nextMBS, args);
-                } catch (InvocationTargetException e) {
-                    throw e.getCause();
-                }
-            } else {
-                System.out.println("...refused");
-                throw new SecurityException(
-                        "Method refused: " + m.getDeclaringClass().getName() +
-                        "." + m.getName() +
-                        ((args == null) ? "[]" : Arrays.deepToString(args)));
-            }
-        }
-
-    }
-
-    private static interface MakeConnectorServer {
-        public JMXConnectorServer make(JMXServiceURL url) throws IOException;
-    }
-
-
-    public static void main(String[] args) throws Exception {
-        JMXPrincipal rootPrincipal = new JMXPrincipal("root");
-        Subject rootSubject = new Subject();
-        rootSubject.getPrincipals().add(rootPrincipal);
-        Subject.doAsPrivileged(rootSubject, new PrivilegedExceptionAction<Void>() {
-            public Void run() throws Exception {
-                mainAsRoot();
-                return null;
-            }
-        }, null);
-    }
-
-    private static void mainAsRoot() throws Exception {
-        AccessControlContext acc = AccessController.getContext();
-        Subject subject = Subject.getSubject(acc);
-        System.out.println("Subject: " + subject);
-        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        ObjectName name = new ObjectName("a:b=c");
-        mbs.registerMBean(new Sender(), name);
-
-        System.out.println("Test with no installed security");
-        test(mbs, name, new MakeConnectorServer() {
-            public JMXConnectorServer make(JMXServiceURL url) throws IOException {
-                return
-                    JMXConnectorServerFactory.newJMXConnectorServer(url, null, null);
-            }
-        });
-
-        System.out.println("Test with filtering MBeanServerForwarder");
-        LimitInvocationHandler limitIH = new LimitInvocationHandler();
-        // We allow getClassLoaderRepository because the ConnectorServer
-        // calls it so any real checking MBeanServerForwarder must accept it.
-        limitIH.allow(
-                "addNotificationListener", "removeNotificationListener",
-                "getClassLoaderRepository"
-                );
-        final MBeanServerForwarder limitMBSF = (MBeanServerForwarder)
-            Proxy.newProxyInstance(
-                MBeanServerForwarder.class.getClassLoader(),
-                new Class<?>[] {MBeanServerForwarder.class},
-                limitIH);
-        // We go to considerable lengths to ensure that the ConnectorServer has
-        // no MBeanServer when the EventClientDelegate forwarder is activated,
-        // so that the calls it makes when it is later linked to an MBeanServer
-        // go through the limitMBSF.
-        test(mbs, name, new MakeConnectorServer() {
-            public JMXConnectorServer make(JMXServiceURL url) throws IOException {
-                JMXConnectorServer cs =
-                    JMXConnectorServerFactory.newJMXConnectorServer(url, null, null);
-                limitMBSF.setMBeanServer(mbs);
-                cs.setMBeanServerForwarder(limitMBSF);
-                return cs;
-            }
-        });
-
-        final File policyFile =
-                File.createTempFile("EventDelegateSecurityTest", ".policy");
-        PrintWriter pw = new PrintWriter(policyFile);
-        String JMXPrincipal = JMXPrincipal.class.getName();
-        String AllPermission = AllPermission.class.getName();
-        String MBeanPermission = MBeanPermission.class.getName();
-        pw.println("grant principal " + JMXPrincipal + " \"root\" {");
-        pw.println("    permission " + AllPermission + ";");
-        pw.println("};");
-        pw.println("grant principal " + JMXPrincipal + " \"user\" {");
-        pw.println("    permission " + MBeanPermission + " \"*\", " +
-                " \"addNotificationListener\";");
-        pw.println("    permission " + MBeanPermission + " \"*\", " +
-                " \"removeNotificationListener\";");
-        pw.println("};");
-        pw.close();
-        Runtime.getRuntime().addShutdownHook(new Thread() {
-            @Override
-            public void run() {
-                policyFile.delete();
-            }
-        });
-        System.setProperty("java.security.policy", policyFile.getAbsolutePath());
-        System.setSecurityManager(new SecurityManager());
-        test(mbs, name, new MakeConnectorServer() {
-            public JMXConnectorServer make(JMXServiceURL url) throws IOException {
-                Map<String, Object> env = new HashMap<String, Object>();
-                env.put(JMXConnectorServer.AUTHENTICATOR, new JMXAuthenticator() {
-                    public Subject authenticate(Object credentials) {
-                        Subject s = new Subject();
-                        s.getPrincipals().add(new JMXPrincipal("user"));
-                        return s;
-                    }
-                });
-                return
-                    JMXConnectorServerFactory.newJMXConnectorServer(url, env, null);
-            }
-        });
-    }
-
-    private static void test(MBeanServer mbs, ObjectName name) throws Exception {
-        test(mbs, name, null);
-    }
-
-    private static void test(
-            MBeanServer mbs, ObjectName name, MakeConnectorServer make)
-            throws Exception {
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
-        JMXConnectorServer cs = make.make(url);
-        ObjectName csName = new ObjectName("a:type=ConnectorServer");
-        mbs.registerMBean(cs, csName);
-        cs.start();
-        try {
-            JMXServiceURL addr = cs.getAddress();
-            JMXConnector cc = JMXConnectorFactory.connect(addr);
-            MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-            test(mbs, mbsc, name);
-            cc.close();
-            mbs.unregisterMBean(csName);
-        } finally {
-            cs.stop();
-        }
-    }
-
-    private static void test(
-            MBeanServer mbs, MBeanServerConnection mbsc, ObjectName name)
-            throws Exception {
-        EventClient ec = new EventClient(mbsc);
-        ec.addNotificationListener(name, queueListener, null, null);
-        mbs.invoke(name, "send", null, null);
-
-        Notification n = notifQ.poll(5, TimeUnit.SECONDS);
-        if (n == null)
-            throw new Exception("FAILED: notif not delivered");
-        if (n.getSequenceNumber() != expectSeqNo) {
-            throw new Exception(
-                    "FAILED: notif seqno " + n.getSequenceNumber() +
-                    " should be " + expectSeqNo);
-        }
-        expectSeqNo++;
-
-        ec.removeNotificationListener(name, queueListener);
-        ec.close();
-    }
-}
--- a/test/javax/management/eventService/EventManagerTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,221 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 EventManagerTest.java 1.8 08/01/22
- * @bug 5108776
- * @summary Basic test for EventManager.
- * @author Shanliang JIANG
- * @run clean EventManagerTest
- * @run build EventManagerTest
- * @run main EventManagerTest
- */
-
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.*;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- *
- */
-public class EventManagerTest {
-    private static MBeanServer mbeanServer;
-    private static ObjectName emitter;
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-    private static JMXConnector conn;
-    private static MBeanServerConnection client;
-
-    /**
-     * @param args the command line arguments
-     */
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> EventManagerTest-main basic tests ...");
-        mbeanServer = MBeanServerFactory.createMBeanServer();
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        emitter = new ObjectName("Default:name=NotificationEmitter");
-
-        url = new JMXServiceURL("rmi", null, 0) ;
-        server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
-        server.start();
-
-        url = server.getAddress();
-        conn = JMXConnectorFactory.connect(url, null);
-        client = conn.getMBeanServerConnection();
-
-        mbeanServer.registerMBean(new NotificationEmitter(), emitter);
-
-        boolean succeed;
-
-        System.out.println(">>> EventManagerTest-main: using the fetching EventRelay...");
-        succeed = test(new EventClient(client));
-
-        System.out.println(">>> EventManagerTest-main: using the pushing EventRelay...");
-        EventClientDelegateMBean ecd = EventClientDelegate.getProxy(client);
-        succeed &= test(new EventClient(ecd,
-                new RMIPushEventRelay(ecd),
-                null, null,
-                EventClient.DEFAULT_REQUESTED_LEASE_TIME));
-
-        conn.close();
-        server.stop();
-
-        if (succeed) {
-            System.out.println(">>> EventManagerTest-main: PASSE!");
-        } else {
-            System.out.println("\n>>> EventManagerTest-main: FAILED!");
-            System.exit(1);
-        }
-    }
-
-    public static boolean test(EventClient efClient) throws Exception {
-        // add listener from the client side
-        Listener listener = new Listener();
-        efClient.subscribe(emitter, listener, null, null);
-
-        // ask to send notifs
-        Object[] params = new Object[] {new Integer(sendNB)};
-        String[] signatures = new String[] {"java.lang.Integer"};
-        client.invoke(emitter, "sendNotifications", params, signatures);
-
-        // waiting
-        long toWait = 6000;
-        long stopTime = System.currentTimeMillis() + toWait;
-
-        synchronized(listener) {
-            while(listener.received < sendNB && toWait > 0) {
-                listener.wait(toWait);
-                toWait = stopTime - System.currentTimeMillis();
-            }
-        }
-
-        // clean
-        System.out.println(">>> EventManagerTest-test: cleaning...");
-        efClient.unsubscribe(emitter, listener);
-        efClient.close();
-
-        if (listener.received != sendNB) {
-            System.out.println(">>> EventManagerTest-test: FAILED! Expected to receive "+sendNB+", but got "+listener.received);
-
-            return false;
-        } else if (listener.seqErr > 0) {
-            System.out.println(">>> EventManagerTest-test: FAILED! The receiving sequence is not correct.");
-
-            return false;
-        } else {
-            System.out.println(">>> EventManagerTest-test: got all expected "+listener.received);
-            return true;
-        }
-    }
-
-    private static class Listener implements NotificationListener {
-        public int received = 0;
-        public int seqErr = 0;
-
-        private long lastSeq = -1;
-
-        public void handleNotification(Notification notif, Object handback) {
-            if (!myType.equals(notif.getType())) {
-                System.out.println(">>> EventManagerTest-Listener: got unexpected notif: "+notif);
-                System.exit(1);
-            }
-
-            if (lastSeq == -1) {
-                lastSeq = notif.getSequenceNumber();
-            } else if (notif.getSequenceNumber() - lastSeq++ != 1) {
-                seqErr++;
-            }
-
-            //System.out.println(">>> EventManagerTest-Listener: got notif "+notif.getSequenceNumber());
-
-            synchronized(this) {
-                if (++received >= sendNB) {
-                    this.notify();
-                }
-            }
-        }
-    }
-
-    public static class NotificationEmitter extends NotificationBroadcasterSupport
-            implements NotificationEmitterMBean {
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            final String[] ntfTypes = {myType};
-
-            final MBeanNotificationInfo[] ntfInfoArray  = {
-                new MBeanNotificationInfo(ntfTypes,
-                        "javax.management.Notification",
-                        "Notifications sent by the NotificationEmitter")};
-
-                        return ntfInfoArray;
-        }
-
-        /**
-         * Send Notification objects.
-         *
-         * @param nb The number of notifications to send
-         */
-        public void sendNotifications(Integer nb) {
-            Notification notif;
-            for (int i=1; i<=nb.intValue(); i++) {
-                notif = new Notification(myType, this, count++);
-                notif.setUserData("jsl");
-                //System.out.println(">>> EventManagerService-NotificationEmitter-sendNotifications: "+i);
-
-                sendNotification(notif);
-            }
-        }
-    }
-
-    public interface NotificationEmitterMBean {
-        public void sendNotifications(Integer nb);
-    }
-
-    private static int sendNB = 120;
-    private static long count = 0;
-
-    private static final String myType = "notification.my_notification";
-}
--- a/test/javax/management/eventService/FetchingTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,276 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 5108776
- * @summary Basic test for EventClient.
- * @author Shanliang JIANG
- * @run clean FetchingTest MyFetchingEventForwarder
- * @run build FetchingTest MyFetchingEventForwarder
- * @run main FetchingTest MyFetchingEventForwarder
- */
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.FetchingEventRelay;
-import javax.management.event.RMIPushEventForwarder;
-import javax.management.event.RMIPushServer;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class FetchingTest {
-    private static MBeanServer mbeanServer;
-    private static ObjectName emitter;
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-    private static JMXConnector conn;
-    private static MBeanServerConnection client;
-    private static long WAITING_TIME = 6000;
-
-    /**
-     * @param args the command line arguments
-     */
-    public static void main(String[] args) throws Exception {
-
-        System.out.println(">>> FetchingTest-main basic tests ...");
-        mbeanServer = MBeanServerFactory.createMBeanServer();
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        emitter = new ObjectName("Default:name=NotificationEmitter");
-        mbeanServer.registerMBean(new NotificationEmitter(), emitter);
-        boolean succeed = true;
-
-        final String[] protos = new String[] {"rmi", "iiop", "jmxmp"};
-        for (String proto : protos) {
-            System.out.println(">>> FetchingTest-main: testing on "+proto);
-
-            try {
-                url = new JMXServiceURL(proto, null, 0) ;
-                server = JMXConnectorServerFactory.
-                        newJMXConnectorServer(url, null, mbeanServer);
-                server.start();
-            } catch (Exception e) {
-                // OK
-                System.out.println(">>> FetchingTest-main: skip the proto "+proto);
-                continue;
-            }
-
-            url = server.getAddress();
-            conn = JMXConnectorFactory.connect(url, null);
-            client = conn.getMBeanServerConnection();
-
-            succeed &= test();
-
-            conn.close();
-            server.stop();
-
-            System.out.println(
-                    ">>> FetchingTest-main: testing on "+proto+" done.");
-        }
-
-        if (succeed) {
-            System.out.println(">>> FetchingTest-main: PASSED!");
-        } else {
-            System.out.println("\n>>> FetchingTest-main: FAILED!");
-            System.exit(1);
-        }
-    }
-
-    public static boolean test() throws Exception {
-        System.out.println(">>> FetchingTest-test: " +
-                "using the default fetching forwarder ...");
-        EventClient eventClient =
-                new EventClient(client);
-
-        Listener listener = new Listener();
-        eventClient.addNotificationListener(emitter, listener, null, null);
-
-        // ask to send notifs
-        Object[] params = new Object[] {new Integer(sendNB)};
-        String[] signatures = new String[] {"java.lang.Integer"};
-        conn.getMBeanServerConnection().invoke(emitter,
-                "sendNotifications", params, signatures);
-
-        if (listener.waitNotif(WAITING_TIME) != sendNB) {
-            System.out.println(
-                    ">>> FetchingTest-test: FAILED! Expected to receive "+
-                    sendNB+", but got "+listener.received);
-
-            return false;
-        }
-
-        System.out.println(
-                ">>> ListenerTest-test: got all expected "+listener.received);
-        //eventClient.removeNotificationListener(emitter, listener);
-        eventClient.close();
-
-        System.out.println(">>> FetchingTest-test: " +
-                "using a user specific List ...");
-
-        FetchingEventRelay fer = new FetchingEventRelay(
-                EventClientDelegate.getProxy(client),
-                1000, 1000L, 1000, null,
-                MyFetchingEventForwarder.class.getName(),
-                null, null);
-
-        eventClient = new EventClient(
-                EventClientDelegate.getProxy(client), fer, null, null, 10000);
-
-        eventClient.addNotificationListener(emitter, listener, null, null);
-        listener.received = 0;
-
-        conn.getMBeanServerConnection().invoke(emitter,
-                "sendNotifications", params, signatures);
-
-        if (listener.waitNotif(WAITING_TIME) != sendNB) {
-            System.out.println(
-                    ">>> FetchingTest-test: FAILED! Expected to receive "+
-                    sendNB+", but got "+listener.received);
-
-            return false;
-        }
-
-        System.out.println(
-                ">>> FetchingTest-test: got all expected "+listener.received);
-
-        if (!MyFetchingEventForwarder.shared.isUsed()) {
-            System.out.println(
-                    ">>> FetchingTest-test: FAILED! The user specific list" +
-                        "is not used!");
-
-            return false;
-        }
-
-        System.out.println(">>> Negative test to add an EventClient" +
-                " with a non EventForwarder object.");
-        try {
-            MyFetchingEventForwarder.shared.setAgain();
-
-            System.out.println(
-                    ">>> FetchingTest-test: FAILED! No expected exception" +
-                    "when setting the list after the forwarder started.");
-
-            return false;
-        } catch (IllegalStateException ise) {
-            // OK
-            System.out.println(
-                    ">>> FetchingTest-test: Got expected exception: " + ise);
-        }
-
-        eventClient.close();
-
-        try {
-            fer = new FetchingEventRelay(
-                EventClientDelegate.getProxy(client),
-                1000, 1000L, 1000, null,
-                Object.class.getName(),
-                null, null);
-
-                eventClient = new EventClient(
-                        EventClientDelegate.getProxy(client), fer, null, null, 10000);
-
-                System.out.println(
-                    ">>> FetchingTest-test: FAILED! No expected exception" +
-                    "when creating an illegal EventForwarder");
-        } catch (IllegalArgumentException iae) {
-            // OK
-            // iae.printStackTrace();
-        }
-
-        return true;
-    }
-
-    private static class Listener implements NotificationListener {
-        public void handleNotification(Notification notif, Object handback) {
-            synchronized(this) {
-                if (++received >= sendNB) {
-                    this.notify();
-                }
-            }
-
-            //System.out.println(">>> FetchingTest-Listener: received = "+received);
-        }
-
-        public int waitNotif(long timeout) throws Exception {
-            synchronized(this) {
-                long stopTime = System.currentTimeMillis() + timeout;
-                long toWait = timeout;
-                while (toWait > 0 && received < sendNB) {
-                        this.wait(toWait);
-                    toWait = stopTime - System.currentTimeMillis();
-                }
-            }
-
-            return received;
-        }
-
-        public static int received = 0;
-    }
-
-    public static class NotificationEmitter extends NotificationBroadcasterSupport
-            implements NotificationEmitterMBean {
-
-        public void sendNotifications(Integer nb) {
-            System.out.println(
-                    ">>> FetchingTest-NotificationEmitter-sendNotifications: "+nb);
-            Notification notif;
-            for (int i=1; i<=nb.intValue(); i++) {
-                notif = new Notification(myType, this, count++);
-                sendNotification(notif);
-            }
-        }
-    }
-
-    public interface NotificationEmitterMBean {
-        public void sendNotifications(Integer nb);
-    }
-
-
-
-    private static int sendNB = 20;
-    private static int count = 0;
-
-    private static final String myType = "notification.my_notification";
-}
--- a/test/javax/management/eventService/LeaseManagerDeadlockTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-/*
- * 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 6717789
- * @summary Check that a lock is not held when a LeaseManager expires.
- * @author Eamonn McManus
- * @compile -XDignore.symbol.file=true LeaseManagerDeadlockTest.java
- * @run main LeaseManagerDeadlockTest
- */
-
-import com.sun.jmx.event.LeaseManager;
-import java.lang.management.ManagementFactory;
-import java.lang.management.ThreadMXBean;
-import java.util.Arrays;
-import java.util.concurrent.Semaphore;
-import java.util.concurrent.TimeUnit;
-
-public class LeaseManagerDeadlockTest {
-    public static String failure;
-    public static LeaseManager leaseManager;
-    public static Semaphore callbackThreadCompleted = new Semaphore(0);
-    public static Object lock = new Object();
-
-    public static Runnable triggerDeadlock = new Runnable() {
-        public void run() {
-            Runnable pingLeaseManager = new Runnable() {
-                public void run() {
-                    System.out.println("Ping thread starts");
-                    synchronized (lock) {
-                        leaseManager.lease(1);
-                    }
-                    System.out.println("Ping thread completes");
-                }
-            };
-            Thread t = new Thread(pingLeaseManager);
-            t.start();
-            try {
-                Thread.sleep(10);  // enough time for ping thread to grab lock
-                synchronized (lock) {
-                    t.join();
-                }
-            } catch (InterruptedException e) {
-                fail(e.toString());
-            }
-            System.out.println("Callback thread completes");
-            callbackThreadCompleted.release();
-        }
-    };
-
-    public static void main(String[] args) throws Exception {
-        // Also test that we can shorten the lease from its initial value.
-        leaseManager = new LeaseManager(triggerDeadlock, 1000000);
-        leaseManager.lease(1L);
-
-        boolean callbackRan =
-                callbackThreadCompleted.tryAcquire(3, TimeUnit.SECONDS);
-
-        if (!callbackRan) {
-            fail("Callback did not complete - probable deadlock");
-            ThreadMXBean threads = ManagementFactory.getThreadMXBean();
-            System.out.println(Arrays.toString(threads.findDeadlockedThreads()));
-            System.out.println("PRESS RETURN");
-            System.in.read();
-        }
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    public static void fail(String why) {
-        System.out.println("TEST FAILS: " + why);
-        failure = why;
-    }
-}
--- a/test/javax/management/eventService/LeaseTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,361 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 LeaseTest.java 1.6 08/01/22
- * @bug 5108776
- * @summary Basic test for Event service leasing.
- * @author Shanliang JIANG
- * @run clean LeaseTest
- * @run build LeaseTest
- * @run main LeaseTest
- */
-
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.EventClientNotFoundException;
-import javax.management.event.FetchingEventRelay;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class LeaseTest {
-
-    private static MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
-    private static List<Notification> notifList = new ArrayList<Notification>();
-    private static ObjectName emitter;
-    private static NotificationEmitter emitterImpl;
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-    private static JMXConnector conn;
-    private static Listener listener = new Listener();
-
-    private static long leaseTime = 100;
-    private static final int multiple = 5;
-    private static final long bigWaiting = 6000;
-
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> Test the event service lease");
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        System.setProperty("com.sun.event.lease.time",
-                String.valueOf(leaseTime));
-        emitter = new ObjectName("Default:name=NotificationEmitter");
-        emitterImpl = new NotificationEmitter();
-        mbeanServer.registerMBean(emitterImpl, emitter);
-
-        String[] types = new String[]{"PushingEventRelay", "FetchingEventRelay"};
-        String[] protos = new String[]{"rmi", "iiop", "jmxmp"};
-        for (String prot : protos) {
-            url = new JMXServiceURL(prot, null, 0);
-
-            try {
-                server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url,
-                null, mbeanServer);
-                server.start();
-            } catch (Exception e) {
-                System.out.println(">>> Skip "+prot+", not support.");
-                continue;
-            }
-
-            url = server.getAddress();
-
-            try {
-                for (String type: types) {
-                    test(type);
-                }
-            } finally {
-                server.stop();
-            }
-        }
-    }
-
-    private static void test(String type) throws Exception {
-        System.out.println("\n\n>>> Testing "+type+" on "+url+" ...");
-        newConn();
-        EventClient ec = newEventClient(type);
-
-        ec.addNotificationListener(emitter,
-                listener, null, null);
-
-        System.out.println(">>> Send a notification and should receive it.");
-        emitterImpl.sendNotif(++counter);
-
-        if (!waitNotif(bigWaiting, counter)) {
-            throw new RuntimeException(">>> Failed to receive notif.");
-        }
-
-        System.out.println(">>> Sleep 3 times of requested lease time.");
-        Thread.sleep(leaseTime*3);
-        System.out.println(">>> Send again a notification and should receive it.");
-        emitterImpl.sendNotif(++counter);
-
-        if (!waitNotif(bigWaiting, counter)) {
-            throw new RuntimeException(">>> Failed to receive notif.");
-        }
-
-        System.out.println(">>> Close the client connection: "+
-                conn.getConnectionId());
-        conn.close();
-
-        System.out.println(">>> Waiting lease timeout to do clean.");
-
-        if (!emitterImpl.waitingClean(leaseTime*multiple)) {
-            throw new RuntimeException(
-                    ">>> The event lease failed to do clean: "+
-                    emitterImpl.listenerSize);
-        } else {
-            System.out.println(">>> The listener has been removed.");
-        }
-
-        // Check that the client id has indeed been removed, by trying to
-        // remove it again, which should fail.
-        newConn();
-        try {
-            EventClientDelegateMBean proxy =
-                EventClientDelegate.getProxy(conn.getMBeanServerConnection());
-            proxy.removeClient(ec.getEventRelay().getClientId());
-
-            throw new RuntimeException(
-                    ">>> The client id is not removed.");
-        } catch (EventClientNotFoundException ecnfe) {
-            // OK
-            System.out.println(">>> The client id has been removed.");
-        }
-        conn.close();
-
-        System.out.println(">>> Reconnect to the server.");
-        newConn();
-
-        System.out.println(">>> Create a new EventClient and add the listeners" +
-                " in the failed EventClient into new EventClient");
-        EventClient newEC = newEventClient(type);
-        newEC.addListeners(ec.getListeners());
-        // We expect ec.close() to get IOException because we closed the
-        // underlying connection.
-        try {
-            ec.close();
-            throw new RuntimeException(">>> EventClient.close did not throw " +
-                    "expected IOException");
-        } catch (IOException e) {
-            System.out.println(">>> EventClient.close threw expected exception: " + e);
-        }
-
-        emitterImpl.sendNotif(++counter);
-
-        if (!waitNotif(bigWaiting, counter)) {
-            throw new RuntimeException(">>> The event client failed to add " +
-                    "all old registered listeners after re-connection.");
-        } else {
-            System.out.println(">>> Successfully received notification from" +
-                    " new EventClient.");
-        }
-
-        System.out.println(">>> Clean the failed EventClient.");
-        ec.close();
-        if (ec.getListeners().size() != 0) {
-            throw new RuntimeException(">>> The event client fails to do clean.");
-        }
-
-        System.out.println(">>> Clean the new EventClient.");
-        newEC.close();
-        if (newEC.getListeners().size() != 0) {
-            throw new RuntimeException(">>> The event client fails to do clean.");
-        }
-
-        conn.close();
-        System.out.println(">>> Testing "+type+" on "+url+" ... done");
-    }
-
-    private static boolean waitNotif(long time, int sequenceNumber)
-    throws Exception {
-        synchronized(notifList) {
-            if (search(sequenceNumber)) {
-                return true;
-            }
-
-            long stopTime = System.currentTimeMillis() + time;
-            long toWait = time;
-            while (toWait > 0) {
-                notifList.wait(toWait);
-
-                if (search(sequenceNumber)) {
-                    return true;
-                }
-
-                toWait = stopTime - System.currentTimeMillis();
-            }
-
-            return false;
-        }
-    }
-
-    private static boolean search(int sequenceNumber) {
-        while(notifList.size() > 0) {
-            Notification n = notifList.remove(0);
-            if (n.getSequenceNumber() == sequenceNumber) {
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-//--------------------------
-// private classes
-//--------------------------
-
-    private static class Listener implements NotificationListener {
-        public void handleNotification(Notification notif, Object handback) {
-            synchronized (notifList) {
-                notifList.add(notif);
-                notifList.notify();
-            }
-        }
-    }
-
-    public static class NotificationEmitter extends NotificationBroadcasterSupport
-            implements NotificationEmitterMBean {
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            final String[] ntfTypes = {myType};
-
-            final MBeanNotificationInfo[] ntfInfoArray  = {
-                new MBeanNotificationInfo(ntfTypes,
-                        "javax.management.Notification",
-                        "Notifications sent by the NotificationEmitter")};
-
-            return ntfInfoArray;
-        }
-
-        /**
-         * Send Notification objects.
-         *
-         * @param nb The number of notifications to send
-         */
-        public void sendNotif(int sequenceNumber) {
-            Notification notif = new Notification(myType, this, sequenceNumber);
-            sendNotification(notif);
-        }
-
-        public void addNotificationListener(NotificationListener listener,
-                NotificationFilter filter, Object handback) {
-            super.addNotificationListener(listener, filter, handback);
-
-            listenerSize++;
-        }
-
-        public void removeNotificationListener(NotificationListener listener)
-        throws ListenerNotFoundException {
-            super.removeNotificationListener(listener);
-            listenerSize--;
-
-            synchronized(this) {
-                if (listenerSize == 0) {
-                    this.notifyAll();
-                }
-            }
-        }
-
-        public void removeNotificationListener(NotificationListener listener,
-                NotificationFilter filter, Object handback)
-                throws ListenerNotFoundException {
-            super.removeNotificationListener(listener, filter, handback);
-            listenerSize--;
-
-            synchronized(this) {
-                if (listenerSize == 0) {
-                    this.notifyAll();
-                }
-            }
-        }
-
-        public boolean waitingClean(long timeout) throws Exception {
-            synchronized(this) {
-                long stopTime = System.currentTimeMillis() + timeout;
-                long toWait = timeout;
-                while (listenerSize != 0 && toWait > 0) {
-                    this.wait(toWait);
-                    toWait = stopTime - System.currentTimeMillis();
-                }
-            }
-
-            return listenerSize == 0;
-        }
-
-        public int listenerSize = 0;
-
-        private final String myType = "notification.my_notification";
-    }
-
-    public interface NotificationEmitterMBean {
-        public void sendNotif(int sequenceNumber);
-    }
-
-    private static void newConn() throws IOException {
-        conn = JMXConnectorFactory.connect(url);
-    }
-
-    private static EventClient newEventClient(String type) throws Exception {
-        EventClientDelegateMBean proxy =
-                EventClientDelegate.getProxy(conn.getMBeanServerConnection());
-        if (type.equals("PushingEventRelay")) {
-            return new EventClient(proxy,
-                    new FetchingEventRelay(proxy), null, null, leaseTime);
-        } else if (type.equals("FetchingEventRelay")) {
-            return new EventClient(proxy,
-                    new FetchingEventRelay(proxy), null, null, leaseTime);
-        } else {
-            throw new RuntimeException("Wrong event client type: "+type);
-        }
-    }
-
-    private static int counter = 0;
-}
--- a/test/javax/management/eventService/ListenerTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 ListenerTest.java 1.7 08/01/22
- * @bug 5108776
- * @summary Basic test for EventClient.
- * @author Shanliang JIANG
- * @run clean ListenerTest
- * @run build ListenerTest
- * @run main ListenerTest
- */
-
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.*;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- *
- */
-public class ListenerTest {
-    private static MBeanServer mbeanServer;
-    private static ObjectName emitter;
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-    private static JMXConnector conn;
-    private static MBeanServerConnection client;
-
-    /**
-     * @param args the command line arguments
-     */
-    public static void main(String[] args) throws Exception {
-
-        System.out.println(">>> ListenerTest-main basic tests ...");
-        mbeanServer = MBeanServerFactory.createMBeanServer();
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        emitter = new ObjectName("Default:name=NotificationEmitter");
-
-        url = new JMXServiceURL("rmi", null, 0) ;
-        server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
-        server.start();
-
-        url = server.getAddress();
-        conn = JMXConnectorFactory.connect(url, null);
-        client = conn.getMBeanServerConnection();
-
-        mbeanServer.registerMBean(new NotificationEmitter(), emitter);
-
-        boolean succeed;
-
-        System.out.println(">>> ListenerTest-main: using the fetching EventRelay...");
-        succeed = test(new EventClient(client));
-
-        System.out.println(">>> ListenerTest-main: using the pushing EventRelay...");
-        EventClientDelegateMBean ecd = EventClientDelegate.getProxy(client);
-        succeed &= test(new EventClient(ecd,
-                new RMIPushEventRelay(ecd),
-                null, null,
-                EventClient.DEFAULT_REQUESTED_LEASE_TIME));
-
-        conn.close();
-        server.stop();
-
-        if (succeed) {
-            System.out.println(">>> ListenerTest-main: PASSED!");
-        } else {
-            System.out.println("\n>>> ListenerTest-main: FAILED!");
-            System.exit(1);
-        }
-    }
-
-    public static boolean test(EventClient efClient) throws Exception {
-        // add listener from the client side
-        Listener listener = new Listener();
-        efClient.addNotificationListener(emitter, listener, null, null);
-
-        // ask to send notifs
-        Object[] params = new Object[] {new Integer(sendNB)};
-        String[] signatures = new String[] {"java.lang.Integer"};
-        client.invoke(emitter, "sendNotifications", params, signatures);
-
-        // waiting
-        long toWait = 6000;
-        long stopTime = System.currentTimeMillis() + toWait;
-
-        synchronized(listener) {
-            while(listener.received < sendNB && toWait > 0) {
-                listener.wait(toWait);
-                toWait = stopTime - System.currentTimeMillis();
-            }
-        }
-
-        // clean
-        efClient.removeNotificationListener(emitter, listener, null, null);
-        efClient.close();
-
-        if (listener.received != sendNB) {
-            System.out.println(">>> ListenerTest-test: FAILED! Expected to receive "+sendNB+", but got "+listener.received);
-
-            return false;
-        } else if (listener.seqErr > 0) {
-            System.out.println(">>> ListenerTest-test: FAILED! The receiving sequence is not correct.");
-
-            return false;
-        } else {
-            System.out.println(">>> ListenerTest-test: got all expected "+listener.received);
-            return true;
-        }
-    }
-
-    private static class Listener implements NotificationListener {
-        public int received = 0;
-        public int seqErr = 0;
-
-        private long lastSeq = -1;
-
-        public void handleNotification(Notification notif, Object handback) {
-            if (!myType.equals(notif.getType())) {
-                System.out.println(">>> EventManagerTest-Listener: got unexpected notif: "+notif);
-                System.exit(1);
-            }
-
-            if (lastSeq == -1) {
-                lastSeq = notif.getSequenceNumber();
-            } else if (notif.getSequenceNumber() - lastSeq++ != 1) {
-                seqErr++;
-            }
-
-            System.out.println(">>> ListenerTest-Listener: got notif "+notif.getSequenceNumber());
-
-            synchronized(this) {
-                if (++received >= sendNB) {
-                    this.notify();
-                }
-            }
-
-            System.out.println(">>> ListenerTest-Listener: received = "+received);
-        }
-    }
-
-    public static class NotificationEmitter extends NotificationBroadcasterSupport
-            implements NotificationEmitterMBean {
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            final String[] ntfTypes = {myType};
-
-            final MBeanNotificationInfo[] ntfInfoArray  = {
-                new MBeanNotificationInfo(ntfTypes,
-                        "javax.management.Notification",
-                        "Notifications sent by the NotificationEmitter")};
-
-                        return ntfInfoArray;
-        }
-
-        /**
-         * Send Notification objects.
-         *
-         * @param nb The number of notifications to send
-         */
-        public void sendNotifications(Integer nb) {
-            Notification notif;
-            for (int i=1; i<=nb.intValue(); i++) {
-                notif = new Notification(myType, this, count++);
-                //System.out.println(">>> ListenerTest-NotificationEmitter-sendNotifications: "+i);
-
-                sendNotification(notif);
-            }
-        }
-
-
-    }
-
-    public interface NotificationEmitterMBean {
-        public void sendNotifications(Integer nb);
-    }
-
-    private static int sendNB = 20;
-    private static int count = 0;
-
-    private static final String myType = "notification.my_notification";
-}
--- a/test/javax/management/eventService/MyFetchingEventForwarder.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * MyList.java
- *
- * Created on Oct 23, 2007, 2:45:57 PM
- *
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/**
- *
- * @author sjiang
- */
-
-import java.io.IOException;
-import java.util.ArrayList;
-import javax.management.event.FetchingEventForwarder;
-
-public class MyFetchingEventForwarder extends FetchingEventForwarder {
-
-    public MyFetchingEventForwarder() {
-        super(1000);
-        shared = this;
-        setList(myList);
-    }
-
-    public void setAgain() {
-        setList(myList);
-    }
-
-    public void setClientId(String clientId) throws IOException {
-        used = true;
-        super.setClientId(clientId);
-    }
-
-    public boolean isUsed() {
-        return used;
-    }
-
-    private class MyList<TargetedNotification>
-            extends ArrayList<TargetedNotification> {
-
-        public boolean add(TargetedNotification e) {
-            used = true;
-
-            return super.add(e);
-        }
-    }
-
-    public MyList myList = new MyList();
-    public static MyFetchingEventForwarder shared;
-    private boolean used = false;
-}
--- a/test/javax/management/eventService/NotSerializableNotifTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,227 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 NotSerializableNotifTest.java 1.5 08/01/22
- * @bug 5108776
- * @summary Basic test for EventClient.
- * @author Shanliang JIANG
- * @run clean NotSerializableNotifTest
- * @run build NotSerializableNotifTest
- * @run main NotSerializableNotifTest
- */
-
-
-// JMX imports
-//
-import javax.management.* ;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.EventRelay;
-import javax.management.event.FetchingEventRelay;
-
-import javax.management.remote.*;
-import javax.management.remote.JMXServiceURL;
-
-public class NotSerializableNotifTest {
-    private static MBeanServer mbeanServer =
-        MBeanServerFactory.createMBeanServer();
-    private static ObjectName emitter;
-    private static int port = 2468;
-
-    private static String[] protocols;
-
-    private static final int sentNotifs = 50;
-
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> Test to send a not serializable notification");
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        NotificationEmitter nm = new NotificationEmitter();
-        emitter = new ObjectName("Default:name=NotificationEmitter");
-        mbeanServer.registerMBean(nm, emitter);
-        String proto = "rmi";
-
-        System.out.println(">>> Test for protocol " + proto);
-
-        JMXServiceURL url = new JMXServiceURL(proto, null, 0);
-
-        JMXConnectorServer server =
-            JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
-
-        server.start();
-
-        url = server.getAddress();
-        JMXConnector conn = JMXConnectorFactory.connect(url, null);
-        MBeanServerConnection client = conn.getMBeanServerConnection();
-
-        EventClientDelegateMBean ecd = EventClientDelegate.getProxy(client);
-        EventRelay eventRelay = new FetchingEventRelay(
-                ecd,
-                FetchingEventRelay.DEFAULT_BUFFER_SIZE,
-                10,
-                FetchingEventRelay.DEFAULT_MAX_NOTIFICATIONS,
-                null);
-        EventClient ec = new EventClient(ecd, eventRelay, null, null,
-                EventClient.DEFAULT_REQUESTED_LEASE_TIME);
-
-        // add listener from the client side
-        Listener listener = new Listener();
-        ec.addNotificationListener(emitter, listener, null, null);
-
-        LostListener lostListener = new LostListener();
-        ec.addEventClientListener(lostListener, null, null);
-
-        // ask to send one not serializable notif
-        System.out.println(">>> sending not serializable notifs ...");
-
-        Object[] params = new Object[] {new Integer(sentNotifs)};
-        String[] signatures = new String[] {"java.lang.Integer"};
-        client.invoke(emitter, "sendNotserializableNotifs", params, signatures);
-
-//      nm.sendNotserializableNotifs(sentNotifs);
-//      nm.sendNotifications(1);
-
-        // waiting
-        synchronized(lostListener) {
-            if (lostListener.lostCount != sentNotifs) {
-                lostListener.wait(6000);
-            }
-        }
-
-        Thread.sleep(100);
-
-        if (lostListener.lostCount != sentNotifs) {
-            System.out.println(">>> FAILED. Expected "+sentNotifs+", but got "+lostListener.lostCount);
-            System.exit(1);
-        }
-
-        System.out.println(">>> Passed.");
-
-        ec.close();
-        conn.close();
-        server.stop();
-    }
-
-
-//--------------------------
-// private classes
-//--------------------------
-    private static class Listener implements NotificationListener {
-        public void handleNotification(Notification n, Object handback) {
-            System.out.println(">>> Listener: receive: "+n);
-        }
-    }
-
-
-    private static class LostListener implements NotificationListener {
-        public void handleNotification(Notification n, Object handback) {
-             if (!EventClient.NOTIFS_LOST.equals(n.getType())) {
-                return;
-            }
-
-            if (!(n.getUserData() instanceof Long)) {
-                System.out.println(">>> Listener: JMXConnectionNotification userData " +
-                                   "not a Long: " + n.getUserData());
-                System.exit(1);
-            } else {
-                int lost = ((Long) n.getUserData()).intValue();
-                lostCount += lost;
-                if (lostCount >= sentNotifs) {
-                    synchronized(this) {
-                        this.notifyAll();
-                    }
-                }
-            }
-
-        }
-
-
-        private int lostCount = 0;
-    }
-
-    public static class NotificationEmitter extends NotificationBroadcasterSupport
-        implements NotificationEmitterMBean {
-
-        public MBeanNotificationInfo[] getNotificationInfo() {
-            final String[] ntfTypes = {myType};
-
-            final MBeanNotificationInfo[] ntfInfoArray  = {
-                new MBeanNotificationInfo(ntfTypes,
-                                          "javax.management.Notification",
-                                          "Notifications sent by the NotificationEmitter")};
-
-            return ntfInfoArray;
-        }
-
-        /**
-         * Send not serializable Notifications.
-         *
-         * @param nb The number of notifications to send
-         */
-        public void sendNotserializableNotifs(Integer nb) {
-
-            Notification notif;
-            for (int i=1; i<=nb.intValue(); i++) {
-                notif = new Notification(myType, this, i);
-
-                notif.setUserData(new Object());
-                sendNotification(notif);
-            }
-        }
-
-        /**
-         * Send Notification objects.
-         *
-         * @param nb The number of notifications to send
-         */
-        public void sendNotifications(Integer nb) {
-            Notification notif;
-            for (int i=1; i<=nb.intValue(); i++) {
-                notif = new Notification(myType, this, i);
-
-                sendNotification(notif);
-            }
-        }
-
-        private final String myType = "notification.my_notification";
-    }
-
-    public interface NotificationEmitterMBean {
-        public void sendNotifications(Integer nb);
-
-        public void sendNotserializableNotifs(Integer nb);
-    }
-}
--- a/test/javax/management/eventService/PublishTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.*;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- *
- */
-public class PublishTest {
-    private static MBeanServer mbeanServer;
-    private static EventManager eventManager;
-    private static ObjectName emitter;
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-    private static JMXConnector conn;
-    private static MBeanServerConnection client;
-
-    /**
-     * @param args the command line arguments
-     */
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> PublishTest-main basic tests ...");
-        mbeanServer = MBeanServerFactory.createMBeanServer();
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-        }
-
-        eventManager = EventManager.getEventManager(mbeanServer);
-
-        emitter = new ObjectName("Default:name=NotificationEmitter");
-
-        url = new JMXServiceURL("rmi", null, 0) ;
-        server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
-        server.start();
-
-        url = server.getAddress();
-        conn = JMXConnectorFactory.connect(url, null);
-        client = conn.getMBeanServerConnection();
-
-        boolean succeed;
-
-        System.out.println(">>> PublishTest-main: using the fetching EventRelay...");
-        succeed = test(new EventClient(client));
-
-        System.out.println(">>> PublishTest-main: using the pushing EventRelay...");
-        succeed &= test(new EventClient(client,
-                new RMIPushEventRelay(EventClientDelegate.getProxy(client)),
-                null,
-                EventClient.DEFAULT_LEASE_TIMEOUT));
-
-        conn.close();
-        server.stop();
-
-        if (succeed) {
-            System.out.println(">>> PublishTest-main: PASSE!");
-        } else {
-            System.out.println("\n>>> PublishTest-main: FAILED!");
-            System.exit(1);
-        }
-    }
-
-    public static boolean test(EventClient efClient) throws Exception {
-        // add listener from the client side
-        Listener listener = new Listener();
-        efClient.subscribe(emitter, listener, null, null);
-
-        ObjectName other = new ObjectName("Default:name=other");
-        // publish notifs
-        for (int i=0; i<sendNB; i++) {
-            Notification notif = new Notification(myType, emitter, count++);
-            Notification notif2 = new Notification(myType, other, 0);
-            //System.out.println(">>> EventManagerService-NotificationEmitter-sendNotifications: "+i);
-
-            eventManager.publish(emitter, notif);
-            eventManager.publish(other, notif2); // should not received
-        }
-
-        // waiting
-        long toWait = 6000;
-        long stopTime = System.currentTimeMillis() + toWait;
-
-        synchronized(listener) {
-            while(listener.received < sendNB && toWait > 0) {
-                listener.wait(toWait);
-                toWait = stopTime - System.currentTimeMillis();
-            }
-        }
-
-        // clean
-        efClient.unsubscribe(emitter, listener);
-        efClient.close();
-
-        if (listener.received != sendNB) {
-            System.out.println(">>> PublishTest-test: FAILED! Expected to receive "+sendNB+", but got "+listener.received);
-
-            return false;
-        } else if (listener.seqErr > 0) {
-            System.out.println(">>> PublishTest-test: FAILED! The receiving sequence is not correct.");
-
-            return false;
-        } else {
-            System.out.println(">>> PublishTest-test: got all expected "+listener.received);
-            return true;
-        }
-    }
-
-    private static class Listener implements NotificationListener {
-        public int received = 0;
-        public int seqErr = 0;
-
-        private long lastSeq = -1;
-
-        public void handleNotification(Notification notif, Object handback) {
-            if (!myType.equals(notif.getType())) {
-                System.out.println(">>> PublishTest-Listener: got unexpected notif: "+notif);
-                System.exit(1);
-            } else if (!emitter.equals(notif.getSource())) {
-                System.out.println(">>> PublishTest-Listener: unknown ObjectName: "+notif.getSource());
-                System.exit(1);
-            }
-
-            if (lastSeq == -1) {
-                lastSeq = notif.getSequenceNumber();
-            } else if (notif.getSequenceNumber() - lastSeq++ != 1) {
-                seqErr++;
-            }
-
-            System.out.println(">>> PublishTest-Listener: got notif "+notif.getSequenceNumber());
-
-            synchronized(this) {
-                if (++received >= sendNB) {
-                    this.notify();
-                }
-            }
-
-            System.out.println(">>> PublishTest-Listener: received = "+received);
-        }
-    }
-
-    private static int sendNB = 20;
-    private static long count = 0;
-
-    private static final String myType = "notification.my_notification";
-}
--- a/test/javax/management/eventService/ReconnectableConnectorTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,488 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 ReconnectableJMXConnector
- * @bug 5108776
- * @summary Check that the Event Service can be used to build a
- * ReconnectableJMXConnector.
- * @author Eamonn McManus
- */
-
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Date;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReentrantLock;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.remote.JMXConnectionNotification;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.security.auth.Subject;
-
-/*
- * This test checks that it is possible to use the Event Service to create
- * a "reconnectable connector".
- *
- * In the JMX Remote API, we deliberately specified that a connector client
- * (JMXConnector) that encounters a network failure is then permanently broken.
- * The idea being that adding recovery logic to the basic connector client
- * would make it much more complicated and less reliable, and the logic would
- * in any case never correspond to what a given situation needs. Some of
- * the tough questions are: Should the connector try to mask the failure by
- * blocking operations until the failure is resolved? How long should the
- * connector try to reestablish the connection before giving up? Rather than
- * try to solve this problem in the connector, we suggested that people who
- * wanted to recover from network failures could implement the JMXConnector
- * interface themselves so that it forwards to a wrapped JMXConnector that can
- * be replaced in case of network failure.
- *
- * This works fine except that the connector client has state,
- * in the form of listeners added by the user through the
- * MBeanServerConnection.addNotificationListener method. It's possible
- * for the wrapper to keep track of these listeners as well as forwarding
- * them to the wrapped JMXConnector, so that it can reapply them to
- * a replacement JMXConnector after failure recover. But it's quite
- * tricky, particularly because of the two- and four-argument versions of
- * removeNotificationListener.
- *
- * The Event Service can take care of this for you through the EventClient
- * class. Listeners added through that class are implemented in a way that
- * doesn't require the connector client to maintain any state, so they should
- * continue to work transparently after replacing the wrapped JMXConnector.
- * This test is a proof of concept that shows it works.  Quite a number of
- * details would need to be changed to build a reliable reconnectable
- * connector.
- *
- * The test simulates network failure by rewrapping the wrapped JMXConnector's
- * MBeanServerConnection (MBSC) in a "breakable" MBSC which we can cause
- * to stop working.  We do this in two phases.  The first phase suspends
- * any MBSC calls just at the point where they would return to the caller.
- * The goal here is to block an EventClientDelegateMBean.fetchNotifications
- * operation when it has received notifications but not yet delivered them
- * to the EventClient.  This is the most delicate point where a breakage
- * can occur, because the EventClientDelegate must not drop those notifs
- * from its buffer until another fetchNotifs call arrives with a later
- * sequence number (which is an implicit ack of the previous set of
- * notifs).  Once the fetchNotifs call is suspended, we "kill" the MBSC,
- * causing it to throw IOException from this and any other calls.  That
- * triggers the reconnect logic, which will make a new MBSC and issue
- * the same fetchNotifs call to it.
- *
- * The test could be improved by synchronizing explicitly between the
- * breakable MBSC and the mainline, so we only proceed to kill the MBSC
- * when we are sure that the fetchNotifs call is blocked.  As it is,
- * we have a small delay which both ensures that no notifs are delivered
- * while the connection is suspended, and if the machine is fast enough
- * allows the fetchNotifs call to reach the blocking point.
- */
-public class ReconnectableConnectorTest {
-    private static class ReconnectableJMXConnector implements JMXConnector {
-        private final JMXServiceURL url;
-        private AtomicReference<JMXConnector> wrappedJMXC =
-                new AtomicReference<JMXConnector>();
-        private AtomicReference<MBeanServerConnection> wrappedMBSC =
-                new AtomicReference<MBeanServerConnection>();
-        private final NotificationBroadcasterSupport broadcaster =
-                new NotificationBroadcasterSupport();
-        private final Lock connectLock = new ReentrantLock();
-
-        ReconnectableJMXConnector(JMXServiceURL url) {
-            this.url = url;
-        }
-
-        private class ReconnectIH implements InvocationHandler {
-            public Object invoke(Object proxy, Method method, Object[] args)
-                    throws Throwable {
-                try {
-                    return method.invoke(wrappedMBSC.get(), args);
-                } catch (InvocationTargetException e) {
-                    if (e.getCause() instanceof IOException) {
-                        connect();
-                        try {
-                            return method.invoke(wrappedMBSC.get(),args);
-                        } catch (InvocationTargetException ee) {
-                            throw ee.getCause();
-                        }
-                    }
-                    throw e.getCause();
-                }
-            }
-        }
-
-        private class FailureListener implements NotificationListener {
-            public void handleNotification(Notification n, Object h) {
-                String type = n.getType();
-                if (type.equals(JMXConnectionNotification.FAILED)) {
-                    try {
-                        connect();
-                    } catch (IOException e) {
-                        broadcaster.sendNotification(n);
-                    }
-                } else if (type.equals(JMXConnectionNotification.NOTIFS_LOST))
-                    broadcaster.sendNotification(n);
-            }
-        }
-
-        public void connect() throws IOException {
-            connectLock.lock();
-            try {
-                connectWithLock();
-            } finally {
-                connectLock.unlock();
-            }
-        }
-
-        private void connectWithLock() throws IOException {
-            MBeanServerConnection mbsc = wrappedMBSC.get();
-            if (mbsc != null) {
-                try {
-                    mbsc.getDefaultDomain();
-                    return;  // the connection works
-                } catch (IOException e) {
-                    // OK: the connection doesn't work, so make a new one
-                }
-            }
-            // This is where we would need to add the fancy logic that
-            // allows the connection to keep failing for a while
-            // before giving up.
-            JMXConnector jmxc = JMXConnectorFactory.connect(url);
-            jmxc.addConnectionNotificationListener(
-                    new FailureListener(), null, null);
-            wrappedJMXC.set(jmxc);
-            if (false)
-                wrappedMBSC.set(jmxc.getMBeanServerConnection());
-            else {
-                mbsc = jmxc.getMBeanServerConnection();
-                InvocationHandler ih = new BreakableIH(mbsc);
-                mbsc = (MBeanServerConnection) Proxy.newProxyInstance(
-                        MBeanServerConnection.class.getClassLoader(),
-                        new Class<?>[] {MBeanServerConnection.class},
-                        ih);
-                wrappedMBSC.set(mbsc);
-            }
-        }
-
-        private BreakableIH breakableIH() {
-            MBeanServerConnection mbsc = wrappedMBSC.get();
-            return (BreakableIH) Proxy.getInvocationHandler(mbsc);
-        }
-
-        void suspend() {
-            BreakableIH ih = breakableIH();
-            ih.suspend();
-        }
-
-        void kill() throws IOException {
-            BreakableIH ih = breakableIH();
-            wrappedJMXC.get().close();
-            ih.kill();
-        }
-
-        public void connect(Map<String, ?> env) throws IOException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        private final AtomicReference<MBeanServerConnection> mbscRef =
-                new AtomicReference<MBeanServerConnection>();
-
-        public MBeanServerConnection getMBeanServerConnection()
-                throws IOException {
-            connect();
-            // Synchro here is not strictly correct: two threads could make
-            // an MBSC at the same time.  OK for a test but beware for real
-            // code.
-            MBeanServerConnection mbsc = mbscRef.get();
-            if (mbsc != null)
-                return mbsc;
-            mbsc = (MBeanServerConnection) Proxy.newProxyInstance(
-                    MBeanServerConnection.class.getClassLoader(),
-                    new Class<?>[] {MBeanServerConnection.class},
-                    new ReconnectIH());
-            mbsc = EventClient.getEventClientConnection(mbsc);
-            mbscRef.set(mbsc);
-            return mbsc;
-        }
-
-        public MBeanServerConnection getMBeanServerConnection(
-                Subject delegationSubject) throws IOException {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void close() throws IOException {
-            wrappedJMXC.get().close();
-        }
-
-        public void addConnectionNotificationListener(
-                NotificationListener l, NotificationFilter f, Object h) {
-            broadcaster.addNotificationListener(l, f, h);
-        }
-
-        public void removeConnectionNotificationListener(NotificationListener l)
-                throws ListenerNotFoundException {
-            broadcaster.removeNotificationListener(l);
-        }
-
-        public void removeConnectionNotificationListener(
-                NotificationListener l, NotificationFilter f, Object h)
-                throws ListenerNotFoundException {
-            broadcaster.removeNotificationListener(l, f, h);
-        }
-
-        public String getConnectionId() throws IOException {
-            return wrappedJMXC.get().getConnectionId();
-        }
-    }
-
-    // InvocationHandler that allows us to perform a two-phase "break" of
-    // an object.  The first phase suspends the object, so that calls to
-    // it are blocked just before they return.  The second phase unblocks
-    // suspended threads and causes them to throw IOException.
-    private static class BreakableIH implements InvocationHandler {
-        private final Object wrapped;
-        private final Holder<String> state = new Holder<String>("running");
-
-        BreakableIH(Object wrapped) {
-            this.wrapped = wrapped;
-        }
-
-        void suspend() {
-            state.set("suspended");
-        }
-
-        void kill() {
-            state.set("killed");
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-                throws Throwable {
-            Object result;
-            try {
-                result = method.invoke(wrapped, args);
-            } catch (InvocationTargetException e) {
-                throw e.getCause();
-            }
-            String s = state.get();
-            if (s.equals("suspended"))
-                state.waitUntilEqual("killed", 3, TimeUnit.SECONDS);
-            else if (s.equals("killed"))
-                throw new IOException("Broken");
-            return result;
-        }
-    }
-
-    private static class Holder<T> {
-        private T held;
-        private Lock lock = new ReentrantLock();
-        private Condition changed = lock.newCondition();
-
-        Holder(T value) {
-            lock.lock();
-            this.held = value;
-            lock.unlock();
-        }
-
-        void waitUntilEqual(T value, long timeout, TimeUnit units)
-                throws InterruptedException {
-            long millis = units.toMillis(timeout);
-            long stop = System.currentTimeMillis() + millis;
-            Date stopDate = new Date(stop);
-            lock.lock();
-            try {
-                while (!value.equals(held)) {
-                    boolean ok = changed.awaitUntil(stopDate);
-                    if (!ok)
-                        throw new InterruptedException("Timed out");
-                }
-            } finally {
-                lock.unlock();
-            }
-        }
-
-        void set(T value) {
-            lock.lock();
-            try {
-                held = value;
-                changed.signalAll();
-            } finally {
-                lock.unlock();
-            }
-        }
-
-        T get() {
-            lock.lock();
-            try {
-                return held;
-            } finally {
-                lock.unlock();
-            }
-        }
-    }
-
-    private static class StoreListener implements NotificationListener {
-        final BlockingQueue<Notification> queue =
-                new ArrayBlockingQueue<Notification>(100);
-
-        public void handleNotification(Notification n, Object h) {
-            queue.add(n);
-        }
-
-        Notification nextNotification(long time, TimeUnit units)
-                throws InterruptedException {
-            Notification n = queue.poll(time, units);
-            if (n == null)
-                throw new NoSuchElementException("Notification wait timed out");
-            return n;
-        }
-
-        int notifCount() {
-            return queue.size();
-        }
-    }
-
-    public static interface SenderMBean {}
-    public static class Sender
-            extends NotificationBroadcasterSupport implements SenderMBean {
-        private AtomicLong seqNo = new AtomicLong(0);
-
-        void send() {
-            Notification n =
-                    new Notification("type", this, seqNo.getAndIncrement());
-            sendNotification(n);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        Sender sender = new Sender();
-        ObjectName name = new ObjectName("a:b=c");
-        mbs.registerMBean(sender, name);
-
-        System.out.println("Creating connector server");
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
-        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
-                url, null, mbs);
-        cs.start();
-
-        StoreListener csListener = new StoreListener();
-        cs.addNotificationListener(csListener, null, null);
-
-        System.out.println("Creating reconnectable client");
-        JMXServiceURL addr = cs.getAddress();
-        ReconnectableJMXConnector cc = new ReconnectableJMXConnector(addr);
-        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-
-        System.out.println("Checking server has sent new-client notif");
-        Notification csn = csListener.nextNotification(1, TimeUnit.SECONDS);
-        assertEquals("CS notif type",
-                JMXConnectionNotification.OPENED, csn.getType());
-
-        StoreListener listener = new StoreListener();
-        mbsc.addNotificationListener(name, listener, null, null);
-
-        System.out.println("Sending 10 notifs and checking they are received");
-        for (int i = 0; i < 10; i++)
-            sender.send();
-        checkNotifs(listener, 0, 10);
-
-        System.out.println("Suspending the fetchNotifs operation");
-        cc.suspend();
-        System.out.println("Sending a notif while fetchNotifs is suspended");
-        sender.send();
-        System.out.println("Brief wait before checking no notif is received");
-        Thread.sleep(2);
-        // dumpThreads();
-        assertEquals("notif queue while connector suspended",
-                0, listener.notifCount());
-        assertEquals("connector server notif queue while connector suspended",
-                0, csListener.notifCount());
-
-        System.out.println("Breaking the connection so fetchNotifs will fail over");
-        cc.kill();
-
-        System.out.println("Checking that client has reconnected");
-        csn = csListener.nextNotification(1, TimeUnit.SECONDS);
-        assertEquals("First CS notif type after kill",
-                JMXConnectionNotification.CLOSED, csn.getType());
-        csn = csListener.nextNotification(1, TimeUnit.SECONDS);
-        assertEquals("Second CS notif type after kill",
-                JMXConnectionNotification.OPENED, csn.getType());
-
-        System.out.println("Checking that suspended notif has been received");
-        checkNotifs(listener, 10, 11);
-    }
-
-    private static void checkNotifs(
-             StoreListener sl, long start, long stop)
-            throws Exception {
-        for (long i = start; i < stop; i++) {
-            Notification n = sl.nextNotification(1, TimeUnit.SECONDS);
-            assertEquals("received sequence number", i, n.getSequenceNumber());
-        }
-    }
-
-    private static void assertEquals(String what, Object expect, Object actual)
-    throws Exception {
-        if (!expect.equals(actual)) {
-            fail(what + " should be " + expect + " but is " + actual);
-        }
-    }
-
-    private static void fail(String why) throws Exception {
-        throw new Exception("TEST FAILED: " + why);
-    }
-
-    private static void dumpThreads() {
-        System.out.println("Thread stack dump");
-        Map<Thread, StackTraceElement[]> traces = Thread.getAllStackTraces();
-        for (Map.Entry<Thread, StackTraceElement[]> entry : traces.entrySet()) {
-            Thread t = entry.getKey();
-            System.out.println("===Thread " + t.getName() + "===");
-            for (StackTraceElement ste : entry.getValue())
-                System.out.println("    " + ste);
-        }
-    }
-}
--- a/test/javax/management/eventService/SharingThreadTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 SharingThreadTest.java 1.3 08/01/22
- * @bug 5108776
- * @summary Basic test for EventClient to see internal thread management.
- * @author Shanliang JIANG
- * @run clean SharingThreadTest
- * @run build SharingThreadTest
- * @run main SharingThreadTest
- */
-
-import java.io.IOException;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventClient;
-import javax.management.event.EventClientDelegate;
-import javax.management.event.EventClientDelegateMBean;
-import javax.management.event.FetchingEventRelay;
-import javax.management.event.RMIPushEventRelay;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-
-public class SharingThreadTest {
-
-    private static MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
-    private static ObjectName emitter;
-    private static NotificationEmitter emitterImpl;
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-
-
-    private static int toSend = 10;
-    private static final long bigWaiting = 6000;
-    private static int counter = 0;
-    private static int jobs = 10;
-    private static int endedJobs = 0;
-
-    private static volatile String failure;
-
-    private static Executor sharedExecutor = new ThreadPoolExecutor(0, 1, 1000,
-            TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(jobs));
-            //Executors.newFixedThreadPool(1);
-
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> Test on sharing threads for multiple EventClient.");
-
-        // for 1.5
-        if (System.getProperty("java.version").startsWith("1.5") &&
-                !mbeanServer.isRegistered(EventClientDelegateMBean.OBJECT_NAME)) {
-            System.out.print("Working on "+System.getProperty("java.version")+
-                    " register "+EventClientDelegateMBean.OBJECT_NAME);
-
-            mbeanServer.registerMBean(EventClientDelegate.
-                    getEventClientDelegate(mbeanServer),
-                    EventClientDelegateMBean.OBJECT_NAME);
-
-            sharedExecutor = new ThreadPoolExecutor(1, 1, 1000,
-            TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(jobs));
-        }
-
-        emitter = new ObjectName("Default:name=NotificationEmitter");
-        emitterImpl = new NotificationEmitter();
-        mbeanServer.registerMBean(emitterImpl, emitter);
-
-        String[] types = new String[]{"PushEventRelay", "FetchingEventRelay"};
-        String[] protos = new String[]{"rmi", "iiop", "jmxmp"};
-        for (String prot : protos) {
-            url = new JMXServiceURL(prot, null, 0);
-
-            try {
-                server =
-                        JMXConnectorServerFactory.newJMXConnectorServer(url,
-                        null, mbeanServer);
-                server.start();
-            } catch (Exception e) {
-                System.out.println(">>> Skip "+prot+", not support.");
-                continue;
-            }
-
-            url = server.getAddress();
-
-            // noise
-            Thread noise = new Thread(new Runnable() {
-                public void run() {
-                    while (true) {
-                        emitterImpl.sendNotif(1, null);
-                        try {
-                            Thread.sleep(10);
-                        } catch (Exception e) {
-                            // OK
-                        }
-                    }
-                }
-            });
-            noise.setDaemon(true);
-            noise.start();
-
-            try {
-                for (String type: types) {
-                    System.out.println("\n\n>>> Testing "+type+" on "+url+" ...");
-                    JMXConnector conn = newConn();
-                    try {
-                        testType(type, conn);
-                    } finally {
-                        conn.close();
-                        System.out.println(">>> Testing "+type+" on "+url+" ... done");
-                    }
-                }
-            } finally {
-                server.stop();
-            }
-        }
-    }
-
-    private static void testType(String type, JMXConnector conn) throws Exception {
-        Thread[] threads = new Thread[jobs];
-        for (int i=0; i<jobs; i++) {
-            threads[i] = new Thread(new Job(type, conn));
-            threads[i].setDaemon(true);
-            threads[i].start();
-        }
-
-        // to wait
-        long toWait = bigWaiting*jobs;
-        long stopTime = System.currentTimeMillis() + toWait;
-
-        synchronized(SharingThreadTest.class) {
-            while (endedJobs < jobs && toWait > 0 && failure == null) {
-                SharingThreadTest.class.wait(toWait);
-                toWait = stopTime - System.currentTimeMillis();
-            }
-        }
-
-        if (endedJobs != jobs && failure == null) {
-            throw new RuntimeException("Need to set bigger waiting timeout?");
-        }
-
-        endedJobs = 0;
-    }
-
-    public static class Job implements Runnable {
-        public Job(String type, JMXConnector conn) {
-            this.type = type;
-            this.conn = conn;
-        }
-        public void run() {
-            try {
-                test(type, conn);
-
-                synchronized(SharingThreadTest.class) {
-                    endedJobs++;
-                    if (endedJobs>=jobs) {
-                        SharingThreadTest.class.notify();
-                    }
-                }
-            } catch (RuntimeException re) {
-                re.printStackTrace(System.out);
-                throw re;
-            } catch (Exception e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        private final String type;
-        private final JMXConnector conn;
-    }
-
-    private static void test(String type, JMXConnector conn) throws Exception {
-        String id = getId();
-
-        Listener listener = new Listener(id);
-        Filter filter = new Filter(id);
-
-        //newConn();
-        EventClient ec = newEventClient(type, conn);
-
-        System.out.println(">>> ("+id+") To receive notifications "+toSend);
-        ec.addNotificationListener(emitter,
-                listener, filter, null);
-
-        emitterImpl.sendNotif(toSend, id);
-        listener.waitNotifs(bigWaiting, toSend);
-        if (listener.received != toSend) {
-            throw new RuntimeException(">>> ("+id+") Expected to receive: "
-                    +toSend+", but got: "+listener.received);
-        }
-
-        ec.close();
-    }
-
-//--------------------------
-// private classes
-//--------------------------
-
-    private static class Listener implements NotificationListener {
-        public Listener(String id) {
-            this.id = id;
-        }
-        public void handleNotification(Notification notif, Object handback) {
-            if (!id.equals(notif.getUserData())) {
-                System.out.println("("+id+") Filter error, my id is: "+id+
-                        ", but got "+notif.getUserData());
-                System.exit(1);
-            }
-            System.out.println("("+id+") received "+notif.getSequenceNumber());
-            synchronized (this) {
-                received++;
-
-                if (sequenceNB < 0) {
-                    sequenceNB = notif.getSequenceNumber();
-                } else if(++sequenceNB != notif.getSequenceNumber()) {
-                    fail("(" + id + ") Wrong sequence number, expected: "
-                            +sequenceNB+", but got: "+notif.getSequenceNumber());
-                }
-                if (received >= toSend || failure != null) {
-                    this.notify();
-                }
-            }
-        }
-
-        public void waitNotifs(long timeout, int nb) throws Exception {
-            long toWait = timeout;
-            long stopTime = System.currentTimeMillis() + timeout;
-            synchronized(this) {
-                while (received < nb && toWait > 0 && failure == null) {
-                    this.wait(toWait);
-                    toWait = stopTime - System.currentTimeMillis();
-                }
-            }
-        }
-
-        private String id;
-        private int received = 0;
-
-        private long sequenceNB = -1;
-    }
-
-    private static class Filter implements NotificationFilter {
-        public Filter(String id) {
-            this.id = id;
-        }
-
-        public boolean isNotificationEnabled(Notification n) {
-            return id.equals(n.getUserData());
-        }
-        private String id;
-    }
-
-    public static class NotificationEmitter extends NotificationBroadcasterSupport
-            implements NotificationEmitterMBean {
-
-        /**
-         * Send Notification objects.
-         *
-         * @param nb The number of notifications to send
-         */
-        public void sendNotif(int nb, String userData) {
-            new Thread(new SendJob(nb, userData)).start();
-        }
-
-        private class SendJob implements Runnable {
-            public SendJob(int nb, String userData) {
-                this.nb = nb;
-                this.userData = userData;
-            }
-
-            public void run() {
-                if (userData != null) {
-                    System.out.println(">>> ("+userData+") sending "+nb);
-                }
-                long sequenceNumber = 0;
-                for (int i = 0; i<nb; i++) {
-                    Notification notif = new Notification(myType, emitter,
-                            sequenceNumber++);
-                    notif.setUserData(userData);
-                    sendNotification(notif);
-                    Thread.yield();
-                    try {
-                        Thread.sleep(1);
-                    } catch (Exception e) {}
-                }
-                if (userData != null) {
-                    System.out.println(">>> ("+userData+") sending done");
-                }
-            }
-            private int nb;
-            private String userData;
-        }
-        private final String myType = "notification.my_notification";
-    }
-
-    public interface NotificationEmitterMBean {
-        public void sendNotif(int nb, String userData);
-    }
-
-    private static JMXConnector newConn() throws IOException {
-        return JMXConnectorFactory.connect(url);
-    }
-
-    private static EventClient newEventClient(String type, JMXConnector conn)
-            throws Exception {
-        EventClientDelegateMBean proxy =
-                EventClientDelegate.getProxy(conn.getMBeanServerConnection());
-        if (type.equals("PushEventRelay")) {
-            return new EventClient(proxy,
-                    new RMIPushEventRelay(proxy), sharedExecutor, null, 600);
-        } else if (type.equals("FetchingEventRelay")) {
-            return new EventClient(proxy,
-                    new FetchingEventRelay(proxy,
-                    FetchingEventRelay.DEFAULT_BUFFER_SIZE,
-                    10,
-                    FetchingEventRelay.DEFAULT_MAX_NOTIFICATIONS,
-                    sharedExecutor),
-                    null, null, 600);
-        } else {
-            throw new RuntimeException("Wrong event client type: "+type);
-        }
-    }
-
-    private static String getId() {
-        synchronized(SharingThreadTest.class) {
-            return String.valueOf(counter++);
-        }
-    }
-
-    private static void fail(String msg) {
-        System.out.println("FAIL: " + msg);
-        failure = msg;
-    }
-}
--- a/test/javax/management/eventService/SubUnsubTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * 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 SubUnsubTest
- * @bug 6736611
- * @summary Test not to remove other listeners when calling unsubscribe
- * @author Shanliang JIANG
- * @run clean SubUnsubTest
- * @run build SubUnsubTest
- * @run main SubUnsubTest
- */
-
-import java.lang.management.ManagementFactory;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventSubscriber;
-import javax.management.event.EventClient;
-public class SubUnsubTest {
-    private static class CountListener implements NotificationListener {
-        volatile int count;
-
-        public void handleNotification(Notification n, Object h) {
-            count++;
-        }
-    }
-
-    public static interface SenderMBean {}
-
-    public static class Sender extends NotificationBroadcasterSupport
-            implements SenderMBean {
-        void send() {
-            Notification n = new Notification("type", this, 1L);
-            sendNotification(n);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        System.out.println("Testing EventSubscriber-unsubscribe method.");
-
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        ObjectName name1 = new ObjectName("d:type=Sender,id=1");
-        ObjectName name2 = new ObjectName("d:type=Sender,id=2");
-        ObjectName pattern = new ObjectName("d:type=Sender,*");
-        Sender sender1 = new Sender();
-        Sender sender2 = new Sender();
-        mbs.registerMBean(sender1, name1);
-        mbs.registerMBean(sender2, name2);
-
-        EventSubscriber sub = EventSubscriber.getEventSubscriber(mbs);
-
-        System.out.println("Single subscribe covering both MBeans");
-        CountListener listener = new CountListener();
-
-        System.out.println("Subscribing and adding listeners ...");
-        sub.subscribe(pattern, listener, null, null);
-        sub.subscribe(name2, listener, null, null);
-        mbs.addNotificationListener(name2, listener, null, null);
-
-        sender1.send();
-        sender2.send();
-        if (listener.count != 4) {
-            throw new RuntimeException("Do not receive all notifications: "+
-                    "Expect 4, got "+listener.count);
-        }
-
-        System.out.println("Unsubscribe the listener with the pattern.");
-        sub.unsubscribe(pattern, listener);
-        listener.count = 0;
-        sender1.send();
-        sender2.send();
-        if (listener.count != 2) {
-            throw new RuntimeException("The method unsubscribe removes wrong listeners.");
-        }
-
-        System.out.println("Unsubscribe the listener with the ObjectName.");
-        sub.unsubscribe(name2, listener);
-        listener.count = 0;
-        sender1.send();
-        sender2.send();
-        if (listener.count != 1) {
-            throw new RuntimeException("The method unsubscribe removes wrong listeners.");
-        }
-
-        System.out.println("Subscribe twice to same MBean with same listener " +
-                "but different handback.");
-        sub.subscribe(name1, listener, null, new Object());
-        sub.subscribe(name1, listener, null, new Object());
-        listener.count = 0;
-
-        sub.unsubscribe(name1, listener);
-        sender1.send();
-        if (listener.count > 0) {
-            throw new RuntimeException("EventSubscriber: the method unsubscribe" +
-                    " does not remove a listener which was subscribed 2 times.");
-        }
-
-        System.out.println("Bye bye!");
-        return;
-    }
-}
\ No newline at end of file
--- a/test/javax/management/eventService/SubscribeTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
- * 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 5108776
- * @summary Test that EventSubscriber.subscribe works
- * @author Eamonn McManus
- */
-
-import java.lang.management.ManagementFactory;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventSubscriber;
-
-public class SubscribeTest {
-    private static class CountListener implements NotificationListener {
-        volatile int count;
-
-        public void handleNotification(Notification n, Object h) {
-            count++;
-        }
-    }
-
-    private static class SwitchFilter implements NotificationFilter {
-        volatile boolean enabled;
-
-        public boolean isNotificationEnabled(Notification n) {
-            return enabled;
-        }
-    }
-
-    public static interface SenderMBean {}
-
-    public static class Sender extends NotificationBroadcasterSupport
-            implements SenderMBean {
-        void send() {
-            Notification n = new Notification("type", this, 1L);
-            sendNotification(n);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        ObjectName name1 = new ObjectName("d:type=Sender,id=1");
-        ObjectName name2 = new ObjectName("d:type=Sender,id=2");
-        ObjectName pattern = new ObjectName("d:type=Sender,*");
-        Sender sender1 = new Sender();
-        Sender sender2 = new Sender();
-        mbs.registerMBean(sender1, name1);
-        mbs.registerMBean(sender2, name2);
-
-        EventSubscriber sub = EventSubscriber.getEventSubscriber(mbs);
-
-        System.out.println("Single subscribe covering both MBeans");
-        CountListener listen1 = new CountListener();
-        sub.subscribe(pattern, listen1, null, null);
-        sender1.send();
-        assertEquals("Notifs after sender1 send", 1, listen1.count);
-        sender2.send();
-        assertEquals("Notifs after sender2 send", 2, listen1.count);
-
-        System.out.println("Unsubscribe");
-        sub.unsubscribe(pattern, listen1);
-        sender1.send();
-        assertEquals("Notifs after sender1 send", 2, listen1.count);
-
-        System.out.println("Subscribe twice to same MBean with same listener " +
-                "but different filters");
-        SwitchFilter filter1 = new SwitchFilter();
-        sub.subscribe(name1, listen1, null, null);
-        sub.subscribe(name1, listen1, filter1, null);
-        listen1.count = 0;
-        sender1.send();
-        // switch is off, so only one notif expected
-        assertEquals("Notifs after sender1 send", 1, listen1.count);
-        filter1.enabled = true;
-        sender1.send();
-        // switch is on, so two more notifs expected
-        assertEquals("Notifs after sender1 send", 3, listen1.count);
-
-        System.out.println("Remove those subscriptions");
-        sub.unsubscribe(name1, listen1);
-        sender1.send();
-        assertEquals("Notifs after sender1 send", 3, listen1.count);
-    }
-
-    private static void assertEquals(String what, Object expected, Object actual)
-    throws Exception {
-        if (!equal(expected, actual)) {
-            String msg = "Expected " + expected + "; got " + actual;
-            throw new Exception("TEST FAILED: " + what + ": " + msg);
-        }
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null)
-            return false;
-        return (x.equals(y));
-    }
-}
--- a/test/javax/management/eventService/UsingEventService.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * 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 UsingEventService.java 1.10 08/01/22
- * @bug 5108776
- * @summary Basic test for EventManager.
- * @author Shanliang JIANG
- * @run clean UsingEventService
- * @run build UsingEventService
- * @run main UsingEventService
- */
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.event.EventConsumer;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class UsingEventService {
-    private static JMXServiceURL url;
-    private static JMXConnectorServer server;
-    private static JMXConnector conn;
-    private static MBeanServerConnection client;
-
-    public static void main(String[] args) throws Exception {
-        if (System.getProperty("java.version").startsWith("1.5")) {
-            System.out.println(">>> UsingEventService-main not available for JDK1.5, bye");
-            return;
-        }
-
-        ObjectName oname = new ObjectName("test:t=t");
-        Notification n = new Notification("", oname, 0);
-
-        System.out.println(">>> UsingEventService-main basic tests ...");
-        MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer();
-
-        url = new JMXServiceURL("rmi", null, 0) ;
-        JMXConnectorServer server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
-        server.start();
-        url = server.getAddress();
-
-        System.out.println(">>> UsingEventService-main test to not use the event service...");
-        conn = JMXConnectorFactory.connect(url, null);
-        client = conn.getMBeanServerConnection();
-
-        System.out.println(">>> UsingEventService-main test to use the event service...");
-        Map env = new HashMap(1);
-        env.put("jmx.remote.use.event.service", "true");
-        conn = JMXConnectorFactory.connect(url, env);
-        client = conn.getMBeanServerConnection();
-
-        ((EventConsumer)client).subscribe(oname, listener, null, null);
-
-        System.out.println(">>> UsingEventService-main using event service as expected!");
-
-        System.out.println(">>> UsingEventService-main test to use" +
-                " the event service with system property...");
-
-        System.setProperty("jmx.remote.use.event.service", "true");
-        conn = JMXConnectorFactory.connect(url, null);
-        client = conn.getMBeanServerConnection();
-
-        ((EventConsumer)client).subscribe(oname, listener, null, null);
-
-        System.out.println("" +
-                ">>> UsingEventService-main using event service as expected!");
-
-        System.out.println(">>> Happy bye bye!");
-    }
-
-    private final static NotificationListener listener = new NotificationListener() {
-        public void handleNotification(Notification n, Object hk) {
-            //
-        }
-    };
-}
--- a/test/javax/management/interop/MBeanExceptionInteropTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-/*
- * 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 6456269
- * @summary Test that an MBeanException serialized on JDK 6 deserializes
- * correctly on JDK 7.
- * @author Eamonn McManus
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import javax.management.MBeanException;
-
-// In JDK 6, the Throwable.cause field was always null for an MBeanException,
-// but it didn't matter because we overrode getCause() to return
-// MBeanException.exception instead.  In JDK 7, we no longer override getCause()
-// because MBeanException doubles as the serial form of GenericMBeanException.
-// So we need some care to make sure that objects deserialized from JDK 6
-// have the right getCause() behaviour.
-public class MBeanExceptionInteropTest {
-    private static final byte[] SERIALIZED_MBEAN_EXCEPTION = {
-        -84,-19,0,5,115,114,0,31,106,97,118,97,120,46,109,97,
-        110,97,103,101,109,101,110,116,46,77,66,101,97,110,69,120,
-        99,101,112,116,105,111,110,56,110,-116,-27,110,87,49,-50,2,
-        0,1,76,0,9,101,120,99,101,112,116,105,111,110,116,0,
-        21,76,106,97,118,97,47,108,97,110,103,47,69,120,99,101,
-        112,116,105,111,110,59,120,114,0,28,106,97,118,97,120,46,
-        109,97,110,97,103,101,109,101,110,116,46,74,77,69,120,99,
-        101,112,116,105,111,110,4,-35,76,-20,-109,-99,126,113,2,0,
-        0,120,114,0,19,106,97,118,97,46,108,97,110,103,46,69,
-        120,99,101,112,116,105,111,110,-48,-3,31,62,26,59,28,-60,
-        2,0,0,120,114,0,19,106,97,118,97,46,108,97,110,103,
-        46,84,104,114,111,119,97,98,108,101,-43,-58,53,39,57,119,
-        -72,-53,3,0,3,76,0,5,99,97,117,115,101,116,0,21,
-        76,106,97,118,97,47,108,97,110,103,47,84,104,114,111,119,
-        97,98,108,101,59,76,0,13,100,101,116,97,105,108,77,101,
-        115,115,97,103,101,116,0,18,76,106,97,118,97,47,108,97,
-        110,103,47,83,116,114,105,110,103,59,91,0,10,115,116,97,
-        99,107,84,114,97,99,101,116,0,30,91,76,106,97,118,97,
-        47,108,97,110,103,47,83,116,97,99,107,84,114,97,99,101,
-        69,108,101,109,101,110,116,59,120,112,113,0,126,0,8,116,
-        0,7,79,104,32,100,101,97,114,117,114,0,30,91,76,106,
-        97,118,97,46,108,97,110,103,46,83,116,97,99,107,84,114,
-        97,99,101,69,108,101,109,101,110,116,59,2,70,42,60,60,
-        -3,34,57,2,0,0,120,112,0,0,0,2,115,114,0,27,
-        106,97,118,97,46,108,97,110,103,46,83,116,97,99,107,84,
-        114,97,99,101,69,108,101,109,101,110,116,97,9,-59,-102,38,
-        54,-35,-123,2,0,4,73,0,10,108,105,110,101,78,117,109,
-        98,101,114,76,0,14,100,101,99,108,97,114,105,110,103,67,
-        108,97,115,115,113,0,126,0,6,76,0,8,102,105,108,101,
-        78,97,109,101,113,0,126,0,6,76,0,10,109,101,116,104,
-        111,100,78,97,109,101,113,0,126,0,6,120,112,0,0,0,
-        63,116,0,25,77,66,101,97,110,69,120,99,101,112,116,105,
-        111,110,73,110,116,101,114,111,112,84,101,115,116,116,0,30,
-        77,66,101,97,110,69,120,99,101,112,116,105,111,110,73,110,
-        116,101,114,111,112,84,101,115,116,46,106,97,118,97,116,0,
-        5,119,114,105,116,101,115,113,0,126,0,12,0,0,0,46,
-        113,0,126,0,14,113,0,126,0,15,116,0,4,109,97,105,
-        110,120,115,114,0,34,106,97,118,97,46,108,97,110,103,46,
-        73,108,108,101,103,97,108,65,114,103,117,109,101,110,116,69,
-        120,99,101,112,116,105,111,110,-75,-119,115,-45,125,102,-113,-68,
-        2,0,0,120,114,0,26,106,97,118,97,46,108,97,110,103,
-        46,82,117,110,116,105,109,101,69,120,99,101,112,116,105,111,
-        110,-98,95,6,71,10,52,-125,-27,2,0,0,120,113,0,126,
-        0,3,113,0,126,0,21,116,0,3,66,97,100,117,113,0,
-        126,0,10,0,0,0,2,115,113,0,126,0,12,0,0,0,
-        62,113,0,126,0,14,113,0,126,0,15,113,0,126,0,16,
-        115,113,0,126,0,12,0,0,0,46,113,0,126,0,14,113,
-        0,126,0,15,113,0,126,0,18,120,
-    };
-
-    private static volatile String failure;
-
-    public static void main(String[] args) throws Exception {
-        if (args.length > 0) {
-            if (args[0].equals("write") && args.length == 1) {
-                write();
-                return;
-            } else {
-                System.err.println(
-                        "Usage: java MBeanExceptionInteropTest");
-                System.err.println(
-                        "or:    java MBeanExceptionInteropTest write");
-                System.exit(1);
-            }
-        }
-
-        // Read the serialized object and check it is correct.
-        ByteArrayInputStream bin =
-                new ByteArrayInputStream(SERIALIZED_MBEAN_EXCEPTION);
-        ObjectInputStream oin = new ObjectInputStream(bin);
-        MBeanException mbeanEx = (MBeanException) oin.readObject();
-        assertEquals("MBeanException message", "Oh dear", mbeanEx.getMessage());
-        System.out.println("getCause(): " + mbeanEx.getCause() + "; " +
-                "getTargetException(): " + mbeanEx.getTargetException());
-        for (Throwable t :
-                new Throwable[] {mbeanEx.getCause(), mbeanEx.getTargetException()}) {
-            if (!(t instanceof IllegalArgumentException))
-                fail("Nested exception not an IllegalArgumentException: " + t);
-            else
-                assertEquals("Nested exception message", "Bad", t.getMessage());
-        }
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    // Write a file that can be inserted into this source file as the
-    // contents of the SERIALIZED_MBEAN_EXCEPTION array.  Run this program
-    // on JDK 6 to generate the array, then test on JDK 7.
-    private static void write() throws Exception {
-        Exception wrapped = new IllegalArgumentException("Bad");
-        MBeanException mbeanEx = new MBeanException(wrapped, "Oh dear");
-        ByteArrayOutputStream bout = new ByteArrayOutputStream();
-        ObjectOutputStream oout = new ObjectOutputStream(bout);
-        oout.writeObject(mbeanEx);
-        oout.close();
-        byte[] bytes = bout.toByteArray();
-        for (int i = 0; i < bytes.length; i++) {
-            System.out.printf("%d,", bytes[i]);
-            if (i % 16 == 15)
-                System.out.println();
-        }
-        if (bytes.length % 16 != 0)
-            System.out.println();
-    }
-
-    private static void assertEquals(String what, Object expect, Object actual) {
-        boolean equal = (expect == null) ? (actual == null) : expect.equals(actual);
-        if (equal)
-            System.out.println("OK: " + what + ": " + expect);
-        else
-            fail(what + ": expected " + expect + ", got " + actual);
-    }
-
-    private static void fail(String why) {
-        System.out.println("FAIL: " + why);
-        failure = why;
-    }
-}
--- a/test/javax/management/modelmbean/DefaultDescriptorFieldTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 6252592 4967755
- * @summary Check that default fields are correctly added to Descriptors
- * and that input Descriptors are never modified
- * @author Lars Westergren
- */
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import javax.management.Descriptor;
-import javax.management.IntrospectionException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanConstructorInfo;
-import javax.management.MBeanException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.RuntimeOperationsException;
-import javax.management.modelmbean.DescriptorSupport;
-import javax.management.modelmbean.ModelMBeanAttributeInfo;
-import javax.management.modelmbean.ModelMBeanConstructorInfo;
-import javax.management.modelmbean.ModelMBeanInfo;
-import javax.management.modelmbean.ModelMBeanInfoSupport;
-import javax.management.modelmbean.ModelMBeanNotificationInfo;
-import javax.management.modelmbean.ModelMBeanOperationInfo;
-
-/**
- * Junit tests for bugs:
- * 6252592 Provide for the user mandatory fields missing in Descriptor given
- *         to Model*Info constructors
- * 4967755 ModelMBeanAttributeInfo constructor modifies its Descriptor argument
- *
- * @author Lars Westergren
- */
-public class DefaultDescriptorFieldTest /*extends TestCase*/ {
-    public static void main(String[] args) throws Exception {
-        boolean fail = false;
-        Object test = new DefaultDescriptorFieldTest("Test");
-        for (Method m : DefaultDescriptorFieldTest.class.getMethods()) {
-            if (m.getName().startsWith("test") &&
-                    m.getParameterTypes().length == 0) {
-                System.out.println("Testing " + m.getName());
-                try {
-                    m.invoke(test);
-                } catch (InvocationTargetException e) {
-                    fail = true;
-                    Throwable t = e.getCause();
-                    System.out.println("FAILED: exception: " + t);
-                    t.printStackTrace(System.out);
-                }
-            }
-        }
-        if (fail)
-            throw new Exception("TEST FAILED");
-    }
-
-    //No check WHICH constructor is reflected, at least when the classes tested are constructed,
-    //so I just use first one that came to mind.
-    final Constructor[] constArr = String.class.getConstructors();
-    final Constructor dummyConstructor = constArr[0];
-
-
-    Method getMethod = null;
-
-    /** Creates a new instance of MBeanTest */
-    public DefaultDescriptorFieldTest(final String name) {
-        try {
-            getMethod = String.class.getMethod("toString");
-        } catch (SecurityException ex) {
-            ex.printStackTrace();
-        } catch (NoSuchMethodException ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    /**
-     * Test instantiating the 5 different classes with a null
-     * Descriptor, and also setting a null descriptor after.
-     * Expected: Default Descriptors created.
-     */
-    public void testNullDescriptors()
-    throws IntrospectionException, MBeanException {
-        final ModelMBeanConstructorInfo constInfo =
-                new ModelMBeanConstructorInfo("Dummy", dummyConstructor, null);
-        constInfo.setDescriptor(null);
-        ModelMBeanAttributeInfo attInfo =
-                new ModelMBeanAttributeInfo("dummyAttInfoName", "dummyAttInfoDesc", getMethod, null, null);
-        attInfo.setDescriptor(null);
-        ModelMBeanNotificationInfo notInfo =
-                new ModelMBeanNotificationInfo(null, "notificationClassName", "daName", null);
-        notInfo.setDescriptor(null);
-        ModelMBeanOperationInfo opInfo =
-                new ModelMBeanOperationInfo("test", getMethod, null);
-        opInfo.setDescriptor(null);
-        ModelMBeanInfoSupport infoSupport =
-                new ModelMBeanInfoSupport(new DummyModelMBeanInfo());
-        infoSupport.setDescriptor(null,null);
-        infoSupport.setDescriptor(null, "mbean");
-    }
-
-    /**
-     * Test instantiating and setting a Descriptor without the "name",
-     * "descriptorType" or "role" fields. This also tests whether the
-     * Descriptor is cloned before default values are set, since
-     * default values for one class will be incorrect for the next.
-     * Expected: Descriptor should be cloned, missing default values should be
-     * set
-     */
-    public void testFieldlessDescriptor()
-    throws IntrospectionException, MBeanException {
-        Descriptor theNamelessOne = new DescriptorSupport();
-        final ModelMBeanConstructorInfo constInfo =
-                new ModelMBeanConstructorInfo("Dummy", dummyConstructor, theNamelessOne);
-        constInfo.setDescriptor(theNamelessOne);
-        ModelMBeanAttributeInfo attInfo =
-                new ModelMBeanAttributeInfo("dummyAttInfoName", "dummyAttInfoDesc", getMethod, null, theNamelessOne);
-        attInfo.setDescriptor(theNamelessOne);
-        ModelMBeanNotificationInfo notInfo =
-                new ModelMBeanNotificationInfo(null, "notificationClassName", "daName", theNamelessOne);
-        notInfo.setDescriptor(theNamelessOne);
-        ModelMBeanOperationInfo opInfo =
-                new ModelMBeanOperationInfo("test", getMethod, theNamelessOne);
-        opInfo.setDescriptor(theNamelessOne);
-        ModelMBeanInfoSupport infoSupport = new ModelMBeanInfoSupport(new DummyModelMBeanInfo());
-        infoSupport.setDescriptor(theNamelessOne, null);
-        infoSupport.setDescriptor(theNamelessOne, "mbean");
-    }
-
-
-     /**
-     * Creates an empty DescriptorSupport and then test that ModelMBeanConstructorInfo accepts
-      * the correct fields in validation one by one.
-     */
-    public void testCorrectConstructorDescriptors()
-    throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
-        Descriptor cDesc = new DescriptorSupport(new String[0],new String[0]);
-        final ModelMBeanConstructorInfo constInfo =
-                new ModelMBeanConstructorInfo("Dummy", dummyConstructor, cDesc);
-        assertFalse(fieldRefuted(constInfo, cDesc, "name" , "java.lang.String"));
-        assertFalse(fieldRefuted(constInfo, cDesc, "role" , "constructor"));
-        assertFalse(fieldRefuted(constInfo, cDesc, "descriptorType" , "operation"));
-    }
-
-    /**
-     * Test that ModelMBeanConstructorInfo refutes incorrect fields in validation one by one.
-     */
-    public void testIncorrectConstructorDescriptors()
-    throws NoSuchMethodException, IllegalAccessException {
-        Descriptor cDesc = new DescriptorSupport(
-           new String[] {"getMethod", "setMethod", "role", "Class", "name", "descriptorType"},
-           new String[] {"dummyGetMethod", "dummySetMethod", "constructor", "dummyClass", "java.lang.String", "operation"});
-        final ModelMBeanConstructorInfo constInfo = new ModelMBeanConstructorInfo("Dummy", dummyConstructor, cDesc);
-        assertTrue(fieldRefuted(constInfo, cDesc, "name" , "blah"));
-        assertTrue(fieldRefuted(constInfo, cDesc, "descriptorType", "mbean"));
-        assertTrue(fieldRefuted(constInfo, cDesc, "descriptorType", "notification"));
-        assertTrue(fieldRefuted(constInfo, cDesc, "descriptorType", "constructor"));
-        assertTrue(fieldRefuted(constInfo, cDesc, "role", "operation"));
-    }
-
-    public void testCorrectAttributeDescriptors()
-    throws IntrospectionException, NoSuchMethodException, IllegalAccessException {
-        Descriptor aDesc = new DescriptorSupport(new String[0],new String[0]);
-        final ModelMBeanAttributeInfo attInfo = new ModelMBeanAttributeInfo("dummyAttInfoName", "dummyAttInfoDesc", getMethod, null, null);
-        assertFalse(fieldRefuted(attInfo, aDesc, "name" , "dummyAttInfoName"));
-        assertFalse(fieldRefuted(attInfo, aDesc, "descriptorType" , "attribute"));
-    }
-
-    public void testIncorrectAttributeDescriptors()
-    throws IntrospectionException, NoSuchMethodException, IllegalAccessException {
-        Descriptor aDesc = new DescriptorSupport();
-        final ModelMBeanAttributeInfo attInfo = new ModelMBeanAttributeInfo("dummyAttInfoName", "dummyAttInfoDesc", getMethod, null, null);
-        assertTrue(fieldRefuted(attInfo, aDesc, "name" , "blah"));
-        assertTrue(fieldRefuted(attInfo, aDesc, "descriptorType" , "constructor"));
-        assertTrue(fieldRefuted(attInfo, aDesc, "descriptorType" , "notification"));
-    }
-
-    public void testCorrectNotificationDescriptors()
-    throws NoSuchMethodException, IllegalAccessException  {
-        Descriptor nDesc = new DescriptorSupport();
-        final ModelMBeanNotificationInfo nInfo = new ModelMBeanNotificationInfo(null, "notificationClassName", "daName", nDesc);
-        assertFalse(fieldRefuted(nInfo, nDesc, "name" , "notificationClassName"));
-        assertFalse(fieldRefuted(nInfo, nDesc, "descriptorType" , "notification"));
-    }
-
-    public void testIncorrectNotificationDescriptors()
-    throws NoSuchMethodException, IllegalAccessException {
-        Descriptor nDesc = new DescriptorSupport();
-        final ModelMBeanNotificationInfo nInfo = new ModelMBeanNotificationInfo(null, "notificationClassName", "daName", nDesc);
-        assertTrue(fieldRefuted(nInfo, nDesc, "name" , "blah"));
-        assertTrue(fieldRefuted(nInfo, nDesc, "descriptorType" , "constructor"));
-        assertTrue(fieldRefuted(nInfo, nDesc, "descriptorType" , "operation"));
-    }
-
-    public void testCorrectOperationDescriptors()
-    throws NoSuchMethodException, IllegalAccessException {
-        Descriptor opDesc = new DescriptorSupport();
-        final ModelMBeanOperationInfo opInfo = new ModelMBeanOperationInfo("test", "readable description", null, "type", 1, opDesc);
-        assertFalse(fieldRefuted(opInfo, opDesc, "name" , "test"));
-        assertFalse(fieldRefuted(opInfo, opDesc, "descriptorType" , "operation"));
-        assertFalse(fieldRefuted(opInfo, opDesc, "role" , "operation"));
-        assertFalse(fieldRefuted(opInfo, opDesc, "role" , "getter"));
-        assertFalse(fieldRefuted(opInfo, opDesc, "role" , "setter"));
-    }
-
-    public void testIncorrectOperationDescriptors()
-    throws NoSuchMethodException, IllegalAccessException {
-        Descriptor opDesc = new DescriptorSupport();
-        final ModelMBeanOperationInfo opInfo = new ModelMBeanOperationInfo("test", "readable description", null, "type", 1, opDesc);
-        assertTrue(fieldRefuted(opInfo, opDesc, "name" , "DENIED!!"));
-        assertTrue(fieldRefuted(opInfo, opDesc, "descriptorType" , "constructor"));
-        assertTrue(fieldRefuted(opInfo, opDesc, "descriptorType" , "attribute"));
-        assertTrue(fieldRefuted(opInfo, opDesc, "descriptorType" , "notification"));
-        assertTrue(fieldRefuted(opInfo, opDesc, "descriptorType" , "x"));
-    }
-
-    //TODO also test ModelMBeanInfoSupport perhaps. Slightly more difficult to set up and test.
-
-    /**
-     * Clones descriptor, sets a new value in the clone and tries to apply clone to
-     * reflected Model*Info object method. The new field should be refuted if it
-     * is a bad value.
-     */
-    //I like java, but this is one case where duck typing would have been slightly easier I think. :)
-    private boolean fieldRefuted(Object mbeanInfo, Descriptor desc, String fieldName, String newValue)
-    throws NoSuchMethodException, IllegalAccessException {
-        Method setDescMethod = mbeanInfo.getClass().getMethod("setDescriptor", Descriptor.class);
-        Descriptor newDesc = (Descriptor)desc.clone();
-        boolean refused = false;
-        newDesc.setField(fieldName, newValue);
-        try {
-            setDescMethod.invoke(mbeanInfo, newDesc);
-        } catch (InvocationTargetException ex) {
-            //If we get classcast exception, someone passed in a bad object to reflection.
-            //Perhaps an unnecessary check, this cast?
-            RuntimeOperationsException rex = (RuntimeOperationsException)ex.getTargetException();
-            refused = true;
-        }
-        return refused;
-    }
-
-    /**
-     * Dummy class used to create test objects. May not be needed.
-     */
-   private class DummyModelMBeanInfo implements ModelMBeanInfo {
-            public Descriptor[] getDescriptors(String inDescriptorType)
-            throws MBeanException, RuntimeOperationsException {
-                return null;
-            }
-
-            public void setDescriptors(Descriptor[] inDescriptors)
-            throws MBeanException, RuntimeOperationsException {
-
-            }
-
-            public Descriptor getDescriptor(String inDescriptorName, String inDescriptorType)
-            throws MBeanException, RuntimeOperationsException {
-                return null;
-            }
-
-            public void setDescriptor(Descriptor inDescriptor, String inDescriptorType)
-            throws MBeanException, RuntimeOperationsException {
-
-            }
-
-            public Descriptor getMBeanDescriptor()
-            throws MBeanException, RuntimeOperationsException {
-                return null;
-            }
-
-            public void setMBeanDescriptor(Descriptor inDescriptor)
-            throws MBeanException, RuntimeOperationsException {
-
-            }
-
-            public ModelMBeanAttributeInfo getAttribute(String inName)
-            throws MBeanException, RuntimeOperationsException {
-                return null;
-            }
-
-            public ModelMBeanOperationInfo getOperation(String inName)
-            throws MBeanException, RuntimeOperationsException {
-                return null;
-            }
-
-            public ModelMBeanNotificationInfo getNotification(String inName)
-            throws MBeanException, RuntimeOperationsException {
-                return null;
-            }
-
-            public MBeanAttributeInfo[] getAttributes() {
-                return null;
-            }
-
-            public String getClassName() {
-                return "AnonMBeanInfoImpl";
-            }
-
-            public MBeanConstructorInfo[] getConstructors() {
-                return null;
-            }
-
-            public String getDescription() {
-                return null;
-            }
-
-            public MBeanNotificationInfo[] getNotifications() {
-                return null;
-            }
-
-            public MBeanOperationInfo[] getOperations() {
-                return null;
-            }
-
-            public Object clone() {
-                return null;
-
-            }
-
-    }
-
-    private static void assertFalse(boolean x) {
-        assertTrue(!x);
-    }
-
-    private static void assertTrue(boolean x) {
-        if (!x)
-            throw new AssertionError("Assertion failed");
-    }
-
-}
--- a/test/javax/management/monitor/AttributeArbitraryDataTypeTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/monitor/AttributeArbitraryDataTypeTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,9 +32,13 @@
  * @run main AttributeArbitraryDataTypeTest
  */
 
+import java.beans.BeanInfo;
 import java.beans.IntrospectionException;
 import java.beans.PropertyDescriptor;
 import java.beans.SimpleBeanInfo;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import javax.management.AttributeNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
 import javax.management.Notification;
@@ -723,12 +727,49 @@
         System.out.println(message);
     }
 
+    public static Object elementFromComplex(Object complex, String element)
+    throws AttributeNotFoundException {
+        try {
+            if (complex.getClass().isArray() && element.equals("length")) {
+                return Array.getLength(complex);
+            } else if (complex instanceof CompositeData) {
+                return ((CompositeData) complex).get(element);
+            } else {
+                // Java Beans introspection
+                //
+                BeanInfo bi = java.beans.Introspector.getBeanInfo(complex.getClass());
+                PropertyDescriptor[] pds = bi.getPropertyDescriptors();
+                System.out.println("PDs: " + pds.length);
+                for (PropertyDescriptor pd : pds) {
+                    System.out.println("Property: " + pd.getName());
+                    if (pd.getName().equals(element))
+                        return pd.getReadMethod().invoke(complex);
+                }
+                throw new AttributeNotFoundException(
+                    "Could not find the getter method for the property " +
+                    element + " using the Java Beans introspector");
+            }
+        } catch (InvocationTargetException e) {
+            throw new IllegalArgumentException(e);
+        } catch (AttributeNotFoundException e) {
+            throw e;
+        } catch (Exception e) {
+            AttributeNotFoundException anfe =
+                new AttributeNotFoundException(e.getMessage());
+            anfe.initCause(e);
+            throw anfe;
+        }
+    }
+
     /*
      * Standalone entry point.
      *
      * Run the test and report to stdout.
      */
     public static void main (String args[]) throws Exception {
+        Match match = Match.do_match_now;
+        String name = (String) elementFromComplex(match, "name");
+        System.out.println("name: " + name);
         AttributeArbitraryDataTypeTest test =
             new AttributeArbitraryDataTypeTest();
         int error = test.monitorNotifications();
--- a/test/javax/management/monitor/InstantiateMonitorNotificationTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-
-import javax.management.ObjectName;
-import javax.management.monitor.MonitorNotification;
-
-/*
- * 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 6373143
- * @summary Test MonitorNotification public constructor
- * @author JFDenise
- * @run clean InstantiateMonitorNotificationTest
- * @run build InstantiateMonitorNotificationTest
- * @run main InstantiateMonitorNotificationTest
- */
-
-public class InstantiateMonitorNotificationTest {
-
-    public static void main(String[] args) throws Exception {
-        MonitorNotification notif = new MonitorNotification("com.foo.test",
-                ObjectName.valueOf(":type=Monitor"),
-                999,
-                999,
-                "A  message",
-                ObjectName.valueOf(":type=Observed"),
-                "MyAttribute",
-                Integer.valueOf(14),
-                Integer.valueOf(15));
-        System.out.println("Test passed");
-    }
-}
--- a/test/javax/management/mxbean/CustomTypeTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,642 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 %M% %I%
- * @bug 6562936 6750935
- * @run compile customtypes/package-info.java
- * @run main CustomTypeTest
- */
-
-import java.io.InvalidObjectException;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.Descriptor;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.NotCompliantMBeanException;
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.MXBeanMapping;
-import javax.management.openmbean.MXBeanMappingClass;
-import javax.management.openmbean.MXBeanMappingFactory;
-import javax.management.openmbean.MXBeanMappingFactoryClass;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.TabularData;
-
-import static javax.management.JMX.MBeanOptions;
-
-import customtypes.*;
-
-public class CustomTypeTest {
-    @MXBeanMappingClass(LinkedListMapping.class)
-    public static class LinkedList {
-        private final String name;
-        private final LinkedList next;
-
-        public LinkedList(String name, LinkedList next) {
-            this.name = name;
-            this.next = next;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public LinkedList getNext() {
-            return next;
-        }
-
-        public String toString() {
-            if (next == null)
-                return "(" + name + ")";
-            else
-                return "(" + name + " " + next + ")";
-        }
-
-        public boolean equals(Object x) {
-            if (!(x instanceof LinkedList))
-                return false;
-            LinkedList other = (LinkedList) x;
-            return (this.name.equals(other.name) &&
-                    (this.next == null ? other.next == null :
-                        this.next.equals(other.next)));
-        }
-    }
-
-    public static class LinkedListMapping extends MXBeanMapping {
-        public LinkedListMapping(Type type) throws OpenDataException {
-            super(LinkedList.class, ArrayType.getArrayType(SimpleType.STRING));
-            if (type != LinkedList.class) {
-                throw new OpenDataException("Mapping only valid for " +
-                        LinkedList.class);
-            }
-        }
-
-        public Object fromOpenValue(Object openValue) throws InvalidObjectException {
-            String[] array = (String[]) openValue;
-            LinkedList list = null;
-            for (int i = array.length - 1; i >= 0; i--)
-                list = new LinkedList(array[i], list);
-            return list;
-        }
-
-        public Object toOpenValue(Object javaValue) throws OpenDataException {
-            ArrayList<String> array = new ArrayList<String>();
-            for (LinkedList list = (LinkedList) javaValue; list != null;
-                    list = list.getNext())
-                array.add(list.getName());
-            return array.toArray(new String[0]);
-        }
-    }
-
-    public static interface LinkedListMXBean {
-        public LinkedList getLinkedList();
-    }
-
-    public static class LinkedListImpl implements LinkedListMXBean {
-        public LinkedList getLinkedList() {
-            return new LinkedList("car", new LinkedList("cdr", null));
-        }
-    }
-
-    public static class ObjectMXBeanMapping extends MXBeanMapping {
-        private static final CompositeType wildcardType;
-
-        static {
-            try {
-                wildcardType =
-                    new CompositeType(Object.class.getName(),
-                                      "Wildcard type for Object",
-                                      new String[0],        // itemNames
-                                      new String[0],        // itemDescriptions
-                                      new OpenType<?>[0]);  // itemTypes
-            } catch (OpenDataException e) {
-                throw new RuntimeException(e);
-            }
-        }
-
-        public ObjectMXBeanMapping() {
-            super(Object.class, wildcardType);
-        }
-
-        public Object fromOpenValue(Object openValue) throws InvalidObjectException {
-            if (!(openValue instanceof CompositeData)) {
-                throw new InvalidObjectException("Not a CompositeData: " +
-                        openValue.getClass());
-            }
-            CompositeData cd = (CompositeData) openValue;
-            if (!cd.containsKey("value")) {
-                throw new InvalidObjectException("CompositeData does not " +
-                        "contain a \"value\" item: " + cd);
-            }
-            Object x = cd.get("value");
-            if (!(x instanceof CompositeData || x instanceof TabularData ||
-                    x instanceof Object[]))
-                return x;
-
-            String typeName = (String) cd.get("type");
-            if (typeName == null) {
-                throw new InvalidObjectException("CompositeData does not " +
-                        "contain a \"type\" item: " + cd);
-            }
-            Class<?> c;
-            try {
-                c = Class.forName(typeName);
-            } catch (ClassNotFoundException e) {
-                InvalidObjectException ioe =
-                        new InvalidObjectException("Could not find type");
-                ioe.initCause(e);
-                throw ioe;
-            }
-            MXBeanMapping mapping;
-            try {
-                mapping = objectMappingFactory.mappingForType(c, objectMappingFactory);
-            } catch (OpenDataException e) {
-                InvalidObjectException ioe =
-                        new InvalidObjectException("Could not map object's " +
-                            "type " + c.getName());
-                ioe.initCause(e);
-                throw ioe;
-            }
-            return mapping.fromOpenValue(x);
-        }
-
-        public Object toOpenValue(Object javaValue) throws OpenDataException {
-            OpenType<?> openType;
-            Object openValue;
-            String typeName;
-            if (javaValue == null) {
-                openType = SimpleType.VOID;
-                openValue = null;
-                typeName = null;
-            } else {
-                Class<?> c = javaValue.getClass();
-                if (c.equals(Object.class))
-                    throw new OpenDataException("Cannot map Object to an open value");
-                MXBeanMapping mapping =
-                        objectMappingFactory.mappingForType(c, objectMappingFactory);
-                openType = mapping.getOpenType();
-                openValue = mapping.toOpenValue(javaValue);
-                typeName = c.getName();
-            }
-            CompositeType ct = new CompositeType(
-                    (javaValue == null) ? "null" : openType.getClassName(),
-                    "Open Mapping for Object",
-                    new String[] {"type", "value"},
-                    new String[] {"type", "value"},
-                    new OpenType<?>[] {SimpleType.STRING, openType});
-            return new CompositeDataSupport(
-                    ct,
-                    new String[] {"type", "value"},
-                    new Object[] {typeName, openValue});
-        }
-    }
-
-    public static class ObjectMappingFactory extends MXBeanMappingFactory {
-        private static MXBeanMapping objectMapping =
-                new ObjectMXBeanMapping();
-
-        @Override
-        public MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f)
-        throws OpenDataException {
-            if (t.equals(Object.class))
-                return objectMapping;
-            else
-                return MXBeanMappingFactory.DEFAULT.mappingForType(t, f);
-        }
-    }
-
-    private static MXBeanMappingFactory objectMappingFactory =
-            new ObjectMappingFactory();
-
-    public static interface ObjectMXBean {
-        public Object getObject();
-        public Object[] getObjects();
-        public List<Object> getObjectList();
-        public Object[][] getMoreObjects();
-    }
-
-    public static class ObjectImpl implements ObjectMXBean {
-        public Object getObject() {
-            return 123;
-        }
-
-        private static Object[] objects = {
-            "foo", 3, 3.14f, 3.14, 3L, new Date(), ObjectName.WILDCARD,
-            new byte[3], new char[3], new int[3][3],
-            new LinkedListImpl().getLinkedList(),
-        };
-
-        public Object[] getObjects() {
-            return objects;
-        }
-
-        public List<Object> getObjectList() {
-            return Arrays.asList(getObjects());
-        }
-
-        public Object[][] getMoreObjects() {
-            return new Object[][] {{getObjects()}};
-        }
-    }
-
-    @MXBeanMappingFactoryClass(ObjectMappingFactory.class)
-    public static interface AnnotatedObjectMXBean extends ObjectMXBean {}
-
-    public static class AnnotatedObjectImpl extends ObjectImpl
-            implements AnnotatedObjectMXBean {}
-
-    public static class BrokenMappingFactory extends MXBeanMappingFactory {
-        public MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f)
-        throws OpenDataException {
-            throw new OpenDataException(t.toString());
-        }
-    }
-
-    public static class ReallyBrokenMappingFactory extends BrokenMappingFactory {
-        public ReallyBrokenMappingFactory() {
-            throw new RuntimeException("Oops");
-        }
-    }
-
-    @MXBeanMappingFactoryClass(BrokenMappingFactory.class)
-    public static interface BrokenMXBean {
-        public int getX();
-    }
-
-    public static class BrokenImpl implements BrokenMXBean {
-        public int getX() {return 0;}
-    }
-
-    @MXBeanMappingFactoryClass(ReallyBrokenMappingFactory.class)
-    public static interface ReallyBrokenMXBean {
-        public int getX();
-    }
-
-    public static class ReallyBrokenImpl implements ReallyBrokenMXBean {
-        public int getX() {return 0;}
-    }
-
-    public static class BrokenMapping extends MXBeanMapping {
-        public BrokenMapping(Type t) {
-            super(t, SimpleType.STRING);
-            throw new RuntimeException("Oops");
-        }
-
-        public Object fromOpenValue(Object openValue) throws InvalidObjectException {
-            throw new AssertionError();
-        }
-
-        public Object toOpenValue(Object javaValue) throws OpenDataException {
-            throw new AssertionError();
-        }
-    }
-
-    @MXBeanMappingClass(BrokenMapping.class)
-    public static class BrokenType {}
-
-    public static interface BrokenTypeMXBean {
-        BrokenType getBroken();
-    }
-
-    public static class BrokenTypeImpl implements BrokenTypeMXBean {
-        public BrokenType getBroken() {
-            throw new AssertionError();
-        }
-    }
-
-    public static class BadConstructorMXBeanMappingFactory1 extends
-            MXBeanMappingFactory {
-        private BadConstructorMXBeanMappingFactory1() {}
-
-        @Override
-        public MXBeanMapping mappingForType(Type arg0, MXBeanMappingFactory arg1)
-                throws OpenDataException {
-            throw new UnsupportedOperationException("Should not be called");
-        }
-    }
-
-    public static class BadConstructorMXBeanMappingFactory2 extends
-            MXBeanMappingFactory {
-        public BadConstructorMXBeanMappingFactory2(boolean oops) {}
-
-        @Override
-        public MXBeanMapping mappingForType(Type arg0, MXBeanMappingFactory arg1)
-                throws OpenDataException {
-            throw new UnsupportedOperationException("Should not be called");
-        }
-    }
-
-    @MXBeanMappingFactoryClass(BadConstructorMXBeanMappingFactory1.class)
-    public static interface BadConstructor1MXBean {}
-
-    public static class BadConstructor1 implements BadConstructor1MXBean {}
-
-    @MXBeanMappingFactoryClass(BadConstructorMXBeanMappingFactory2.class)
-    public static interface BadConstructor2MXBean {}
-
-    public static class BadConstructor2 implements BadConstructor2MXBean {}
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-
-        System.out.println("Test @MXBeanMappingClass");
-        ObjectName linkedName = new ObjectName("d:type=LinkedList");
-        LinkedListMXBean linkedListMXBean = new LinkedListImpl();
-        LinkedList list1 = linkedListMXBean.getLinkedList();
-        mbs.registerMBean(linkedListMXBean, linkedName);
-        LinkedListMXBean linkedProxy =
-                JMX.newMXBeanProxy(mbs, linkedName, LinkedListMXBean.class);
-        MBeanServerInvocationHandler mbsih = (MBeanServerInvocationHandler)
-                Proxy.getInvocationHandler(linkedProxy);
-        if (!mbsih.isMXBean())
-            fail("not MXBean proxy");
-        LinkedList list2 = linkedProxy.getLinkedList();
-        if (list1 == list2)
-            fail("lists identical!");
-            // They should have gone through the mapping and back,
-            // and the mapping doesn't do anything that would allow it
-            // to restore the identical object.
-        if (!list1.equals(list2))
-            fail("lists different: " + list1 + " vs " + list2);
-        System.out.println("...success");
-
-        System.out.println("Test StandardMBean with MXBeanMappingFactory");
-        ObjectMXBean wildcardMBean = new ObjectImpl();
-        MBeanOptions options = new MBeanOptions();
-        options.setMXBeanMappingFactory(objectMappingFactory);
-        if (!options.isMXBean())
-            fail("Setting MXBeanMappingFactory should imply MXBean");
-        StandardMBean wildcardStandardMBean =
-                new StandardMBean(wildcardMBean, ObjectMXBean.class, options);
-        testWildcardMBean(mbs, wildcardMBean, wildcardStandardMBean,
-                          options, ObjectMXBean.class);
-
-        System.out.println("Test @MXBeanMappingFactoryClass on interface");
-        ObjectMXBean annotatedWildcardMBean = new AnnotatedObjectImpl();
-        testWildcardMBean(mbs, annotatedWildcardMBean, annotatedWildcardMBean,
-                          null, AnnotatedObjectMXBean.class);
-
-        System.out.println("Test @MXBeanMappingFactoryClass on package");
-        CustomMXBean custom = zeroProxy(CustomMXBean.class);
-        ObjectName customName = new ObjectName("d:type=Custom");
-        mbs.registerMBean(custom, customName);
-        Object x = mbs.getAttribute(customName, "X");
-        if (!(x instanceof String))
-            fail("Should be String: " + x + " (a " + x.getClass().getName() + ")");
-        CustomMXBean customProxy =
-                JMX.newMXBeanProxy(mbs, customName, CustomMXBean.class);
-        x = customProxy.getX();
-        if (!(x instanceof Integer) || (Integer) x != 0)
-            fail("Wrong return from proxy: " + x + " (a " + x.getClass().getName() + ")");
-
-        System.out.println("Test MXBeanMappingFactory exception");
-        try {
-            mbs.registerMBean(new BrokenImpl(), new ObjectName("d:type=Broken"));
-            fail("Register did not throw exception");
-        } catch (NotCompliantMBeanException e) {
-            System.out.println("...OK: threw: " + e);
-        }
-
-        System.out.println("Test MXBeanMappingFactory constructor exception");
-        try {
-            mbs.registerMBean(new ReallyBrokenImpl(), new ObjectName("d:type=Broken"));
-            fail("Register did not throw exception");
-        } catch (NotCompliantMBeanException e) {
-            System.out.println("...OK: threw: " + e);
-        } catch (Exception e) {
-            fail("Register threw wrong exception: " + e);
-        }
-
-        System.out.println("Test MXBeanMappingFactory exception with StandardMBean");
-        MXBeanMappingFactory brokenF = new BrokenMappingFactory();
-        MBeanOptions brokenO = new MBeanOptions();
-        brokenO.setMXBeanMappingFactory(brokenF);
-        try {
-            new StandardMBean(wildcardMBean, ObjectMXBean.class, brokenO);
-            fail("StandardMBean with broken factory did not throw exception");
-        } catch (IllegalArgumentException e) {
-            if (!(e.getCause() instanceof NotCompliantMBeanException)) {
-                fail("StandardMBean with broken factory threw wrong exception: "
-                        + e.getCause());
-            }
-        }
-
-        System.out.println("Test MXBeanMappingClass exception");
-        try {
-            mbs.registerMBean(new BrokenTypeImpl(), new ObjectName("d:type=Broken"));
-            fail("Broken MXBeanMappingClass did not throw exception");
-        } catch (NotCompliantMBeanException e) {
-            System.out.println("...OK: threw: " + e);
-        }
-
-        System.out.println("Test MXBeanMappingFactoryClass constructor exception");
-        for (Object mbean : new Object[] {
-            new BadConstructor1(), new BadConstructor2(),
-        }) {
-            String testName = mbean.getClass().getSimpleName();
-            try {
-                ObjectName name = new ObjectName("d:type=" + testName);
-                mbs.registerMBean(mbean, name);
-                fail("Broken MXBeanMappingFactoryClass did not throw exception" +
-                        " (" + testName + ")");
-            } catch (NotCompliantMBeanException e) {
-                System.out.println("...OK: " + testName + " threw: " + e);
-            } catch (Exception e) {
-                fail("Broken MXBeanMappingFactoryClass " + testName + " threw " +
-                        "wrong exception: " + e);
-            }
-        }
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static void testWildcardMBean(MBeanServer mbs, ObjectMXBean impl,
-                                          Object mbean,
-                                          MBeanOptions proxyOptions,
-                                          Class<? extends ObjectMXBean> intf)
-    throws Exception {
-        ObjectName wildcardName = new ObjectName("d:type=Object");
-        mbs.registerMBean(mbean, wildcardName);
-        try {
-            testWildcardMBean2(mbs, impl, wildcardName, proxyOptions, intf);
-        } finally {
-            mbs.unregisterMBean(wildcardName);
-        }
-    }
-
-    private static void testWildcardMBean2(MBeanServer mbs, ObjectMXBean impl,
-                                           ObjectName wildcardName,
-                                           MBeanOptions proxyOptions,
-                                           Class<? extends ObjectMXBean> intf)
-    throws Exception {
-        if (proxyOptions == null) {
-            proxyOptions = new MBeanOptions();
-            MXBeanMappingFactory f = MXBeanMappingFactory.forInterface(intf);
-            proxyOptions.setMXBeanMappingFactory(f);
-        }
-        Descriptor d = mbs.getMBeanInfo(wildcardName).getDescriptor();
-        String factoryName = (String)
-                d.getFieldValue(JMX.MXBEAN_MAPPING_FACTORY_CLASS_FIELD);
-        if (!ObjectMappingFactory.class.getName().equals(factoryName)) {
-            fail("Descriptor has wrong MXBeanMappingFactory: " + factoryName +
-                    " should be " + ObjectMappingFactory.class.getName());
-        }
-        ObjectMXBean wildcardProxy =
-            JMX.newMBeanProxy(mbs, wildcardName, intf, proxyOptions);
-        MBeanServerInvocationHandler mbsih = (MBeanServerInvocationHandler)
-                Proxy.getInvocationHandler(wildcardProxy);
-        MBeanOptions opts = mbsih.getMBeanOptions();
-        if (!opts.equals(proxyOptions)) {
-            fail("Proxy options differ from request: " + opts + " vs " +
-                    proxyOptions);
-        }
-        Method[] wildcardMethods = ObjectMXBean.class.getMethods();
-        for (Method m : wildcardMethods) {
-            System.out.println("..." + m.getName());
-            Object orig = m.invoke(impl);
-            Object copy = m.invoke(wildcardProxy);
-            if (!deepEquals(orig, copy)) {
-                fail("objects differ: " + deepToString(orig) + " vs " +
-                        deepToString(copy));
-            }
-        }
-    }
-
-    private static <T> T zeroProxy(Class<T> intf) {
-        return intf.cast(Proxy.newProxyInstance(intf.getClassLoader(),
-                new Class<?>[] {intf},
-                new ZeroInvocationHandler()));
-    }
-
-    private static class ZeroInvocationHandler implements InvocationHandler {
-        public Object invoke(Object proxy, Method method, Object[] args)
-        throws Throwable {
-            return 0;
-        }
-    }
-
-    private static boolean deepEquals(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-
-        if (x instanceof Collection<?>) {
-            if (!(y instanceof Collection<?>))
-                return false;
-            Collection<?> xcoll = (Collection<?>) x;
-            Collection<?> ycoll = (Collection<?>) y;
-            if (xcoll.size() != ycoll.size())
-                return false;
-            Iterator<?> xit = xcoll.iterator();
-            Iterator<?> yit = ycoll.iterator();
-            while (xit.hasNext()) {
-                if (!deepEquals(xit.next(), yit.next()))
-                    return false;
-            }
-            return true;
-        }
-
-        Class<?> xclass = x.getClass();
-        Class<?> yclass = y.getClass();
-        if (xclass.isArray()) {
-            if (!yclass.isArray())
-                return false;
-            if (!xclass.getComponentType().equals(yclass.getComponentType()))
-                return false;
-            int len = Array.getLength(x);
-            if (Array.getLength(y) != len)
-                return false;
-            for (int i = 0; i < len; i++) {
-                if (!deepEquals(Array.get(x, i), Array.get(y, i)))
-                    return false;
-            }
-            return true;
-        }
-
-//        return x.equals(y);
-        if (x.equals(y))
-            return true;
-        System.out.println("Not equal: <" + x + "> and <" + y + ">");
-        return false;
-    }
-
-    private static String deepToString(Object x) {
-        if (x == null)
-            return "null";
-
-        if (x instanceof Collection<?>) {
-            Collection<?> xcoll = (Collection<?>) x;
-            StringBuilder sb = new StringBuilder("[");
-            for (Object e : xcoll) {
-                if (sb.length() > 1)
-                    sb.append(", ");
-                sb.append(deepToString(e));
-            }
-            sb.append("]");
-            return sb.toString();
-        }
-
-        if (x instanceof Object[]) {
-            Object[] xarr = (Object[]) x;
-            return deepToString(Arrays.asList(xarr));
-        }
-
-        if (x.getClass().isArray()) { // primitive array
-            String s = Arrays.deepToString(new Object[] {x});
-            return s.substring(1, s.length() - 1);
-        }
-
-        return x.toString();
-    }
-
-    private static void fail(String msg) {
-        System.out.println("TEST FAILED: " + msg);
-        if (msg.length() > 100)
-            msg = msg.substring(0, 100) + "...";
-        failure = msg;
-    }
-
-    private static String failure;
-}
--- a/test/javax/management/mxbean/ExceptionDiagnosisTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/mxbean/ExceptionDiagnosisTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,3 +1,26 @@
+/*
+ * 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 6713777
@@ -180,7 +203,6 @@
     private static void testCaseProb() throws Exception {
         MBeanServer mbs = MBeanServerFactory.newMBeanServer();
         ObjectName name = new ObjectName("a:b=c");
-        Object mbean = new CaseProbImpl();
         mbs.registerMBean(new CaseProbImpl(), name);
         CaseProbMXBean proxy = JMX.newMXBeanProxy(mbs, name, CaseProbMXBean.class);
         try {
--- a/test/javax/management/mxbean/JMXServiceURLTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 JMXServiceURLTest
- * @bug 6607114 6670375 6731410
- * @summary Test that JMXServiceURL works correctly in MXBeans
- * @author Eamonn McManus
- */
-
-import java.io.InvalidObjectException;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.management.Attribute;
-import javax.management.JMX;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-import javax.management.remote.JMXServiceURL;
-
-public class JMXServiceURLTest {
-    public static interface UrlMXBean {
-        public JMXServiceURL getUrl();
-        public void setUrl(JMXServiceURL url);
-    }
-
-    public static class UrlImpl implements UrlMXBean {
-        volatile JMXServiceURL url;
-
-        public JMXServiceURL getUrl() {
-            return url;
-        }
-
-        public void setUrl(JMXServiceURL url) {
-            this.url = url;
-        }
-    }
-
-    private static enum Part {
-        PROTOCOL("protocol", SimpleType.STRING, "rmi", 25, "", "a:b", "/", "?", "#"),
-        HOST("host", SimpleType.STRING, "a.b.c", 25, "a..b", ".a.b", "a.b."),
-        PORT("port", SimpleType.INTEGER, 25, "25", -25),
-        PATH("URLPath", SimpleType.STRING, "/tiddly", 25, "tiddly");
-
-        Part(String name, OpenType openType, Object validValue, Object... bogusValues) {
-            this.name = name;
-            this.openType = openType;
-            this.validValue = validValue;
-            this.bogusValues = bogusValues;
-        }
-
-        final String name;
-        final OpenType openType;
-        final Object validValue;
-        final Object[] bogusValues;
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        ObjectName name = new ObjectName("a:b=c");
-        UrlImpl urlImpl = new UrlImpl();
-        mbs.registerMBean(urlImpl, name);
-
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://host:8000/noddy");
-        UrlMXBean proxy = JMX.newMXBeanProxy(mbs, name, UrlMXBean.class);
-        proxy.setUrl(url);
-        assertEquals(url, urlImpl.url);
-        JMXServiceURL url2 = proxy.getUrl();
-        assertEquals(url, url2);
-
-        CompositeData cd = (CompositeData) mbs.getAttribute(name, "Url");
-        CompositeType ct = cd.getCompositeType();
-        // Make sure it looks like what we expect.  This will have to be
-        // changed if ever we add new properties to CompositeType.  In that
-        // case this test should also check interoperability between the
-        // current version and the new version.
-        assertEquals(4, ct.keySet().size());
-        Object[][] expectedItems = {
-            {"protocol", SimpleType.STRING, "rmi"},
-            {"host", SimpleType.STRING, "host"},
-            {"port", SimpleType.INTEGER, 8000},
-            {"URLPath", SimpleType.STRING, "/noddy"},
-        };
-        for (Object[] expectedItem : expectedItems) {
-            String itemName = (String) expectedItem[0];
-            OpenType expectedType = (OpenType) expectedItem[1];
-            Object expectedValue = expectedItem[2];
-            OpenType actualType = ct.getType(itemName);
-            assertEquals(expectedType, actualType);
-            Object actualValue = cd.get(itemName);
-            assertEquals(expectedValue, actualValue);
-        }
-
-        // Now make sure we reject any bogus-looking CompositeData items.
-        // We first try every combination of omitted items (items can be
-        // null but cannot be omitted), then we try every combination of
-        // valid and bogus items.
-        final Part[] parts = Part.values();
-        final int nParts = parts.length;
-        final int maxPartMask = (1 << nParts) - 1;
-        // Iterate over all possibilities of included and omitted, except
-        // 0, because a CompositeDataSupport must have at least one element,
-        // and maxPartMask, where all items are included and the result is valid.
-        for (int mask = 1; mask < maxPartMask; mask++) {
-            Map<String, Object> cdMap = new HashMap<String, Object>();
-            List<String> names = new ArrayList<String>();
-            List<OpenType> types = new ArrayList<OpenType>();
-            for (int i = 0; i < nParts; i++) {
-                if ((mask & (1 << i)) != 0) {
-                    Part part = parts[i];
-                    cdMap.put(part.name, part.validValue);
-                    names.add(part.name);
-                    types.add(openTypeForValue(part.validValue));
-                }
-            }
-            String[] nameArray = names.toArray(new String[0]);
-            OpenType[] typeArray = types.toArray(new OpenType[0]);
-            CompositeType badct = new CompositeType(
-                    "bad", "descr", nameArray, nameArray, typeArray);
-            CompositeData badcd = new CompositeDataSupport(badct, cdMap);
-            checkBad(mbs, name, badcd);
-        }
-
-        int nBogus = 1;
-        for (Part part : parts)
-            nBogus *= (part.bogusValues.length + 1);
-        // Iterate over all combinations of bogus values.  We are basically
-        // treating each Part as a digit while counting up from 1.  A digit
-        // value of 0 stands for the valid value of that Part, and 1 on
-        // stand for the bogus values.  Hence an integer where all the digits
-        // are 0 would represent a valid CompositeData, which is why we
-        // start from 1.
-        for (int bogusCount = 1; bogusCount < nBogus; bogusCount++) {
-            List<String> names = new ArrayList<String>();
-            List<OpenType> types = new ArrayList<OpenType>();
-            int x = bogusCount;
-            Map<String, Object> cdMap = new HashMap<String, Object>();
-            for (Part part : parts) {
-                int digitMax = part.bogusValues.length + 1;
-                int digit = x % digitMax;
-                Object value = (digit == 0) ?
-                    part.validValue : part.bogusValues[digit - 1];
-                cdMap.put(part.name, value);
-                names.add(part.name);
-                types.add(openTypeForValue(value));
-                x /= digitMax;
-            }
-            String[] nameArray = names.toArray(new String[0]);
-            OpenType[] typeArray = types.toArray(new OpenType[0]);
-            CompositeType badct = new CompositeType(
-                    "bad", "descr", nameArray, nameArray, typeArray);
-            CompositeData badcd = new CompositeDataSupport(badct, cdMap);
-            checkBad(mbs, name, badcd);
-        }
-    }
-
-    private static OpenType openTypeForValue(Object value) {
-        if (value instanceof String)
-            return SimpleType.STRING;
-        else if (value instanceof Integer)
-            return SimpleType.INTEGER;
-        else
-            throw new AssertionError("Value has invalid type: " + value);
-    }
-
-    private static void checkBad(
-            MBeanServer mbs, ObjectName name, CompositeData badcd)
-            throws Exception {
-        try {
-            mbs.setAttribute(name, new Attribute("Url", badcd));
-            throw new Exception("Expected exception for: " + badcd);
-        } catch (MBeanException e) {
-            if (!(e.getCause() instanceof InvalidObjectException)) {
-                throw new Exception(
-                        "Wrapped exception should be InvalidObjectException", e);
-            }
-            System.out.println("OK: rejected " + badcd);
-        }
-    }
-
-    private static void assertEquals(Object expect, Object actual)
-            throws Exception {
-        if (expect.equals(actual))
-            System.out.println("Equal: " + expect);
-        else
-            throw new Exception("Expected " + expect + ", got " + actual);
-    }
-}
--- a/test/javax/management/mxbean/customtypes/CustomLongMXBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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.
- */
-
-// CustomLongMXBean.java - see CustomTypeTest
-
-package customtypes;
-
-import javax.management.openmbean.MXBeanMappingFactoryClass;
-
-@MXBeanMappingFactoryClass(IntegerIsLongFactory.class)
-public interface CustomLongMXBean extends CustomMXBean {}
--- a/test/javax/management/mxbean/customtypes/CustomMXBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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.
- */
-
-// CustomMXBean.java - see CustomTypeTest
-
-package customtypes;
-
-public interface CustomMXBean {
-    public Integer getX();
-}
--- a/test/javax/management/mxbean/customtypes/IntegerIsLongFactory.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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.
- */
-
-// IntegerIsLongFactory.java - see CustomTypeTest
-
-package customtypes;
-
-import java.io.InvalidObjectException;
-import java.lang.reflect.Type;
-import javax.management.openmbean.MXBeanMapping;
-import javax.management.openmbean.MXBeanMappingFactory;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.SimpleType;
-
-public class IntegerIsLongFactory implements MXBeanMappingFactory {
-    public MXBeanMapping forType(Type t, MXBeanMappingFactory f)
-    throws OpenDataException {
-        if (t == Integer.class)
-            return IntegerIsLongMapping;
-        else
-            return MXBeanMappingFactory.DEFAULT.forType(t, f);
-    }
-
-    private static final MXBeanMapping IntegerIsLongMapping =
-            new IntegerIsLongMapping();
-
-    private static class IntegerIsLongMapping extends MXBeanMapping {
-        IntegerIsLongMapping() {
-            super(Integer.class, SimpleType.STRING);
-        }
-
-        public Object fromOpenValue(Object openValue)
-        throws InvalidObjectException {
-            try {
-                return (Long) openValue;
-            } catch (Exception e) {
-                InvalidObjectException ioe = new InvalidObjectException("oops");
-                ioe.initCause(e);
-                throw ioe;
-            }
-        }
-
-        public Object toOpenValue(Object javaValue) throws OpenDataException {
-            try {
-                Integer i = (Integer) javaValue;
-                return new Long((int) i);
-            } catch (Exception e) {
-                OpenDataException ode = new OpenDataException("oops");
-                ode.initCause(e);
-                throw ode;
-            }
-        }
-    }
-}
--- a/test/javax/management/mxbean/customtypes/IntegerIsStringFactory.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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.
- */
-
-// IntegerIsStringFactory.java - see CustomTypeTest
-
-package customtypes;
-
-import java.io.InvalidObjectException;
-import java.lang.reflect.Type;
-import javax.management.openmbean.MXBeanMapping;
-import javax.management.openmbean.MXBeanMappingFactory;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.SimpleType;
-
-public class IntegerIsStringFactory extends MXBeanMappingFactory {
-    @Override
-    public MXBeanMapping mappingForType(Type t, MXBeanMappingFactory f)
-    throws OpenDataException {
-        if (t == Integer.class)
-            return integerIsStringMapping;
-        else
-            return MXBeanMappingFactory.DEFAULT.mappingForType(t, f);
-    }
-
-    private static final MXBeanMapping integerIsStringMapping =
-            new IntegerIsStringMapping();
-
-    private static class IntegerIsStringMapping extends MXBeanMapping {
-        IntegerIsStringMapping() {
-            super(Integer.class, SimpleType.STRING);
-        }
-
-        public Object fromOpenValue(Object openValue)
-        throws InvalidObjectException {
-            try {
-                String s = (String) openValue;
-                return Integer.parseInt(s);
-            } catch (Exception e) {
-                InvalidObjectException ioe = new InvalidObjectException("oops");
-                ioe.initCause(e);
-                throw ioe;
-            }
-        }
-
-        public Object toOpenValue(Object javaValue) throws OpenDataException {
-            try {
-                Integer i = (Integer) javaValue;
-                return i.toString();
-            } catch (Exception e) {
-                OpenDataException ode = new OpenDataException("oops");
-                ode.initCause(e);
-                throw ode;
-            }
-        }
-    }
-}
--- a/test/javax/management/mxbean/customtypes/package-info.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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-info.java - test package annotations for custom types
-
-@javax.management.openmbean.MXBeanMappingFactoryClass(IntegerIsStringFactory.class)
-package customtypes;
--- a/test/javax/management/namespace/DomainCreationTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,330 +0,0 @@
-/*
- * 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 DomainCreationTest.java
- * @bug 5072476
- * @summary Test the creation and registration of JMXDomain instances.
- * @author Daniel Fuchs
- * @run clean DomainCreationTest Wombat WombatMBean
- * @run build DomainCreationTest Wombat WombatMBean
- * @run main DomainCreationTest
- */
-
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.NotificationEmitter;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.RuntimeMBeanException;
-import javax.management.RuntimeOperationsException;
-import javax.management.namespace.JMXDomain;
-import javax.management.namespace.MBeanServerSupport;
-
-/**
- * Test simple creation/registration of namespace.
- *
- */
-public class DomainCreationTest {
-    private static Map<String,Object> emptyEnvMap() {
-        return Collections.emptyMap();
-    }
-
-
-    public static class LocalDomainRepository
-            extends MBeanServerSupport {
-        private final MBeanServer server;
-        private final String      domain;
-
-
-        public class DynamicMBeanProxy implements DynamicMBean {
-
-            private final MBeanServer server;
-            private final ObjectName name;
-
-            public DynamicMBeanProxy(MBeanServer s, ObjectName n) {
-                this.server = s;
-                this.name = n;
-            }
-
-            public Object getAttribute(String attribute)
-                    throws AttributeNotFoundException,
-                    MBeanException, ReflectionException {
-                try {
-                    return server.getAttribute(name, attribute);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public void setAttribute(Attribute attribute)
-                    throws AttributeNotFoundException,
-                    InvalidAttributeValueException, MBeanException,
-                    ReflectionException {
-                try {
-                    server.setAttribute(name, attribute);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public AttributeList getAttributes(String[] attributes) {
-                try {
-                    return server.getAttributes(name, attributes);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public AttributeList setAttributes(AttributeList attributes) {
-                try {
-                    return server.setAttributes(name, attributes);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public Object invoke(String actionName, Object[] params,
-                    String[] signature) throws MBeanException,
-                    ReflectionException {
-                try {
-                    return server.invoke(name, actionName, params, signature);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public MBeanInfo getMBeanInfo() {
-                try {
-                    return server.getMBeanInfo(name);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-        }
-
-        public LocalDomainRepository(String domain) {
-            this.server = MBeanServerFactory.newMBeanServer();
-            this.domain = domain;
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            try {
-            final ObjectName name =
-                    ObjectName.getInstance(domain+":*");
-            return server.queryNames(name, null);
-            } catch (RuntimeException x) {
-                throw x;
-            } catch (Exception x) {
-                throw new RuntimeException(x);
-            }
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            return new DynamicMBeanProxy(server, name);
-        }
-
-        @Override
-        public NotificationEmitter
-                getNotificationEmitterFor(ObjectName name)
-                throws InstanceNotFoundException {
-            DynamicMBean mbean = getDynamicMBeanFor(name);
-            if (mbean instanceof NotificationEmitter)
-                return (NotificationEmitter) mbean;
-            return null;
-        }
-
-    }
-
-    private static MBeanServer newMBeanServer() {
-        return MBeanServerFactory.newMBeanServer();
-    }
-
-    public static interface ThingMBean {}
-    public static class Thing implements ThingMBean, MBeanRegistration {
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-                throws Exception {
-            if (name == null) return new ObjectName(":type=Thing");
-            else return name;
-        }
-        public void postRegister(Boolean registrationDone) {
-        }
-
-        public void preDeregister() throws Exception {
-        }
-        public void postDeregister() {
-        }
-    }
-
-    /**
-     * Test that it is possible to create a dummy MBean with a null
-     * ObjectName - this is just a sanity check - as there are already
-     * other JMX tests that check that.
-     *
-     * @throws java.lang.Exception
-     */
-    public static void testCreateWithNull() throws Exception {
-        final MBeanServer server = newMBeanServer();
-        final ObjectInstance oi = server.registerMBean(new Thing(),null);
-        server.unregisterMBean(oi.getObjectName());
-        System.out.println("testCreateWithNull PASSED");
-    }
-
-    /**
-     * Check that we can register a JMXNamespace MBean, using its standard
-     * ObjectName.
-     * @throws java.lang.Exception
-     */
-    public static void testGoodObjectName() throws Exception {
-        MBeanServer server = newMBeanServer();
-        final ObjectName name =
-                JMXDomain.getDomainObjectName("gloups");
-        final ObjectInstance oi =
-                server.registerMBean(new JMXDomain(
-                new LocalDomainRepository("gloups")),name);
-        System.out.println("Succesfully registered namespace: "+name);
-        try {
-            if (! name.equals(oi.getObjectName()))
-                throw new RuntimeException("testGoodObjectName: TEST failed: " +
-                        "namespace registered as: "+
-                    oi.getObjectName()+" expected: "+name);
-        } finally {
-            server.unregisterMBean(oi.getObjectName());
-        }
-        System.out.println("Succesfully unregistered namespace: "+name);
-        System.out.println("testGoodObjectName PASSED");
-    }
-
-    /**
-     * Check that we cannot register a JMXNamespace MBean, if we don't use
-     * its standard ObjectName.
-     * @throws java.lang.Exception
-     */
-    public static void testBadObjectName() throws Exception {
-        MBeanServer server = newMBeanServer();
-        Throwable exp = null;
-        final ObjectName name = new ObjectName("d:k=v");
-        try {
-            server.registerMBean(new JMXDomain(
-                new LocalDomainRepository("d")),name);
-            System.out.println("testBadObjectName: " +
-                    "Error: MBean registered, no exception thrown.");
-        } catch(RuntimeMBeanException x) {
-            exp = x.getCause();
-        } catch(Exception x) {
-            throw new RuntimeException("testBadObjectName: TEST failed: " +
-                    "expected RuntimeMBeanException - got "+
-                    x);
-        }
-        if (exp == null)  server.unregisterMBean(name);
-        if (exp == null)
-            throw new RuntimeException("testBadObjectName: TEST failed: " +
-                    "expected IllegalArgumentException - got none");
-        if (!(exp instanceof IllegalArgumentException))
-            throw new RuntimeException("testBadObjectName: TEST failed: " +
-                    "expected IllegalArgumentException - got "+
-                    exp.toString(),exp);
-        System.out.println("Got expected exception: "+exp);
-        System.out.println("testBadObjectName PASSED");
-    }
-
-    /**
-     * Check that we cannot register a Domain MBean in a domain that already
-     * exists.
-     *
-     * @throws java.lang.Exception
-     */
-    public static void testBadDomain() throws Exception {
-        MBeanServer server = newMBeanServer();
-        Throwable exp = null;
-        final ObjectName name = new ObjectName("glips:k=v");
-        server.registerMBean(new Wombat(),name);
-
-        final ObjectName dname =
-                JMXDomain.getDomainObjectName("glips");
-
-        try {
-            server.registerMBean(new JMXDomain(
-                new LocalDomainRepository("glips")),dname);
-            System.out.println("testBadDomain: " +
-                    "Error: MBean registered, no exception thrown.");
-        } catch(RuntimeOperationsException x) {
-            exp = x.getCause();
-        } catch(Exception x) {
-            throw new RuntimeException("testBadDomain: TEST failed: " +
-                    "expected RuntimeOperationsException - got "+
-                    x);
-        } finally {
-            server.unregisterMBean(name);
-        }
-        if (exp == null)  {
-            server.unregisterMBean(dname);
-        }
-        if (exp == null)
-            throw new RuntimeException("testBadDomain: TEST failed: " +
-                    "expected IllegalArgumentException - got none");
-        if (!(exp instanceof IllegalArgumentException))
-            throw new RuntimeException("testBadDomain: TEST failed: " +
-                    "expected IllegalArgumentException - got "+
-                    exp.toString(),exp);
-        System.out.println("Got expected exception: "+exp);
-        System.out.println("testBadDomain PASSED");
-    }
-
-
-    public static void main(String... args) throws Exception {
-        testCreateWithNull();
-        testGoodObjectName();
-        testBadObjectName();
-        testBadDomain();
-    }
-}
--- a/test/javax/management/namespace/EventWithNamespaceControlTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * 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 EventWithNamespaceControlTest.java
- * @summary Check -Djmx.remote.use.event.service=true and
- *                -Djmx.remote.delegate.event.service
- * @author Daniel Fuchs
- * @bug 5072476 5108776
- * @run clean EventWithNamespaceTest EventWithNamespaceControlTest
- *            Wombat WombatMBean JMXRemoteTargetNamespace
- *            NamespaceController NamespaceControllerMBean
- * @compile -XDignore.symbol.file=true EventWithNamespaceTest.java
-              EventWithNamespaceControlTest.java
- *            Wombat.java WombatMBean.java JMXRemoteTargetNamespace.java
- *            NamespaceController.java NamespaceControllerMBean.java
- * @run main/othervm -Djmx.remote.use.event.service=true EventWithNamespaceControlTest
- * @run main/othervm EventWithNamespaceControlTest
- * @run main/othervm -Djmx.remote.delegate.event.service=false EventWithNamespaceControlTest java.lang.UnsupportedOperationException
- */
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.logging.Logger;
-import javax.management.RuntimeOperationsException;
-
-/**
- *
- * @author Sun Microsystems, Inc.
- */
-public class EventWithNamespaceControlTest extends EventWithNamespaceTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(EventWithNamespaceControlTest.class.getName());
-
-    /** Creates a new instance of EventWithNamespaceTest */
-    public EventWithNamespaceControlTest() {
-    }
-
-
-
-    public static void main(String[] args) {
-        final  EventWithNamespaceControlTest test =
-                new EventWithNamespaceControlTest();
-        if (args.length == 0) {
-            test.run(args);
-            System.out.println("Test successfully passed");
-        } else {
-            try {
-                test.run(args);
-                throw new RuntimeException("Test should have failed.");
-            } catch (RuntimeOperationsException x) {
-                if (! args[0].equals(x.getCause().getClass().getName())) {
-                    System.err.println("Unexpected wrapped exception: "+
-                            x.getCause());
-                    throw x;
-                } else {
-                    System.out.println("Got expected exception: "+x.getCause());
-                }
-            }
-        }
-    }
-
-    @Override
-    public Map<String, ?> getServerMap() {
-        Map<String, ?> retValue = Collections.emptyMap();
-        return retValue;
-    }
-
-}
--- a/test/javax/management/namespace/EventWithNamespaceTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,241 +0,0 @@
-/*
- * 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 EventWithNamespaceTest.java 1.8
- * @bug 6539857 5072476 5108776
- * @summary General Namespace & Notifications test.
- * @author Daniel Fuchs
- * @run clean EventWithNamespaceTest Wombat WombatMBean
- *            JMXRemoteTargetNamespace
- *            NamespaceController NamespaceControllerMBean
- * @compile -XDignore.symbol.file=true EventWithNamespaceTest.java
- *          Wombat.java WombatMBean.java JMXRemoteTargetNamespace.java
- *          NamespaceController.java NamespaceControllerMBean.java
- * @run main EventWithNamespaceTest
- */
-
-import java.lang.management.ManagementFactory;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- *
- * @author Sun Microsystems, Inc.
- */
-public class EventWithNamespaceTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(EventWithNamespaceTest.class.getName());
-
-    /** Creates a new instance of EventWithNamespaceTest */
-    public EventWithNamespaceTest() {
-    }
-
-    private static Map<String,?> singletonMap(String key, Object value) {
-        final Map<String,Object> map = new HashMap<String,Object>();
-        map.put(key,value);
-        return map;
-    }
-
-    public  Map<String,?> getServerMap() {
-        return singletonMap(JMXConnectorServer.DELEGATE_TO_EVENT_SERVICE,"true");
-    }
-
-    public JMXServiceURL export(MBeanServer server)
-    throws Exception {
-        final JMXServiceURL in = new JMXServiceURL("rmi",null,0);
-        final Map<String,?> env = getServerMap();
-
-        final JMXConnectorServer cs =
-                JMXConnectorServerFactory.newJMXConnectorServer(in,env,null);
-        final ObjectName csname = ObjectName.
-                getInstance(cs.getClass().getPackage().getName()+
-                ":type="+cs.getClass().getSimpleName());
-        server.registerMBean(cs,csname);
-        cs.start();
-        return cs.getAddress();
-    }
-
-    public static class Counter {
-        int count;
-        public synchronized int count() {
-            count++;
-            notifyAll();
-            return count;
-        }
-        public synchronized int peek() {
-            return count;
-        }
-        public synchronized int waitfor(int max, long timeout)
-        throws InterruptedException {
-            final long start = System.currentTimeMillis();
-            while (count < max && timeout > 0) {
-                final long rest = timeout -
-                        (System.currentTimeMillis() - start);
-                if (rest <= 0) break;
-                wait(rest);
-            }
-            return count;
-        }
-    }
-
-    public static class CounterListener
-            implements NotificationListener {
-        final private Counter counter;
-        public CounterListener(Counter counter) {
-            this.counter = counter;
-        }
-        public void handleNotification(Notification notification,
-                Object handback) {
-            System.out.println("Received notif from " + handback +
-                    ":\n\t" + notification);
-            if (!notification.getSource().equals(handback)) {
-                System.err.println("OhOh... Unexpected source: \n\t"+
-                        notification.getSource()+"\n\twas expecting:\n\t"+
-                        handback);
-            }
-            counter.count();
-        }
-    }
-
-    public void simpleTest(String[] args) {
-        try {
-            final MBeanServer server1 =
-                    ManagementFactory.getPlatformMBeanServer();
-            final JMXServiceURL url1 = export(server1);
-
-            final MBeanServer server2 =
-                    MBeanServerFactory.createMBeanServer("server2");
-            final JMXServiceURL url2 = export(server2);
-
-            final MBeanServer server3 =
-                    MBeanServerFactory.createMBeanServer("server3");
-            final JMXServiceURL url3 = export(server3);
-
-            final ObjectInstance ncinst =
-                    NamespaceController.createInstance(server1);
-
-            final NamespaceControllerMBean nc =
-                    JMX.newMBeanProxy(server1,ncinst.getObjectName(),
-                    NamespaceControllerMBean.class);
-
-            final String mount2 = nc.mount(url2,"server2",null);
-            final String mount3 = nc.mount(url3,"server2//server3",
-                    null);
-
-            final ObjectName deep =
-                    new ObjectName("server2//server3//bush:type=Wombat,name=kanga");
-            server1.createMBean(Wombat.class.getName(),deep);
-
-            System.err.println("There's a wombat in the bush!");
-
-            final Counter counter = new Counter();
-
-            final NotificationListener listener =
-                    new CounterListener(counter);
-
-            final JMXConnector jc = JMXConnectorFactory.connect(url1);
-            final MBeanServerConnection conn1 =
-                    jc.getMBeanServerConnection();
-            final ObjectName shallow =
-                    new ObjectName("bush:"+
-                    deep.getKeyPropertyListString());
-            final MBeanServerConnection conn2 =
-                    JMXNamespaces.narrowToNamespace(conn1,"server2//server3");
-
-            final WombatMBean proxy1 =
-                    JMX.newMBeanProxy(conn1,deep,WombatMBean.class,true);
-            final WombatMBean proxy2 =
-                    JMX.newMBeanProxy(conn2,shallow,WombatMBean.class,true);
-
-
-            System.err.println("Adding first Notification Listener");
-            conn1.addNotificationListener(deep,listener,null,deep);
-            System.err.println("Adding second Notification Listener");
-            ((NotificationEmitter)proxy2).
-                    addNotificationListener(listener,null,shallow);
-            final JMXConnector c3 = JMXConnectorFactory.connect(url3,
-                    singletonMap(JMXConnector.USE_EVENT_SERVICE,"false"));
-            System.err.println("Adding third Notification Listener");
-            c3.getMBeanServerConnection().
-                    addNotificationListener(shallow,listener,null,shallow);
-            System.err.println("Set attribute to trigger notif");
-            proxy1.setCaption("I am a new Wombat!");
-            System.err.println("Get attribute");
-            System.err.println("New caption: "+proxy2.getCaption());
-            System.err.println("Wait for Notifs...");
-            final int rcvcount = counter.waitfor(3,3000);
-            if (rcvcount != 3)
-                throw new RuntimeException("simpleTest failed: "+
-                        "received count is " +rcvcount);
-            System.err.println("simpleTest: got expected "+rcvcount+
-                    " notifs");
-
-            System.err.println("removing all listeners");
-            conn1.removeNotificationListener(deep,listener,null,deep);
-            ((NotificationEmitter)proxy2)
-                .removeNotificationListener(listener,null,shallow);
-            c3.getMBeanServerConnection().
-                    removeNotificationListener(shallow,listener,null,shallow);
-
-            System.err.println("simpleTest passed: got "+rcvcount+
-                    " notifs");
-
-        } catch (RuntimeException x) {
-            throw x;
-        } catch (Exception x) {
-            throw new RuntimeException("simpleTest failed: " + x,x);
-        }
-    }
-
-    public void run(String[] args) {
-                simpleTest(args);
-    }
-
-    public static void main(String[] args) {
-        new EventWithNamespaceTest().run(args);
-    }
-
-}
--- a/test/javax/management/namespace/ExportNamespaceTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * 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 ExportNamespaceTest.java
- * @summary Test that you can export a single namespace through a
- *          JMXConnectorServer.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean ExportNamespaceTest Wombat WombatMBean
- * @run build ExportNamespaceTest Wombat WombatMBean
- * @run main ExportNamespaceTest
- */
-
-import javax.management.JMX;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-
-/**
- * Test simple creation/registration of namespace.
- *
- */
-public class ExportNamespaceTest {
-
-    public static void testExport() throws Exception {
-        final JMXNamespace my =
-                new JMXNamespace(MBeanServerFactory.newMBeanServer());
-        final MBeanServer s = MBeanServerFactory.newMBeanServer();
-        final ObjectName myname = JMXNamespaces.getNamespaceObjectName("my");
-        final ObjectName wname = ObjectName.getInstance("backyard:type=Wombat");
-        my.getSourceServer().registerMBean(new Wombat(),wname);
-        s.registerMBean(my,myname);
-
-        if (!s.queryNames(new ObjectName("my//b*:*"),null).contains(
-                JMXNamespaces.insertPath("my", wname))) {
-            throw new RuntimeException("1: Wombat not found: "+wname);
-        }
-
-        final MBeanServer cd = JMXNamespaces.narrowToNamespace(s, "my");
-        if (!cd.queryNames(new ObjectName("b*:*"),null).contains(wname)) {
-            throw new RuntimeException("2: Wombat not found: "+wname);
-        }
-
-        final JMXServiceURL url = new JMXServiceURL("rmi",null,0);
-        final JMXConnectorServer server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, null, cd);
-        server.start();
-
-        final JMXConnector jc = JMXConnectorFactory.
-                connect(server.getAddress(),null);
-        final MBeanServerConnection mbsc = jc.getMBeanServerConnection();
-
-        if (!mbsc.queryNames(new ObjectName("b*:*"),null).contains(wname)) {
-            throw new RuntimeException("3: Wombat not found: "+wname);
-        }
-        System.out.println("Found a Wombat in my backyard.");
-
-        final String deepThoughts = "I want to leave this backyard!";
-        final WombatMBean w = JMX.newMBeanProxy(mbsc, wname, WombatMBean.class);
-        w.setCaption(deepThoughts);
-        if (!deepThoughts.equals(w.getCaption()))
-                throw new RuntimeException("4: Wombat is not thinking right: "+
-                        w.getCaption());
-
-    }
-
-    public static void main(String... args) throws Exception {
-        testExport();
-    }
-}
--- a/test/javax/management/namespace/JMXDomainTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,513 +0,0 @@
-/*
- * 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 JMXDomainTest.java
- * @bug 5072476
- * @summary Basic test for JMXDomain.
- * @author Daniel Fuchs
- * @run clean JMXDomainTest Wombat WombatMBean
- * @run build JMXDomainTest Wombat WombatMBean
- * @run main JMXDomainTest
- */
-
-
-import java.util.Collections;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.Map;
-import java.util.Set;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerNotification;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.namespace.JMXDomain;
-import javax.management.namespace.MBeanServerSupport;
-
-/**
- * Test simple creation/registration of namespace.
- *
- */
-public class JMXDomainTest {
-    private static Map<String,Object> emptyEnvMap() {
-        return Collections.emptyMap();
-    }
-
-
-    public static class LocalDomainRepository
-            extends MBeanServerSupport {
-        private final MBeanServer server;
-        private final String      domain;
-
-        public class DynamicMBeanProxy implements DynamicMBean {
-
-            private final MBeanServer server;
-            private final ObjectName name;
-
-            public DynamicMBeanProxy(MBeanServer s, ObjectName n) {
-                this.server = s;
-                this.name = n;
-            }
-
-            public Object getAttribute(String attribute)
-                    throws AttributeNotFoundException,
-                    MBeanException, ReflectionException {
-                try {
-                    return server.getAttribute(name, attribute);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public void setAttribute(Attribute attribute)
-                    throws AttributeNotFoundException,
-                    InvalidAttributeValueException, MBeanException,
-                    ReflectionException {
-                try {
-                    server.setAttribute(name, attribute);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public AttributeList getAttributes(String[] attributes) {
-                try {
-                    return server.getAttributes(name, attributes);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public AttributeList setAttributes(AttributeList attributes) {
-                try {
-                    return server.setAttributes(name, attributes);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public Object invoke(String actionName, Object[] params,
-                    String[] signature) throws MBeanException,
-                    ReflectionException {
-                try {
-                    return server.invoke(name, actionName, params, signature);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-
-            public MBeanInfo getMBeanInfo() {
-                try {
-                    return server.getMBeanInfo(name);
-                } catch (RuntimeException x) {
-                    throw x;
-                } catch (Exception x) {
-                    throw new RuntimeException(x);
-                }
-            }
-        }
-
-        public LocalDomainRepository(String domain) {
-            this.server = MBeanServerFactory.newMBeanServer();
-            this.domain = domain;
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            try {
-            final ObjectName name =
-                    ObjectName.getInstance(domain+":*");
-            return server.queryNames(name, null);
-            } catch (RuntimeException x) {
-                throw x;
-            } catch (Exception x) {
-                throw new RuntimeException(x);
-            }
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            if (server.isRegistered(name))
-                return new DynamicMBeanProxy(server, name);
-            throw new InstanceNotFoundException(name);
-        }
-
-
-        @Override
-        public NotificationEmitter
-                getNotificationEmitterFor(final ObjectName name)
-                throws InstanceNotFoundException {
-            if (server.isInstanceOf(name, NotificationEmitter.class.getName())) {
-                return new NotificationEmitter() {
-
-                    public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
-                        try {
-                            server.removeNotificationListener(name, listener, filter, handback);
-                        } catch (InstanceNotFoundException x) {
-                            throw new IllegalArgumentException(String.valueOf(name), x);
-                        }
-                    }
-
-                    public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException {
-                        try {
-                            server.addNotificationListener(name, listener, filter, handback);
-                        } catch (InstanceNotFoundException x) {
-                            throw new IllegalArgumentException(String.valueOf(name), x);
-                        }
-                    }
-
-                    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
-                        try {
-                            server.removeNotificationListener(name, listener);
-                        } catch (InstanceNotFoundException x) {
-                            throw new IllegalArgumentException(String.valueOf(name), x);
-                        }
-                    }
-
-                    public MBeanNotificationInfo[] getNotificationInfo() {
-                        try {
-                            return server.getMBeanInfo(name).getNotifications();
-                        } catch (Exception x) {
-                            throw new IllegalArgumentException(String.valueOf(name), x);
-                        }
-                    }
-                };
-            }
-            return null;
-        }
-
-        @Override
-        public ObjectInstance registerMBean(Object object, ObjectName name)
-                throws InstanceAlreadyExistsException,
-                MBeanRegistrationException, NotCompliantMBeanException {
-            return server.registerMBean(object, name);
-        }
-
-        @Override
-        public void unregisterMBean(ObjectName name)
-                throws InstanceNotFoundException,
-                MBeanRegistrationException {
-            server.unregisterMBean(name);
-        }
-
-        @Override
-        public ObjectInstance createMBean(String className,
-                ObjectName name, ObjectName loaderName, Object[] params,
-                String[] signature, boolean useCLR)
-                throws ReflectionException, InstanceAlreadyExistsException,
-                MBeanRegistrationException, MBeanException,
-                NotCompliantMBeanException, InstanceNotFoundException {
-            if (useCLR && loaderName == null) {
-                return server.createMBean(className, name, params, signature);
-            }
-            return server.createMBean(className, name, loaderName,
-                    params, signature);
-        }
-
-
-    }
-
-    private static MBeanServer newMBeanServer() {
-        return MBeanServerFactory.newMBeanServer();
-    }
-
-    public static interface ThingMBean {}
-    public static class Thing implements ThingMBean, MBeanRegistration {
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-                throws Exception {
-            if (name == null) return new ObjectName(":type=Thing");
-            else return name;
-        }
-        public void postRegister(Boolean registrationDone) {
-        }
-
-        public void preDeregister() throws Exception {
-        }
-        public void postDeregister() {
-        }
-    }
-
-    /**
-     * Test that it is possible to create a dummy MBean with a null
-     * ObjectName - this is just a sanity check - as there are already
-     * other JMX tests that check that.
-     *
-     * @throws java.lang.Exception
-     */
-    public static void testCreateWithNull() throws Exception {
-        final MBeanServer server = newMBeanServer();
-        final ObjectInstance oi = server.registerMBean(new Thing(),null);
-        server.unregisterMBean(oi.getObjectName());
-        System.out.println("testCreateWithNull PASSED");
-    }
-
-    public static void testRegisterSimple() throws Exception {
-        final ObjectName name =
-                JMXDomain.getDomainObjectName("gloups");
-        final JMXDomain jmxDomain = new JMXDomain(
-                MBeanServerFactory.newMBeanServer());
-        testRegister("testRegisterSimple: ",name,jmxDomain);
-    }
-
-    public static void testRegisterPseudoVirtual()
-            throws Exception {
-        final ObjectName name =
-                JMXDomain.getDomainObjectName("gloups");
-        final JMXDomain jmxDomain = new JMXDomain(
-                new LocalDomainRepository("gloups"));
-        testRegister("testRegisterPseudoVirtual: ",name,jmxDomain);
-    }
-
-    public static void testRegister(final String test,
-            final ObjectName name,
-            final JMXDomain jmxDomain) throws Exception {
-        System.out.println(test+" START");
-        MBeanServer server = newMBeanServer();
-        final ObjectInstance oi =
-                server.registerMBean(jmxDomain,name);
-        System.out.println(test+"Succesfully registered namespace: "+name);
-        if (!server.isRegistered(name))
-            fail(test+name+" is not registered!");
-        if (!server.queryNames(new ObjectName(name.getDomain()+":*"), null).
-                contains(name))
-            fail(test+name+" not in queryNames");
-
-        final Thing thing = new Thing();
-        final ObjectName thingName = new ObjectName("gloups:type=Thing");
-        server.registerMBean(thing,thingName);
-        if (!server.isRegistered(thingName))
-            fail(test+thingName+" is not registered!");
-        if (!jmxDomain.getSourceServer().isRegistered(thingName))
-            fail(test+thingName+" is not registered in domain!");
-        if (!server.queryNames(new ObjectName(name.getDomain()+":*"), null).
-                contains(thingName))
-            fail(test+thingName+" not in queryNames");
-
-        server.unregisterMBean(name);
-        if (server.isRegistered(thingName))
-            fail(test+thingName+" is still registered!");
-        if (server.queryNames(new ObjectName(name.getDomain()+":*"), null).
-                contains(thingName))
-            fail(test+thingName+" still in queryNames");
-
-        server.registerMBean(jmxDomain, name);
-        if (!server.isRegistered(thingName))
-            fail(test+thingName+" is not registered again!");
-
-        System.out.println(test+" PASSED");
-    }
-
-    private static MBeanServerNotification pop(
-            BlockingQueue<Notification> queue,
-                                    String type,
-                                    ObjectName mbean,
-                                    String test)
-                                    throws InterruptedException {
-        final Notification n = queue.poll(1, TimeUnit.SECONDS);
-        if (!(n instanceof MBeanServerNotification))
-            fail(test+"expected MBeanServerNotification, got "+n);
-        final MBeanServerNotification msn = (MBeanServerNotification)n;
-        if (!type.equals(msn.getType()))
-            fail(test+"expected "+type+", got "+msn.getType());
-        if (!mbean.apply(msn.getMBeanName()))
-            fail(test+"expected "+mbean+", got "+msn.getMBeanName());
-        System.out.println(test+" got: "+msn);
-        return msn;
-    }
-    private static MBeanServerNotification popADD(
-            BlockingQueue<Notification> queue,
-                                    ObjectName mbean,
-                                    String test)
-                                    throws InterruptedException {
-        return pop(queue, MBeanServerNotification.REGISTRATION_NOTIFICATION,
-                mbean, test);
-    }
-
-    private static MBeanServerNotification popREM(
-            BlockingQueue<Notification> queue,
-                                    ObjectName mbean,
-                                    String test)
-                                    throws InterruptedException {
-        return pop(queue, MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
-                mbean, test);
-    }
-
-
-    public static void testRegisterNotifSimple() throws Exception {
-        final ObjectName name =
-                JMXDomain.getDomainObjectName("gloups");
-        final JMXDomain jmxDomain = new JMXDomain(
-                MBeanServerFactory.newMBeanServer());
-        testRegisterNotif("testRegisterNotifSimple: ",name,jmxDomain);
-    }
-
-    public static void testRegisterNotifPseudoVirtual()
-            throws Exception {
-        final ObjectName name =
-                JMXDomain.getDomainObjectName("gloups");
-        final JMXDomain jmxDomain = new JMXDomain(
-                new LocalDomainRepository("gloups"));
-        testRegisterNotif("testRegisterNotifPseudoVirtual: ",name,jmxDomain);
-    }
-
-    public static void testRegisterNotif(final String test,
-            final ObjectName name,
-            final JMXDomain jmxDomain) throws Exception {
-        System.out.println(test+" START");
-        MBeanServer server = newMBeanServer();
-        final ObjectInstance oi =
-                server.registerMBean(jmxDomain,name);
-        System.out.println(test+"Succesfully registered namespace: "+name);
-        if (!server.isRegistered(name))
-            fail(test+name+" is not registered!");
-
-        final BlockingQueue<Notification> queue =
-                new ArrayBlockingQueue<Notification>(10);
-
-        final NotificationListener l = new NotificationListener() {
-
-            public void handleNotification(Notification notification,
-                    Object handback) {
-                try {
-                    if (!queue.offer(notification,5,TimeUnit.SECONDS))
-                        throw new RuntimeException("timeout exceeded");
-                } catch (Exception x) {
-                    fail(test+"failed to handle notif", x);
-                }
-            }
-        };
-
-        server.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, l,
-                null, null);
-
-        final Thing thing = new Thing();
-        final ObjectName thingName = new ObjectName("gloups:type=Thing");
-
-        server.registerMBean(thing,thingName);
-        if (!jmxDomain.getSourceServer().isRegistered(thingName))
-            fail(test+thingName+" is not registered in domain!");
-        popADD(queue, thingName, test);
-        server.unregisterMBean(thingName);
-        if (jmxDomain.getSourceServer().isRegistered(thingName))
-            fail(test+thingName+" is still registered in domain!");
-        popREM(queue, thingName, test);
-        if (queue.size() != 0)
-            fail(test+queue.size()+" notifs remain in queue "+queue);
-
-        server.unregisterMBean(name);
-        popREM(queue, name, test);
-
-        jmxDomain.getSourceServer().registerMBean(thing,thingName);
-        if (server.isRegistered(thingName))
-            fail(test+thingName+" is still registered in domain!");
-        jmxDomain.getSourceServer().unregisterMBean(thingName);
-        if (queue.size() != 0)
-            fail(test+queue.size()+" notifs remain in queue "+queue);
-
-        server.registerMBean(jmxDomain, name);
-        if (!server.isRegistered(name))
-            fail(test+name+" is not registered again!");
-        popADD(queue, name, test);
-        if (queue.size() != 0)
-            fail(test+queue.size()+" notifs remain in queue "+queue);
-
-        server.registerMBean(thing,thingName);
-        if (!jmxDomain.getSourceServer().isRegistered(thingName))
-            fail(test+thingName+" is not registered in domain!");
-        popADD(queue, thingName, test);
-        server.unregisterMBean(thingName);
-        if (jmxDomain.getSourceServer().isRegistered(thingName))
-            fail(test+thingName+" is still registered in domain!");
-        popREM(queue, thingName, test);
-        if (queue.size() != 0)
-            fail(test+queue.size()+" notifs remain in queue "+queue);
-
-        System.out.println(test+" PASSED");
-    }
-
-
-
-    private static void fail(String msg) {
-        raise(new RuntimeException(msg));
-    }
-
-    private static void fail(String msg, Throwable cause) {
-        raise(new RuntimeException(msg,cause));
-    }
-
-    private static void raise(RuntimeException x) {
-        lastException = x;
-        exceptionCount++;
-        throw x;
-    }
-
-    private static volatile Exception lastException = null;
-    private static volatile int       exceptionCount = 0;
-
-    public static void main(String... args) throws Exception {
-        testCreateWithNull();
-
-        testRegisterSimple();
-        testRegisterNotifSimple();
-
-        testRegisterPseudoVirtual();
-        testRegisterNotifPseudoVirtual();
-
-        if (lastException != null)
-            throw lastException;
-    }
-}
--- a/test/javax/management/namespace/JMXNamespaceSecurityTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,274 +0,0 @@
-/*
- * 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 JMXNamespaceSecurityTest.java
- * @summary General JMXNamespaceSecurityTest test.
- * @author Daniel Fuchs
- * @bug 5072476 6299231
- * @run clean JMXNamespaceViewTest JMXNamespaceSecurityTest Wombat WombatMBean
- *            LazyDomainTest
- * @run build JMXNamespaceSecurityTest JMXNamespaceViewTest Wombat WombatMBean
- *            LazyDomainTest
- * @run main/othervm JMXNamespaceSecurityTest namespace.policy
- */
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXDomain;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.ClientContext;
-
-/**
- *
- * @author Sun Microsystems, Inc.
- */
-public class JMXNamespaceSecurityTest extends JMXNamespaceViewTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(JMXNamespaceSecurityTest.class.getName());
-
-    public static class NamedMBeanServerCreator
-            extends JMXNamespaceViewTest.MBeanServerConfigCreator {
-      public MBeanServer createMBeanServerFor(NamespaceConfig config) {
-            return MBeanServerFactory.
-                    createNamedMBeanServer(config.name,config.name);
-        }
-    }
-    /**
-     * Creates a config for a hierarchy of namespaces, mixing local namespaces
-     * and remote namespaces using the given protocol.
-     * @param protocol The protocol that should be used for remote namespaces.
-     * @return A namespace config hierarchy.
-     * @throws java.lang.Exception
-     */
-    public static NamespaceConfig[] makeConfig(String protocol)
-        throws Exception {
-        final NamespaceConfig[] config = {
-        // Top level namespace "top1" (local)
-        config("top1",wombats("wchief","w1","w2","w3"),
-                // top1//local1
-                config("local1",wombats("wchief","ww1","ww2")),
-                // top1//local2
-                config("local2",wombats("wchief","ww4","ww5","ww6"),
-                    // top1//local2//local3
-                    config("local3",wombats("wchief","www1","www2")),
-                    // top1//local2//rmi1
-                    config("rmi1",url(protocol),wombats("wchief","www3","www4","www5"))),
-                // top1//rmi2
-                config("rmi2",url(protocol),wombats("wchief","ww7","ww8","ww9"),
-                    // top1//rmi2//local4
-                    config("local4",wombats("wchief","www6","www7")),
-                    // top1//rmi2//rmi3
-                    config("rmi3",url(protocol),wombats("wchief","www3","www4","www5"),
-                        // top1//rmi2//rmi3//local5
-                        config("local5",wombats("wchief","wwww1"))))),
-        // Top level namespace "top2" (local)
-        config("top2",wombats("wchief","w21","w22","w23"),
-                // top2//local21
-                config("local21",wombats("wchief","ww21","ww22")),
-                // top2//rmi22
-                config("rmi22",url(protocol),wombats("wchief","ww27","ww28","ww29"),
-                    // top2//rmi22//local24
-                    config("local24",wombats("wchief","www26","www27")),
-                    // top2//rmi22//rmi23
-                    config("rmi23",url(protocol),wombats("wchief","www23","www24","www25"),
-                        // top2//rmi22//rmi23//local25
-                        config("local25",wombats("wchief","wwww21"))))),
-        // Top level namespace "top3" (remote)
-        config("top3",url(protocol),wombats("wchief","w31","w32","w33"),
-                // top3//local31
-                config("local31",wombats("wchief","ww31","ww32")),
-                // top3//rmi32
-                config("rmi32",url(protocol),wombats("wchief","ww37","ww38","ww39"),
-                    // top3//rmi32//local34
-                    config("local34",wombats("wchief","www36","www37")),
-                    // top3//rmi32//rmi33
-                    config("rmi33",url(protocol),wombats("wchief","www33","www34","www35"),
-                        // top3//rmi32//local35
-                        config("local35",wombats("wchief","wwww31"))))),
-        };
-        return config;
-    }
-
-    public static void test(MBeanServer server, NamespaceConfig[] namespaces)
-        throws Exception {
-        System.out.println("Launching test...");
-        List<JMXConnectorServer> cslist = load(server,
-                new NamedMBeanServerCreator(), namespaces);
-        Map<String,NamespaceConfig> inputMap =
-                new HashMap<String,NamespaceConfig>();
-
-        for (NamespaceConfig cfg : namespaces) {
-            fillMap(inputMap,"",cfg);
-        }
-        final MBeanServer platform = ManagementFactory.getPlatformMBeanServer();
-        //if (System.getProperty("jmx.wait")!=null) {
-            /*
-            // if we wanted to lazy load the platform MBeanServer:
-            final LazyDomainTest.MBeanServerLoader loader =
-                    new LazyDomainTest.MBeanServerLoader() {
-                public MBeanServer loadMBeanServer() {
-                    return ManagementFactory.getPlatformMBeanServer();
-                }
-            };
-            final LazyDomainTest.MBeanServerProxy proxy =
-                    new LazyDomainTest.MBeanServerProxy(loader);
-            final LazyDomainTest.LazyDomain domain =
-                    new LazyDomainTest.LazyDomain(proxy);
-            server.registerMBean(domain,
-                    JMXDomain.getDomainObjectName("java.lang"));
-            */
-            // Mount java.lang MBeans into our private server so that
-            // visualvm can connect.
-            server.registerMBean(
-                    new JMXDomain(platform),
-                    JMXDomain.getDomainObjectName("java.lang"));
-        //}
-        if (System.getProperty("jmx.wait")!=null) {
-            platform.registerMBean(new JMXNamespace(server),
-                    JMXNamespaces.getNamespaceObjectName("test"));
-        }
-
-        System.setSecurityManager(new SecurityManager());
-
-        // Some sanity checks... The policy file should allow access
-        // to java.lang MBeans.
-        final ObjectName platnames = new ObjectName("java.lang:*");
-        for (ObjectName o : platform.queryNames(platnames,null)) {
-            server.getMBeanInfo(o);
-        }
-        final Set<ObjectName> lang =
-                new HashSet<ObjectName>(server.queryNames(platnames, null));
-        lang.remove(JMXDomain.getDomainObjectName("java.lang"));
-        if (!lang.equals(platform.
-                queryNames(platnames, null)))
-            throw new Exception("Wrong list of platform names: "+lang);
-        System.out.println("Got all java.lang MBeans: "+lang);
-
-        // The policy file should allow to see all namespaces.
-        // check this...
-        final List<ObjectName> patterns = new ArrayList<ObjectName>();
-        final Set<String> paths = new TreeSet<String>();
-        final Set<String> uuids = new HashSet<String>();
-        patterns.add(new ObjectName("*//:*"));
-        while (patterns.size()>0) {
-            System.out.println("server.queryNames("+patterns.get(0)+",null)");
-            Set<ObjectName> names = server.queryNames(patterns.remove(0),null);
-            System.out.println("found: "+names);
-
-            for (ObjectName no : names) {
-                final String uuid = (String) server.getAttribute(no, "UUID");
-                if (uuids.contains(uuid)) {
-                    System.out.print("namespace "+no+", uuid="+uuid+
-                            " already parsed. Skipping");
-                    continue;
-                }
-                uuids.add(uuid);
-                patterns.add(new ObjectName(no.getDomain()+"*//:*"));
-                System.out.println("added pattern: "+
-                        new ObjectName(no.getDomain()+"*//:*"));
-                if (no.getDomain().endsWith(ClientContext.NAMESPACE+
-                        JMXNamespaces.NAMESPACE_SEPARATOR)) continue;
-                paths.add(no.getDomain().substring(0,
-                        no.getDomain().length()-
-                        JMXNamespaces.NAMESPACE_SEPARATOR.length()));
-            }
-        }
-        final TreeSet<String> expected = new TreeSet<String>(inputMap.keySet());
-        if (!expected.equals(paths)) {
-            throw new Exception("wrong set of namespaces, expected "+
-                    expected+", got "+paths);
-        }
-
-        System.out.println("Got all namespaces: "+paths);
-
-        // Check that we can see all wombats.
-        //
-        ObjectName wchief =
-                new ObjectName("top1//rmi2//wombat:name=wchief,type=Wombat");
-        String caption = (String) server.getAttribute(wchief,"Caption");
-        System.out.println("wchief says "+caption);
-        Object mood = server.getAttribute(wchief,"Mood");
-        System.out.println("wchief's mood on a scale of 100 is "+mood);
-
-        ObjectName wchief2 =
-                new ObjectName("top1//wombat:name=wchief,type=Wombat");
-        String caption2 = (String) server.getAttribute(wchief2,"Caption");
-        System.out.println("wchief2 says "+caption2);
-        try {
-            Object mood2 = server.getAttribute(wchief2,"Mood");
-            System.out.println("wchief2's mood on a scale of 100 is "+mood2);
-            throw new Exception("Expected security exception for "+
-                    "getAttribute("+wchief2+", \"Mood\"");
-        } catch (SecurityException x) {
-            System.out.println("wchief2's mood is unavailable: "+x);
-        }
-        try {
-            exportAndWaitIfNeeded(server);
-        } finally {
-            closeAll(cslist);
-        }
-
-    }
-    /** Creates a new instance of JMXNamespaceTest */
-    public JMXNamespaceSecurityTest() {
-    }
-
-    public static void main(String[] args) throws Exception {
-        String osName = System.getProperty("os.name");
-        System.out.println("os.name = " + osName);
-        if (!osName.equals("SunOS")) {
-            System.out.println("This test runs on Solaris only.");
-            System.out.println("Bye! Bye!");
-            return;
-        }
-        final String policy = System.getProperty("test.src") +
-                File.separator + args[0];
-        System.out.println("PolicyFile = " + policy);
-        System.setProperty("java.security.policy", policy);
-        if (!new File(System.getProperty("java.security.policy")).canRead())
-            throw new IOException("no such file: "+
-                    System.getProperty("java.security.policy"));
-        test(MBeanServerFactory.createNamedMBeanServer("root","root"),
-                makeConfig("rmi"));
-    }
-
-}
--- a/test/javax/management/namespace/JMXNamespaceTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,511 +0,0 @@
-/*
- * 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 JMXNamespaceTest.java
- * @summary General JMXNamespace test.
- * @bug 5072476
- * @author Daniel Fuchs
- * @run clean JMXNamespaceTest
- *            Wombat WombatMBean JMXRemoteTargetNamespace
- *            NamespaceController NamespaceControllerMBean
- * @compile -XDignore.symbol.file=true JMXNamespaceTest.java
- *            Wombat.java WombatMBean.java JMXRemoteTargetNamespace.java
- *            NamespaceController.java NamespaceControllerMBean.java
- * @run main/othervm JMXNamespaceTest
- */
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.NotificationEmitter;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaceMBean;
-import javax.management.namespace.JMXRemoteNamespaceMBean;
-import javax.management.namespace.MBeanServerConnectionWrapper;
-import javax.management.namespace.MBeanServerSupport;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- *
- * @author Sun Microsystems, Inc.
- */
-public class JMXNamespaceTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(JMXNamespaceTest.class.getName());
-
-    /** Creates a new instance of JMXNamespaceTest */
-    public JMXNamespaceTest() {
-    }
-
-    public static class WombatRepository extends MBeanServerSupport {
-        final Wombat wombat;
-        final StandardMBean mbean;
-        final ObjectName wombatName;
-
-        public WombatRepository(ObjectName wombatName) {
-            try {
-                wombat = new Wombat();
-                mbean  = wombat;
-                this.wombatName = wombatName;
-                wombat.preRegister(null,wombatName);
-            } catch (Exception x) {
-                throw new IllegalArgumentException(x);
-            }
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-            throws InstanceNotFoundException {
-            if (wombatName.equals(name)) return mbean;
-            else throw new InstanceNotFoundException(String.valueOf(name));
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            final Set<ObjectName> res = Collections.singleton(wombatName);
-            return res;
-        }
-
-        @Override
-        public NotificationEmitter
-                getNotificationEmitterFor(ObjectName name)
-            throws InstanceNotFoundException {
-            final DynamicMBean mb = getDynamicMBeanFor(name);
-            if (mb instanceof NotificationEmitter)
-                return (NotificationEmitter)mb;
-            return null;
-        }
-    }
-
-    public static class SimpleTest {
-            public final String   descr;
-            private final Class<?> testClass;
-            private final Method method;
-            public SimpleTest(String descr) {
-                this.descr = descr;
-                this.testClass = JMXNamespaceTest.class;
-                try {
-                    method = testClass.
-                        getDeclaredMethod(descr,SimpleTestConf.class,
-                            Object[].class);
-                } catch (NoSuchMethodException x) {
-                    throw new IllegalArgumentException(descr+": test not found",
-                            x);
-                }
-            }
-
-            public void run(SimpleTestConf conf, Object... args)
-                throws Exception {
-                try {
-                    method.invoke(null,conf,args);
-                } catch (InvocationTargetException x) {
-                    final Throwable cause = x.getCause();
-                    if (cause instanceof Exception) throw (Exception)cause;
-                    if (cause instanceof Error) throw (Error)cause;
-                    throw x;
-                }
-            }
-    }
-
-    public static class SimpleTestConf {
-        public final  Wombat wombat;
-        public final  StandardMBean mbean;
-        public final  String dirname;
-        public final  ObjectName handlerName;
-        public final  ObjectName wombatNickName;
-        public final  ObjectName wombatName;
-        public final  JMXNamespace wombatNamespace;
-        public final  MBeanServer server;
-        public final  WombatMBean proxy;
-        public SimpleTestConf(String[] args) throws Exception {
-            wombat = new Wombat();
-            mbean = wombat;
-            dirname = "wombat";
-            handlerName =
-                    new ObjectName(dirname+"//:type=JMXNamespace");
-
-            wombatNickName =
-                    new ObjectName("burrow:type=Wombat");
-
-            wombatName =
-                    new ObjectName(dirname+"//"+wombatNickName);
-
-            wombatNamespace =
-                    new JMXNamespace(
-                    new WombatRepository(wombatNickName));
-
-            server = ManagementFactory.getPlatformMBeanServer();
-            System.out.println(handlerName+" registered="+
-                    server.isRegistered(handlerName));
-            server.registerMBean(wombatNamespace,handlerName);
-
-            try {
-                proxy = JMX.newMBeanProxy(server,wombatName,
-                                WombatMBean.class);
-            } catch (Exception x) {
-                server.unregisterMBean(handlerName);
-                throw x;
-            }
-        }
-
-        public void close() {
-            try {
-                server.unregisterMBean(handlerName);
-            } catch (Exception x) {
-                System.out.println("Failed to close: " + x);
-                x.printStackTrace();
-            }
-        }
-
-        public void test(SimpleTest test,Object... args)
-            throws Exception {
-            try {
-                test.run(this,args);
-                passed++;
-            } catch (Exception x) {
-                failed++;
-                System.err.println(test.descr+" failed: " + x);
-                x.printStackTrace();
-            }
-        }
-
-        public volatile int failed = 0;
-        public volatile int passed = 0;
-    }
-
-    static void checkValue(String name,Object expected, Object returned)
-        throws InvalidAttributeValueException {
-        if (Collections.singletonList(expected).
-                equals(Collections.singletonList(returned))) return;
-
-        throw new InvalidAttributeValueException("Bad value for "+
-                name+": ["+returned+"] - was expecting ["+expected+"]");
-    }
-
-    // ---------------------------------------------------------------
-    // SIMPLE TESTS BEGIN HERE
-    // ---------------------------------------------------------------
-
-    static void getCaptionTest(SimpleTestConf env, Object... args)
-        throws Exception {
-        System.out.println(env.proxy.getCaption());
-    }
-
-    static void setCaptionTest(SimpleTestConf env, Object... args)
-        throws Exception {
-        env.proxy.setCaption((String)args[0]);
-        final String result = env.proxy.getCaption();
-        System.out.println(result);
-        checkValue("Caption",args[0],result);
-    }
-
-    static void queryNamesTest1(SimpleTestConf env, Object... args)
-        throws Exception {
-        final ObjectName pat =
-                new ObjectName(env.handlerName.getDomain()+"*:*");
-        final Set<ObjectName> res =
-                env.server.queryNames(pat,null);
-        System.out.println("queryNamesTest1: "+res);
-        checkValue("names",Collections.singleton(env.wombatName),res);
-    }
-
-    static void queryNamesTest2(SimpleTestConf env, Object... args)
-        throws Exception {
-        final ObjectName pat =
-                new ObjectName("*:"+
-                env.wombatName.getKeyPropertyListString());
-        final Set<ObjectName> res =
-                env.server.queryNames(pat,null);
-        System.out.println("queryNamesTest2: "+res);
-        checkValue("names",Collections.emptySet(),res);
-    }
-
-    static void getDomainsTest(SimpleTestConf env, Object... args)
-        throws Exception {
-        final List<String> domains =
-                Arrays.asList(env.server.getDomains());
-        System.out.println("getDomainsTest: "+domains);
-        if (domains.contains(env.wombatName.getDomain()))
-            throw new InvalidAttributeValueException("domain: "+
-                    env.wombatName.getDomain());
-        if (!domains.contains(env.handlerName.getDomain()))
-            throw new InvalidAttributeValueException("domain not found: "+
-                    env.handlerName.getDomain());
-    }
-
-    // ---------------------------------------------------------------
-    // SIMPLE TESTS END HERE
-    // ---------------------------------------------------------------
-
-    private static void simpleTest(String[] args) {
-        final SimpleTestConf conf;
-        try {
-            conf = new SimpleTestConf(args);
-            try {
-                conf.test(new SimpleTest("getCaptionTest"));
-                conf.test(new SimpleTest("setCaptionTest"),
-                        "I am a new Wombat!");
-                conf.test(new SimpleTest("queryNamesTest1"));
-                conf.test(new SimpleTest("queryNamesTest2"));
-                conf.test(new SimpleTest("getDomainsTest"));
-            } finally {
-                conf.close();
-            }
-        } catch (Exception x) {
-            System.err.println("simpleTest FAILED: " +x);
-            x.printStackTrace();
-            throw new RuntimeException(x);
-        }
-        System.out.println("simpleTest: "+conf.passed+
-                " PASSED, " + conf.failed + " FAILED.");
-        if (conf.failed>0) {
-            System.err.println("simpleTest FAILED ["+conf.failed+"]");
-            throw new RuntimeException("simpleTest FAILED ["+conf.failed+"]");
-        } else {
-            System.err.println("simpleTest PASSED ["+conf.passed+"]");
-        }
-    }
-
-    public static void recursiveTest(String[] args) {
-        final SimpleTestConf conf;
-        try {
-            conf = new SimpleTestConf(args);
-            try {
-                final JMXServiceURL url =
-                        new JMXServiceURL("rmi","localHost",0);
-                final Map<String,Object> empty = Collections.emptyMap();
-                final JMXConnectorServer server =
-                        JMXConnectorServerFactory.newJMXConnectorServer(url,
-                        empty,conf.server);
-                server.start();
-                final JMXServiceURL address = server.getAddress();
-                final JMXConnector client =
-                        JMXConnectorFactory.connect(address,
-                        empty);
-                final String[] signature = {
-                    JMXServiceURL.class.getName(),
-                    Map.class.getName(),
-                };
-                final String[] signature2 = {
-                    JMXServiceURL.class.getName(),
-                    Map.class.getName(),
-                    String.class.getName(),
-                };
-                final Object[] params = {
-                    address,
-                    null,
-                };
-                final MBeanServerConnection c =
-                        client.getMBeanServerConnection();
-                final ObjectName dirName1 =
-                        new ObjectName("kanga//:type=JMXNamespace");
-                c.createMBean(JMXRemoteTargetNamespace.class.getName(),
-                              dirName1, params,signature);
-                c.invoke(dirName1, "connect", null, null);
-                try {
-                    final MemoryMXBean memory =
-                            JMX.newMXBeanProxy(c,
-                            new ObjectName("kanga//"+
-                            ManagementFactory.MEMORY_MXBEAN_NAME),
-                            MemoryMXBean.class);
-                    System.out.println("HeapMemory #1: "+
-                            memory.getHeapMemoryUsage().toString());
-                    final MemoryMXBean memory2 =
-                            JMX.newMXBeanProxy(c,
-                            new ObjectName("kanga//kanga//"+
-                            ManagementFactory.MEMORY_MXBEAN_NAME),
-                            MemoryMXBean.class);
-                    System.out.println("HeapMemory #2: "+
-                            memory2.getHeapMemoryUsage().toString());
-                    final Object[] params2 = {
-                        address,
-                        null,
-                        "kanga//kanga"
-                        // "kanga//kanga//roo//kanga", <= cycle
-                    };
-                    final ObjectName dirName2 =
-                            new ObjectName("kanga//roo//:type=JMXNamespace");
-                    c.createMBean(JMXRemoteTargetNamespace.class.getName(),
-                              dirName2, params2, signature2);
-                    System.out.println(dirName2 + " created!");
-                    JMX.newMBeanProxy(c,dirName2,
-                            JMXRemoteNamespaceMBean.class).connect();
-                    try {
-                        final ObjectName wombatName1 =
-                                new ObjectName("kanga//roo//"+conf.wombatName);
-                        final ObjectName wombatName2 =
-                                new ObjectName("kanga//roo//"+wombatName1);
-                        final WombatMBean wombat1 =
-                                JMX.newMBeanProxy(c,wombatName1,WombatMBean.class);
-                        final WombatMBean wombat2 =
-                                JMX.newMBeanProxy(c,wombatName2,WombatMBean.class);
-                        final String newCaption="I am still the same old wombat";
-                        wombat1.setCaption(newCaption);
-                        final String caps = conf.proxy.getCaption();
-                        System.out.println("Caption: "+caps);
-                        checkValue("Caption",newCaption,caps);
-                        final String caps1 = wombat1.getCaption();
-                        System.out.println("Caption #1: "+caps1);
-                        checkValue("Caption #1",newCaption,caps1);
-                        final String caps2 = wombat2.getCaption();
-                        System.out.println("Caption #2: "+caps2);
-                        checkValue("Caption #2",newCaption,caps2);
-                        final ObjectInstance instance =
-                                NamespaceController.createInstance(conf.server);
-                        final NamespaceControllerMBean controller =
-                                JMX.newMBeanProxy(conf.server,instance.getObjectName(),
-                                                  NamespaceControllerMBean.class);
-                        final String[] dirs = controller.findNamespaces();
-                        System.out.println("directories: " +
-                                Arrays.asList(dirs));
-                        final int depth = 4;
-                        final String[] dirs2 = controller.findNamespaces(null,null,depth);
-                        System.out.println("directories[depth="+depth+"]: " +
-                                Arrays.asList(dirs2));
-                        for (String dir : dirs2) {
-                            if (dir.endsWith(JMXNamespaces.NAMESPACE_SEPARATOR))
-                                dir = dir.substring(0,dir.length()-
-                                        JMXNamespaces.NAMESPACE_SEPARATOR.length());
-                            if (dir.split(JMXNamespaces.NAMESPACE_SEPARATOR).length
-                                        > (depth+1)) {
-                                throw new RuntimeException(dir+": depth exceeds "+depth);
-                            }
-                            final ObjectName handlerName =
-                                    JMXNamespaces.getNamespaceObjectName(dir);
-                            final JMXNamespaceMBean handler =
-                                    JMX.newMBeanProxy(conf.server,handlerName,
-                                    JMXNamespaceMBean.class);
-                            try {
-                            System.err.println("Directory "+dir+" domains: "+
-                                    Arrays.asList(handler.getDomains()));
-                            System.err.println("Directory "+dir+" default domain: "+
-                                    handler.getDefaultDomain());
-                            System.err.println("Directory "+dir+" MBean count: "+
-                                    handler.getMBeanCount());
-                            } catch(Exception x) {
-                                System.err.println("get info failed for " +
-                                        dir +", "+handlerName+": "+x);
-                                x.getCause().printStackTrace();
-                                throw x;
-                            }
-                        }
-
-                    } finally {
-                        c.unregisterMBean(dirName2);
-                    }
-                } finally {
-                    c.unregisterMBean(dirName1);
-                    client.close();
-                    server.stop();
-                }
-            } finally {
-                conf.close();
-            }
-            System.err.println("recursiveTest PASSED");
-        } catch (Exception x) {
-            System.err.println("recursiveTest FAILED: " +x);
-            x.printStackTrace();
-            throw new RuntimeException(x);
-        }
-    }
-
-    public static void verySimpleTest(String[] args) {
-        System.err.println("verySimpleTest: starting");
-        try {
-            final MBeanServer srv = MBeanServerFactory.createMBeanServer();
-            srv.registerMBean(new JMXNamespace(
-                    JMXNamespaces.narrowToNamespace(srv, "foo")),
-                    JMXNamespaces.getNamespaceObjectName("foo"));
-            throw new Exception("Excpected IllegalArgumentException not raised.");
-        } catch (IllegalArgumentException x) {
-            System.err.println("verySimpleTest: got expected exception: "+x);
-        } catch (Exception x) {
-            System.err.println("verySimpleTest FAILED: " +x);
-            x.printStackTrace();
-            throw new RuntimeException(x);
-        }
-        System.err.println("verySimpleTest: PASSED");
-    }
-
-    public static void verySimpleTest2(String[] args) {
-        System.err.println("verySimpleTest2: starting");
-        try {
-            final MBeanServer srv = MBeanServerFactory.createMBeanServer();
-            final JMXConnectorServer cs = JMXConnectorServerFactory.
-                    newJMXConnectorServer(new JMXServiceURL("rmi",null,0),
-                    null, srv);
-            cs.start();
-            final JMXConnector cc = JMXConnectorFactory.connect(cs.getAddress());
-
-            srv.registerMBean(new JMXNamespace(
-                    new MBeanServerConnectionWrapper(
-                            JMXNamespaces.narrowToNamespace(
-                                cc.getMBeanServerConnection(),
-                                "foo"))),
-                    JMXNamespaces.getNamespaceObjectName("foo"));
-            throw new Exception("Excpected IllegalArgumentException not raised.");
-        } catch (IllegalArgumentException x) {
-            System.err.println("verySimpleTest2: got expected exception: "+x);
-        } catch (Exception x) {
-            System.err.println("verySimpleTest2 FAILED: " +x);
-            x.printStackTrace();
-            throw new RuntimeException(x);
-        }
-        System.err.println("verySimpleTest2: PASSED");
-    }
-
-    public static void main(String[] args) {
-        simpleTest(args);
-        recursiveTest(args);
-        verySimpleTest(args);
-        verySimpleTest2(args);
-    }
-
-}
--- a/test/javax/management/namespace/JMXNamespaceViewTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,546 +0,0 @@
-/*
- * 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 JMXNamespaceViewTest.java
- * @summary Test the JMXNamespaceView class.
- * @bug 5072476
- * @author Daniel Fuchs
- * @run clean JMXNamespaceViewTest Wombat WombatMBean
- * @run build JMXNamespaceViewTest Wombat WombatMBean
- * @run main JMXNamespaceViewTest
- */
-
-
-import java.lang.management.ManagementFactory;
-import java.net.ServerSocket;
-import java.rmi.registry.LocateRegistry;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.management.ClientContext;
-import javax.management.JMException;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaceView;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXRemoteNamespace;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * A simple test to test the JMXNamespaceViewTest...
- * @author dfuchs
- */
-public class JMXNamespaceViewTest {
-
-    /**
-     * Describe the configuration of a namespace
-     */
-    public static class NamespaceConfig {
-        /** name of the namespace - no // allowed **/
-        public String name;
-        /**
-         * JMXServiceURL through which the namespace is exported, if it
-         * is a remote namespace. {@code null} if the namespace is local.
-         * This is an inpur URL - eg: new JMXServiceURL("rmi",null,0).toString()
-         * is acceptable here.
-         */
-        public String jmxurl;
-        /**
-         * Values of the name= key for each WombatMBean contained in the
-         * namespace.
-         */
-        public String[] wombats;
-        /** list of child namespace **/
-        public NamespaceConfig[] children;
-    }
-
-    /**
-     * Creates a NamespaceConfig record for a local namespace.
-     * @param name     name  of the namespace
-     * @param wombats  names of WombatMBean it should contain.
-     * @return a NamespaceConfig.
-     */
-    public static NamespaceConfig config(String name, String[] wombats) {
-        return config(name,null,wombats);
-    }
-
-    /**
-     * Creates a NamespaceConfig record for a remote namespace.
-     * @param name    name  of the namespace
-     * @param jmxurl  input JMXServiceURL for creating the JMXConnectorServer
-     * @param wombats names of WombatMBean it should contain.
-     * @return a NamespaceConfig.
-     */
-    public static NamespaceConfig config(String name, String jmxurl,
-            String[] wombats) {
-        return config(name,jmxurl,wombats,(NamespaceConfig[])null);
-    }
-
-    /**
-     * Creates a NamespaceConfig record for a local namespace.
-     * @param name     name  of the namespace
-     * @param wombats  names of WombatMBean it should contain.
-     * @param children list  of sub namespaces.
-     * @return a NamespaceConfig.
-     */
-    public static NamespaceConfig config(String name, String[] wombats,
-            NamespaceConfig... children) {
-        return config(name,null,wombats,children);
-    }
-
-    /**
-     * Creates a NamespaceConfig record for a remote namespace.
-     * @param name    name  of the namespace
-     * @param jmxurl  input JMXServiceURL for creating the JMXConnectorServer
-     * @param wombats names of WombatMBean it should contain.
-     * @param children list  of sub namespaces.
-     * @return a NamespaceConfig.
-     */
-    static NamespaceConfig config(String name, String jmxurl, String[] wombats,
-            NamespaceConfig... children) {
-         final NamespaceConfig cfg = new NamespaceConfig();
-         cfg.name=name; cfg.jmxurl=jmxurl; cfg.wombats=wombats;
-         cfg.children=children;
-         return cfg;
-    }
-
-    /**
-     * Returns the given names. This is a utility method to ease code
-     * reading.
-     * @param names names of Wombat MBeans.
-     * @return the given names.
-     */
-    static String[] wombats(String... names) {
-        return names;
-    }
-
-    /**
-     * Creates a JMXServiceURL string for the given protocol.
-     * This is also a utility method to ease code reading.
-     * @param protocol The protocol name (e.g. "rmi")
-     * @return A JMXServiceURL string.
-     * @throws Exception if creation of the JMXServiceURL fails.
-     */
-    static String url(String protocol) throws Exception {
-        return new JMXServiceURL(protocol,null,0).toString();
-    }
-
-    /**
-     * Creates a config for a hierarchy of namespaces, mixing local namespaces
-     * and remote namespaces using the given protocol.
-     * @param protocol The protocol that should be used for remote namespaces.
-     * @return A namespace config hierarchy.
-     * @throws java.lang.Exception
-     */
-    public static NamespaceConfig[] makeConfig(String protocol)
-        throws Exception {
-        final NamespaceConfig[] config = {
-        // Top level namespace "top1" (local)
-        config("top1",wombats("wchief","w1","w2","w3"),
-                // top1//local1
-                config("local1",wombats("wchief","ww1","ww2")),
-                // top1//local2
-                config("local2",wombats("wchief","ww4","ww5","ww6"),
-                    // top1//local2//local3
-                    config("local3",wombats("wchief","www1","www2")),
-                    // top1//local2//rmi1
-                    config("rmi1",url(protocol),wombats("wchief","www3","www4","www5"))),
-                // top1//rmi2
-                config("rmi2",url(protocol),wombats("wchief","ww7","ww8","ww9"),
-                    // top1//rmi2//local4
-                    config("local4",wombats("wchief","www6","www7")),
-                    // top1//rmi2//rmi3
-                    config("rmi3",url(protocol),wombats("wchief","www3","www4","www5"),
-                        // top1//rmi2//rmi3//local5
-                        config("local5",wombats("wchief","wwww1"))))),
-        // Top level namespace "top2" (local)
-        config("top2",wombats("wchief","w21","w22","w23"),
-                // top2//local21
-                config("local21",wombats("wchief","ww21","ww22")),
-                // top2//rmi22
-                config("rmi22",url(protocol),wombats("wchief","ww27","ww28","ww29"),
-                    // top2//rmi22//local24
-                    config("local24",wombats("wchief","www26","www27")),
-                    // top2//rmi22//rmi23
-                    config("rmi23",url(protocol),wombats("wchief","www23","www24","www25"),
-                        // top2//rmi22//rmi23//local25
-                        config("local25",wombats("wchief","wwww21"))))),
-        // Top level namespace "top3" (remote)
-        config("top3",url(protocol),wombats("wchief","w31","w32","w33"),
-                // top3//local31
-                config("local31",wombats("wchief","ww31","ww32")),
-                // top3//rmi32
-                config("rmi32",url(protocol),wombats("wchief","ww37","ww38","ww39"),
-                    // top3//rmi32//local34
-                    config("local34",wombats("wchief","www36","www37")),
-                    // top3//rmi32//rmi33
-                    config("rmi33",url(protocol),wombats("wchief","www33","www34","www35"),
-                        // top3//rmi32//local35
-                        config("local35",wombats("wchief","wwww31"))))),
-        };
-        return config;
-    }
-
-    /**
-     * Close all connector servers in the list.
-     * @param cslist List of connector servers to close.
-     */
-    public static void closeAll(List<JMXConnectorServer> cslist) {
-            for (JMXConnectorServer cs : cslist) {
-                try {
-                    cs.stop();
-                } catch (Exception xx) {
-                    System.err.println("Failed to stop connector: " + xx);
-                }
-            }
-    }
-
-    public static class MBeanServerConfigCreator {
-        public MBeanServer createMBeanServerFor(NamespaceConfig config) {
-            return MBeanServerFactory.newMBeanServer();
-        }
-    }
-
-    /**
-     * Load the given namespace configuration inside the given MBeanServer.
-     * Return a list of connector servers created in the process.
-     * @param server      The MBeanServer in which the namespaces must
-     *                    be created.
-     * @param namespaces  The list of namespaces to create.
-     * @return a list of started connector servers.
-     * @throws java.lang.Exception failed to create the specified namespaces.
-     */
-    public static List<JMXConnectorServer> load(MBeanServer server,
-           MBeanServerConfigCreator factory,
-           NamespaceConfig... namespaces) throws Exception {
-        final List<JMXConnectorServer> cslist =
-                new ArrayList<JMXConnectorServer>();
-        try {
-            final ObjectName creator =
-                    new ObjectName("jmx.creator:type=JMXNamespaceCreator");
-            if (System.getProperty("jmx.wait")!=null
-                    && !server.isRegistered(creator)) {
-                server.registerMBean(new JMXNamespaceCreator(),creator);
-            }
-            for (NamespaceConfig cfg : namespaces) {
-                final MBeanServer srv = factory.createMBeanServerFor(cfg);
-                if (System.getProperty("jmx.wait")!=null
-                    && !srv.isRegistered(creator)) {
-                    srv.registerMBean(new JMXNamespaceCreator(),creator);
-                }
-                if (cfg.wombats != null) {
-                    for (String w : cfg.wombats) {
-                        final ObjectName n =
-                                new ObjectName("wombat:type=Wombat,name=" + w);
-                        final WombatMBean ww = new Wombat();
-                        srv.registerMBean(ww, n);
-                    }
-                }
-                if (cfg.children != null) {
-                    cslist.addAll(load(srv, factory, cfg.children));
-                }
-                JMXNamespace nm;
-                if (cfg.jmxurl == null) {
-                    nm = new JMXNamespace(srv);
-                } else {
-                    JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL(cfg.jmxurl),
-                            null, srv);
-                    srv.registerMBean(cs,
-                            new ObjectName("jmx.remote:type=JMXConnectorServer"));
-                    cs.start();
-                    cslist.add(cs);
-                    nm = JMXRemoteNamespace.
-                            newJMXRemoteNamespace(cs.getAddress(),
-                            null);
-                }
-                server.registerMBean(nm,
-                        JMXNamespaces.getNamespaceObjectName(cfg.name));
-                if (nm instanceof JMXRemoteNamespace) {
-                    server.invoke(
-                            JMXNamespaces.getNamespaceObjectName(cfg.name),
-                            "connect", null, null);
-                }
-            }
-        } catch (Exception x) {
-            closeAll(cslist);
-            throw x;
-        }
-        return cslist;
-    }
-
-    /**
-     * Add an entry {@code <path,NamespaceConfig>} in the map for the given
-     * namespace and its subnamespaces.
-     * @param map    A {@code Map<path,NamespaceConfig>}.
-     * @param parent The path of the parent workspace.
-     * @param cfg    The NamespaceConfig hierarchy to index in the map.
-     */
-    public static void fillMap(Map<String,NamespaceConfig> map, String parent,
-            NamespaceConfig cfg) {
-
-        final String where;
-        if (parent == null || parent.equals(""))
-            where=cfg.name;
-        else
-            where=parent+JMXNamespaces.NAMESPACE_SEPARATOR+cfg.name;
-        map.put(where,cfg);
-        if (cfg.children==null) return;
-        for(NamespaceConfig child:cfg.children) {
-            fillMap(map,where,child);
-        }
-    }
-
-    /**
-     * Compare a list of namespace names obtained from JMXNamespaceView.list()
-     * with the expected clildren list of the corresponding NamespaceConfig.
-     * @param list      A list of namespace names
-     * @param children  A list of NamespaceConfig correspondng to expected
-     *                  namespace.
-     * @param fail      If true and the comparison yields false, throws an
-     *                  exception instead of simply returning false.
-     * @return true if OK, false if NOK.
-     */
-    private static boolean compare(String[] list, NamespaceConfig[] children,
-            boolean fail) {
-        final List<String> found = new ArrayList<String>(Arrays.asList(list));
-        if (found.contains(ClientContext.NAMESPACE))
-            found.remove(ClientContext.NAMESPACE);
-
-        if (children == null && found.size()==0) return  true;
-        if (children == null && fail == false) return false;
-        if (children == null) throw new RuntimeException(
-                "No child expected. Found "+Arrays.toString(list));
-        final Set<String> names = new HashSet<String>();
-        for (NamespaceConfig cfg : children) {
-            names.add(cfg.name);
-            if (found.contains(cfg.name)) continue;
-            if (!fail) return false;
-            throw new RuntimeException(cfg.name+" not found in "+
-                    found);
-        }
-        found.removeAll(names);
-        if (found.size()==0) return true;
-        if (fail==false) return false;
-        throw new RuntimeException("found additional namespaces: "+
-                found);
-    }
-
-    /**
-     * Compares the result of queryNames(null,null) with a set of expected
-     * wombats.
-     * @param where    The path of the namespace that was queried.
-     * @param list     The set of ObjectNames found.
-     * @param wombats  The expected list of wombats.
-     * @param fail      If true and the comparison yields false, throws an
-     *                  exception instead of simply returning false.
-     * @return true if OK, false if NOK.
-     * @throws java.lang.Exception something went wrong.
-     */
-    private static boolean compare(String where,
-            Set<ObjectName>list, String[] wombats,
-            boolean fail) throws Exception {
-        final Set<ObjectName> found = new HashSet<ObjectName>();
-        final Set<ObjectName> expected = new HashSet<ObjectName>();
-        for (ObjectName n : list) {
-            if ("Wombat".equals(n.getKeyProperty("type")))
-               found.add(n);
-        }
-        for(String w : wombats) {
-            final ObjectName n =
-                    new ObjectName("wombat:type=Wombat,name=" + w);
-            expected.add(n);
-            if (found.contains(n)) continue;
-            if (fail == false) return false;
-            throw new RuntimeException(where+
-                    ": Wombat "+w+" not found in "+found);
-        }
-        found.removeAll(expected);
-        if (found.size()==0) {
-            System.out.println(where+": found all expected: "+expected);
-            return true;
-        }
-        if (fail==false) return false;
-        throw new RuntimeException(where+": found additional MBeans: "+
-                found);
-    }
-
-    /**
-     * A generic test to test JMXNamespaceView over a namespace configuration.
-     * @param server      The MBeanServer in which to load the namespace
-     *                    config.
-     * @param namespaces  The namespace config to run the test over...
-     * @throws java.lang.Exception
-     */
-    public static void doTest(MBeanServer server, NamespaceConfig... namespaces)
-            throws Exception {
-        List<JMXConnectorServer> cslist = load(server,
-                new MBeanServerConfigCreator(), namespaces);
-        Map<String,NamespaceConfig> inputMap =
-                new HashMap<String,NamespaceConfig>();
-
-        for (NamespaceConfig cfg : namespaces) {
-            fillMap(inputMap,"",cfg);
-        }
-        try {
-            final JMXNamespaceView root = new JMXNamespaceView(server);
-            List<JMXNamespaceView> vlist = new ArrayList<JMXNamespaceView>();
-            vlist.add(root);
-
-            while (!vlist.isEmpty()) {
-                JMXNamespaceView v = vlist.remove(0);
-                final String where = v.isRoot()?"root":v.where();
-                System.out.println(where+": "+
-                   v.getMBeanServerConnection().queryNames(null,null));
-                for (String ns : v.list()) {
-                    final JMXNamespaceView down = v.down(ns);
-                    vlist.add(down);
-                    if (!down.where().equals(v.isRoot()?ns:where+
-                            JMXNamespaces.NAMESPACE_SEPARATOR+ns)) {
-                        throw new RuntimeException("path of "+down.where()+
-                            " should be "+(v.isRoot()?ns:where+
-                            JMXNamespaces.NAMESPACE_SEPARATOR+ns));
-                    }
-                    if (down.up().equals(v)) continue;
-                    throw new RuntimeException("parent of "+down.where()+
-                            " should be "+where);
-                }
-                final NamespaceConfig[] children;
-                final NamespaceConfig   cfg;
-                if (v.isRoot()) {
-                    children=namespaces;
-                    cfg = null;
-                } else {
-                    cfg = inputMap.get(where);
-                    children = cfg==null?null:cfg.children;
-                }
-                compare(v.list(),children,true);
-                if (!v.isRoot()) {
-                    if (where.endsWith(ClientContext.NAMESPACE)) {
-                        System.out.println(where+": skipping queryNames analysis");
-                        continue;
-                    }
-                    //System.out.println(where+": cfg is: "+cfg);
-                    compare(where,v.getMBeanServerConnection().
-                        queryNames(null, null),cfg.wombats,true);
-                }
-            }
-
-            exportAndWaitIfNeeded(server);
-        } finally {
-            closeAll(cslist);
-        }
-    }
-
-    public static interface JMXNamespaceCreatorMBean {
-        public ObjectInstance createLocalNamespace(String namespace)
-                throws JMException ;
-        public void removeLocalNamespace(String namespace)
-                throws JMException;
-    }
-
-    public static class JMXNamespaceCreator
-            implements MBeanRegistration,
-                      JMXNamespaceCreatorMBean {
-
-        private volatile MBeanServer mbeanServer;
-
-        public ObjectInstance createLocalNamespace(String namespace)
-            throws JMException {
-            return mbeanServer.registerMBean(
-                    new JMXNamespace(MBeanServerFactory.newMBeanServer()),
-                    JMXNamespaces.getNamespaceObjectName(namespace));
-        }
-
-        public void removeLocalNamespace(String namespace)
-            throws JMException {
-            mbeanServer.unregisterMBean(
-                    JMXNamespaces.getNamespaceObjectName(namespace));
-        }
-
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-                throws Exception {
-            mbeanServer = server;
-            return name;
-        }
-
-        public void postRegister(Boolean registrationDone) {
-        }
-
-        public void preDeregister() throws Exception {
-         }
-
-        public void postDeregister() {
-        }
-
-    }
-
-    public static void exportAndWaitIfNeeded(MBeanServer server)
-        throws Exception {
-                if (System.getProperty("jmx.wait")!=null) {
-                final int port = getPortFor("rmi");
-                LocateRegistry.createRegistry(port);
-                final JMXServiceURL url =
-                        new JMXServiceURL("rmi",null,port,
-                        "/jndi/rmi://localhost:"+port+"/jmxrmi");
-                final JMXConnectorServer cs =
-                        JMXConnectorServerFactory.
-                        newJMXConnectorServer(url, null, server);
-                cs.start();
-                try {
-                    System.out.println("RMI Server waiting at: "+cs.getAddress());
-                    System.in.read();
-                } finally {
-                    cs.stop();
-                }
-            }
-    }
-
-    public static int getPortFor(String protocol) throws Exception {
-        final int aport =
-              Integer.valueOf(System.getProperty("jmx."+protocol+".port","0"));
-        if (aport > 0) return aport;
-        final ServerSocket s = new ServerSocket(0);
-        try {
-            final int port = s.getLocalPort();
-            return port;
-        } finally {
-            s.close();
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        doTest(ManagementFactory.getPlatformMBeanServer(),makeConfig("rmi"));
-    }
-
-}
--- a/test/javax/management/namespace/JMXNamespacesTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,648 +0,0 @@
-/*
- * 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 JMXNamespacesTest.java
- * @summary Test the static method that rewrite ObjectNames in JMXNamespacesTest
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean JMXNamespacesTest
- * @compile -XDignore.symbol.file=true JMXNamespacesTest.java
- * @run main JMXNamespacesTest
- */
-
-import com.sun.jmx.namespace.ObjectNameRouter;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.logging.Logger;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespaces;
-
-/**
- * Class JMXNamespacesTest
- * @author Sun Microsystems, 2005 - All rights reserved.
- */
-public class JMXNamespacesTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(JMXNamespacesTest.class.getName());
-
-    /** Creates a new instance of JMXNamespacesTest */
-    public JMXNamespacesTest() {
-    }
-
-    public static class CustomObject implements Serializable {
-        ObjectName toto;
-        String titi;
-        CustomObject(String toto, String titi) {
-            try {
-                this.toto = new ObjectName(toto);
-            } catch (MalformedObjectNameException m) {
-                throw new IllegalArgumentException(m);
-            }
-            this.titi = titi;
-        }
-        private Object[] data() {
-            return new Object[] {toto, titi};
-        }
-        @Override
-        public boolean equals(Object other) {
-            if (! (other instanceof CustomObject)) return false;
-            return Arrays.deepEquals(data(),((CustomObject)other).data());
-        }
-        @Override
-        public int hashCode() {
-            return Arrays.deepHashCode(data());
-        }
-    }
-
-    public static CustomObject obj(String toto, String titi) {
-        return new CustomObject(toto,titi);
-    }
-
-    private static String failure;
-
-    public static void testDeepRewrite() throws Exception {
-        failure = null;
-        String s1 = "x//y//d:k=v";
-        String s2 = "v//w//x//y//d:k=v";
-        String p1 = "v//w";
-        String p3 = "a//b";
-
-        System.out.println("inserting "+p1);
-        final CustomObject foo1 =
-                JMXNamespaces.deepReplaceHeadNamespace(obj(s1,s1),"",p1);
-        assertEquals(foo1.toto.toString(),p1+"//"+s1);
-        assertEquals(foo1.titi,s1);
-
-       System.out.println("removing "+p1);
-       final CustomObject foo2 =
-                JMXNamespaces.deepReplaceHeadNamespace(obj(s2,s2),p1,"");
-        assertEquals(foo2.toto.toString(),s1);
-        assertEquals(foo2.titi,s2);
-
-        System.out.println("removing "+p1);
-        final CustomObject foo3 =
-                JMXNamespaces.deepReplaceHeadNamespace(obj(p1+"//"+s2,s2),p1,"");
-        assertEquals(foo3.toto.toString(),s2);
-        assertEquals(foo3.titi,s2);
-
-        System.out.println("replacing "+p1+" with "+p3);
-        final CustomObject foo4 =
-                JMXNamespaces.deepReplaceHeadNamespace(obj(s2,s2),p1,p3);
-        assertEquals(foo4.toto.toString(),p3+"//"+s1);
-        assertEquals(foo4.titi,s2);
-
-        System.out.println("replacing "+p1+" with "+p1);
-        final CustomObject foo5 =
-                JMXNamespaces.deepReplaceHeadNamespace(obj(s2,s2),p1,p1);
-        assertEquals(foo5.toto.toString(),s2);
-        assertEquals(foo5.titi,s2);
-
-        System.out.println("removing x//y in "+s2);
-        try {
-            final CustomObject foo7 =
-                JMXNamespaces.deepReplaceHeadNamespace(obj(s2,s2),"x//y","");
-            failed("Remove x//y in "+s2+" should have failed!");
-        } catch (IllegalArgumentException x) {
-            System.out.println("Received expected exception: "+x);
-        }
-
-        System.out.println("replacing x//y with "+p3+" in "+s2);
-        try {
-            final CustomObject foo7 =
-                JMXNamespaces.deepReplaceHeadNamespace(obj(s2,s2),"x//y",p3);
-            failed("Replace x//y in "+s2+" should have failed!");
-        } catch (IllegalArgumentException x) {
-            System.out.println("Received expected exception: "+x);
-        }
-
-        if (failure != null) throw new Exception(failure);
-    }
-
-    private static String[][] wildcards = {
-        { "", "*:*" },
-        { "//", "//*:*" },
-        { "foo", "foo//*:*" },
-        { "//foo", "//foo//*:*" },
-        { "////foo", "//foo//*:*" },
-        { "foo//", "foo//*:*" },
-        { "foo////", "foo//*:*" },
-        { "//foo//", "//foo//*:*" },
-        { "////foo//", "//foo//*:*" },
-        { "////foo////", "//foo//*:*" },
-        { "foo//bar", "foo//bar//*:*" },
-        { "//foo//bar", "//foo//bar//*:*" },
-        { "////foo//bar", "//foo//bar//*:*" },
-        { "foo//bar//", "foo//bar//*:*" },
-        { "foo//bar////", "foo//bar//*:*" },
-        { "//foo//bar//", "//foo//bar//*:*" },
-        { "////foo//bar//", "//foo//bar//*:*" },
-        { "////foo//bar////", "//foo//bar//*:*" },
-        { "foo////bar", "foo//bar//*:*" },
-        { "//foo////bar", "//foo//bar//*:*" },
-        { "////foo////bar", "//foo//bar//*:*" },
-        { "foo////bar//", "foo//bar//*:*" },
-        { "foo////bar////", "foo//bar//*:*" },
-        { "//foo////bar//", "//foo//bar//*:*" },
-        { "////foo////bar//", "//foo//bar//*:*" },
-        { "////foo////bar////", "//foo//bar//*:*" },
-        { "fo/o", "fo/o//*:*" },
-        { "//f/oo", "//f/oo//*:*" },
-        { "////f/o/o", "//f/o/o//*:*" },
-        { "fo/o//", "fo/o//*:*" },
-        { "f/oo////", "f/oo//*:*" },
-        { "//fo/o//", "//fo/o//*:*" },
-        { "////f/oo//", "//f/oo//*:*" },
-        { "////f/o/o////", "//f/o/o//*:*" },
-        { "foo//b/a/r", "foo//b/a/r//*:*" },
-        { "//fo/o//bar", "//fo/o//bar//*:*" },
-        { "////foo//b/ar", "//foo//b/ar//*:*" },
-        { "foo//ba/r//", "foo//ba/r//*:*" },
-        { "f/oo//bar////", "f/oo//bar//*:*" },
-        { "//f/o/o//bar//", "//f/o/o//bar//*:*" },
-        { "////foo//b/a/r//", "//foo//b/a/r//*:*" },
-        { "////f/o/o//b/a/r////", "//f/o/o//b/a/r//*:*" },
-        { "foo////ba/r", "foo//ba/r//*:*" },
-        { "//foo////b/ar", "//foo//b/ar//*:*" },
-        { "////f/oo////bar", "//f/oo//bar//*:*" },
-        { "fo/o////bar//", "fo/o//bar//*:*" },
-        { "foo////ba/r////", "foo//ba/r//*:*" },
-        { "//fo/o////ba/r//", "//fo/o//ba/r//*:*" },
-        { "////f/oo////b/ar//", "//f/oo//b/ar//*:*" },
-        { "////f/o/o////b/a/r////", "//f/o/o//b/a/r//*:*" },
-    };
-    private final static String[] badguys = {
-        null,
-        "/",         "/*:*",
-        "///",       "///*:*" ,
-        "/foo",      "/foo//*:*",
-        "//foo/",    "//foo///*:*" ,
-        "/////foo",  "///foo//*:*",
-        "/foo//",    "/foo//*:*",
-        "foo/////",  "foo///*:*",
-        "///foo//",  "///foo//*:*",
-        "////foo///", "//foo///*:*" ,
-        "/////foo/////", "///foo///*:*",
-        "/foo//bar", "/foo//bar//*:*",
-        "//foo///bar", "//foo///bar//*:*",
-        "/////foo////bar/", "///foo//bar///*:*",
-        "foo///bar//", "foo//bar///*:*",
-        "foo//bar/////", "foo///bar//*:*",
-        "///foo//bar//", "//foo///bar//*:*" ,
-    };
-    public static void testWildcard() throws Exception {
-        int i = 0;
-        for (String[] pair : wildcards) {
-            i++;
-            final String msg = "testWildcard[good,"+i+"] "+Arrays.asList(pair)+": ";
-            assertEquals(msg, new ObjectName(pair[1]),
-                    JMXNamespaces.getWildcardFor(pair[0]));
-        }
-        i=0;
-        for (String bad : badguys) {
-            i++;
-            try {
-                JMXNamespaces.getWildcardFor(bad);
-                failed("testWildcard[bad,"+i+"] "+bad+" incorrectly accepted. " +
-                        "IllegalArgumentException was expected");
-            } catch (IllegalArgumentException x) {
-                // OK
-            }
-        }
-        if (failure != null) throw new Exception(failure);
-    }
-
-    private static String[][] goodinsert = {
-        {"","d:k=v","d:k=v"},
-        {"","//d:k=v","//d:k=v"},
-        {"//","d:k=v","//d:k=v"},
-        {"//","//d:k=v","//d:k=v"},
-        {"//","a//d:k=v","//a//d:k=v"},
-        {"//","//a//d:k=v","//a//d:k=v"},
-        {"//","////a////d:k=v","//a//d:k=v"},
-        {"//b","////a////d:k=v","//b//a//d:k=v"},
-        {"b","////a////d:k=v","b//a//d:k=v"},
-        {"b","d:k=v","b//d:k=v"},
-        {"b//","d:k=v","b//d:k=v"},
-        {"//b//","d:k=v","//b//d:k=v"},
-        {"//b","////a////d:k=v","//b//a//d:k=v"},
-        {"b//c","////a////d:k=v","b//c//a//d:k=v"},
-        {"b//c","d:k=v","b//c//d:k=v"},
-        {"b//c//","d:k=v","b//c//d:k=v"},
-        {"//b//c//","d:k=v","//b//c//d:k=v"},
-        {"","/d:k=v","/d:k=v"},
-        {"","///d:k=v","///d:k=v"},
-        {"//","/d:k=v","///d:k=v"},
-        {"//","///d:k=v","///d:k=v"},
-        {"//","a///d:k=v","//a///d:k=v"},
-        {"//","//a///d:k=v","//a///d:k=v"},
-        {"//","////a////d/:k=v","//a//d/:k=v"},
-        {"//b","////a/////d:k=v","//b//a///d:k=v"},
-        {"b","////a////d/:k=v","b//a//d/:k=v"},
-        {"b","/d:k=v","b///d:k=v"},
-        {"b//","/d:k=v","b///d:k=v"},
-        {"//b//","/d:k=v","//b///d:k=v"},
-        {"//b","////a/////d:k=v","//b//a///d:k=v"},
-        {"b//c","////a/////d:k=v","b//c//a///d:k=v"},
-        {"b//c","/d:k=v","b//c///d:k=v"},
-        {"b//c//","/d:k=v","b//c///d:k=v"},
-        {"//b//c//","d/:k=v","//b//c//d/:k=v"},
-    };
-
-    private static String[][] badinsert = {
-        {"/","d:k=v"},
-        {"/","//d:k=v"},
-        {"///","d:k=v"},
-        {"///","//d:k=v"},
-        {"///","/a//d:k=v"},
-        {"///","///a//d:k=v"},
-        {"///","/////a////d:k=v"},
-        {"//b","/////a////d:k=v"},
-        {"b/","////a////d:k=v"},
-        {"b/","d:k=v"},
-        {"b///","d:k=v"},
-        {"//b///","d:k=v"},
-        {"//b/","////a////d:k=v"},
-        {"b///c","////a////d:k=v"},
-        {"b//c/","d:k=v"},
-        {"b///c//","d:k=v"},
-        {"//b///c//","d:k=v"},
-
-    };
-
-    public static void testInsertPath() throws Exception {
-        int i = 0;
-        for (String[] pair : goodinsert) {
-            i++;
-            final String msg = "testInsertPath[good,"+i+"] "+Arrays.asList(pair)+": ";
-            assertEquals(msg,new ObjectName(pair[2]),
-                    JMXNamespaces.insertPath(pair[0],
-                    new ObjectName(pair[1])));
-        }
-        i=0;
-        for (String[] bad : badinsert) {
-            i++;
-            try {
-                JMXNamespaces.insertPath(bad[0],
-                    new ObjectName(bad[1]));
-                failed("testInsertPath[bad,"+i+"] "+
-                        Arrays.asList(bad)+" incorrectly accepted. " +
-                        "IllegalArgumentException was expected");
-            } catch (IllegalArgumentException x) {
-                // OK
-            }
-        }
-        if (failure != null) throw new Exception(failure);
-    }
-
-    private static String[][] testpath  = {
-        {"/a/a/:k=v",""},
-        {"/:k=v",""},
-        {"bli:k=v",""},
-        {"///a/a/:k=v",""},
-        {"///:k=v",""},
-        {"//bli:k=v",""},
-        {"/////a/a/:k=v",""},
-        {"/////:k=v",""},
-        {"////bli:k=v",""},
-        {"y///a/a/:k=v","y"},
-        {"y///:k=v","y"},
-        {"y//bli:k=v","y"},
-        {"y/////a/a/:k=v","y"},
-        {"y/////:k=v","y"},
-        {"y////bli:k=v","y"},
-        {"//y///a/a/:k=v","y"},
-        {"//y///:k=v","y"},
-        {"//y//bli:k=v","y"},
-        {"//y/////a/a/:k=v","y"},
-        {"//y/////:k=v","y"},
-        {"//y////bli:k=v","y"},
-        {"////y///a/a/:k=v","y"},
-        {"////y///:k=v","y"},
-        {"////y//bli:k=v","y"},
-        {"////y/////a/a/:k=v","y"},
-        {"////y/////:k=v","y"},
-        {"////y////bli:k=v","y"},
-
-        {"z//y///a/a/:k=v","z//y"},
-        {"z//y///:k=v","z//y"},
-        {"z//y//bli:k=v","z//y"},
-        {"z//y/////a/a/:k=v","z//y"},
-        {"z//y/////:k=v","z//y"},
-        {"z//y////bli:k=v","z//y"},
-        {"//z//y///a/a/:k=v","z//y"},
-        {"//z//y///:k=v","z//y"},
-        {"//z//y//bli:k=v","z//y"},
-        {"//z//y/////a/a/:k=v","z//y"},
-        {"//z//y/////:k=v","z//y"},
-        {"//z//y////bli:k=v","z//y"},
-        {"z////y///a/a/:k=v","z//y"},
-        {"z////y///:k=v","z//y"},
-        {"z////y//bli:k=v","z//y"},
-        {"z////y/////a/a/:k=v","z//y"},
-        {"z////y/////:k=v","z//y"},
-        {"z////y////bli:k=v","z//y"},
-        {"//z////y///a/a/:k=v","z//y"},
-        {"//z////y///:k=v","z//y"},
-        {"//z////y//bli:k=v","z//y"},
-        {"//z////y/////a/a/:k=v","z//y"},
-        {"//z////y/////:k=v","z//y"},
-        {"//z////y////bli:k=v","z//y"},
-        {"////z////y///a/a/:k=v","z//y"},
-        {"////z////y///:k=v","z//y"},
-        {"////z////y//bli:k=v","z//y"},
-        {"////z////y/////a/a/:k=v","z//y"},
-        {"////z////y/////:k=v","z//y"},
-        {"////z////y////bli:k=v","z//y"},
-
-    };
-
-    public static void testGetNormalizedPath() throws Exception {
-        int i = 0;
-        for (String[] pair : testpath) {
-            i++;
-            final String msg = "testGetNormalizedPath["+i+"] "+Arrays.asList(pair)+": ";
-            assertEquals(msg,pair[1],
-                    JMXNamespaces.getContainingNamespace(new ObjectName(pair[0])));
-        }
-        if (failure != null) throw new Exception(failure);
-    }
-
-    private static String[][] testdomain  = {
-        {"/a/a/","/a/a/"},
-        {"/","/"},
-        {"bli","bli"},
-        {"///a/a/","///a/a/"},
-        {"///","///"},
-        {"//bli","//bli"},
-        {"/////a/a/","///a/a/"},
-        {"/////","///"},
-        {"////bli","//bli"},
-        {"y///a/a/","y///a/a/"},
-        {"y///","y///"},
-        {"y//bli","y//bli"},
-        {"y/////a/a/","y///a/a/"},
-        {"y/////","y///"},
-        {"y////bli","y//bli"},
-        {"//y///a/a/","//y///a/a/"},
-        {"//y///","//y///"},
-        {"//y//bli","//y//bli"},
-        {"//y/////a/a/","//y///a/a/"},
-        {"//y/////","//y///"},
-        {"//y////bli","//y//bli"},
-        {"////y///a/a/","//y///a/a/"},
-        {"////y///","//y///"},
-        {"////y//bli","//y//bli"},
-        {"////y/////a/a/","//y///a/a/"},
-        {"////y/////","//y///"},
-        {"////y////bli","//y//bli"},
-
-        {"z//y///a/a/","z//y///a/a/"},
-        {"z//y///","z//y///"},
-        {"z//y//bli","z//y//bli"},
-        {"z//y/////a/a/","z//y///a/a/"},
-        {"z//y/////","z//y///"},
-        {"z//y////bli","z//y//bli"},
-        {"//z//y///a/a/","//z//y///a/a/"},
-        {"//z//y///","//z//y///"},
-        {"//z//y//bli","//z//y//bli"},
-        {"//z//y/////a/a/","//z//y///a/a/"},
-        {"//z//y/////","//z//y///"},
-        {"//z//y////bli","//z//y//bli"},
-        {"z////y///a/a/","z//y///a/a/"},
-        {"z////y///","z//y///"},
-        {"z////y//bli","z//y//bli"},
-        {"z////y/////a/a/","z//y///a/a/"},
-        {"z////y/////","z//y///"},
-        {"z////y////bli","z//y//bli"},
-        {"//z////y///a/a/","//z//y///a/a/"},
-        {"//z////y///","//z//y///"},
-        {"//z////y//bli","//z//y//bli"},
-        {"//z////y/////a/a/","//z//y///a/a/"},
-        {"//z////y/////","//z//y///"},
-        {"//z////y////bli","//z//y//bli"},
-        {"////z////y///a/a/","//z//y///a/a/"},
-        {"////z////y///","//z//y///"},
-        {"////z////y//bli","//z//y//bli"},
-        {"////z////y/////a/a/","//z//y///a/a/"},
-        {"////z////y/////","//z//y///"},
-        {"////z////y////bli","//z//y//bli"},
-
-        {"bli//","bli//"},
-        {"//bli//","//bli//"},
-        {"////bli//","//bli//"},
-        {"y////","y//"},
-        {"y//bli//","y//bli//"},
-        {"y////","y//"},
-        {"y////bli//","y//bli//"},
-        {"//y////","//y//"},
-        {"//y//bli//","//y//bli//"},
-        {"//y//////","//y//"},
-        {"//y////bli//","//y//bli//"},
-        {"////y////","//y//"},
-        {"////y//bli////","//y//bli//"},
-        {"////y//////","//y//"},
-        {"////y////bli////","//y//bli//"},
-        {"z//y////","z//y//"},
-        {"z//y//bli//","z//y//bli//"},
-        {"z//y//////","z//y//"},
-        {"z//y////bli//","z//y//bli//"},
-        {"//z//y////","//z//y//"},
-        {"//z//y//bli//","//z//y//bli//"},
-        {"//z//y//////","//z//y//"},
-        {"//z//y////bli//","//z//y//bli//"},
-        {"z////y////","z//y//"},
-        {"z////y//bli//","z//y//bli//"},
-        {"z////y//////","z//y//"},
-        {"z////y////bli//","z//y//bli//"},
-        {"//z////y////","//z//y//"},
-        {"//z////y//bli//","//z//y//bli//"},
-        {"//z////y//////","//z//y//"},
-        {"//z////y////bli//","//z//y//bli//"},
-        {"////z////y////","//z//y//"},
-        {"////z////y//bli//","//z//y//bli//"},
-        {"////z////y//////","//z//y//"},
-        {"////z////y////bli//","//z//y//bli//"},
-
-    };
-    private static String[][] testnolead  = {
-        {"/a/a/","/a/a/"},
-        {"/","/"},
-        {"bli","bli"},
-        {"///a/a/","/a/a/"},
-        {"///","/"},
-        {"//bli","bli"},
-        {"/////a/a/","/a/a/"},
-        {"/////","/"},
-        {"////bli","bli"},
-        {"y///a/a/","y///a/a/"},
-        {"y///","y///"},
-        {"y//bli","y//bli"},
-        {"y/////a/a/","y///a/a/"},
-        {"y/////","y///"},
-        {"y////bli","y//bli"},
-        {"//y///a/a/","y///a/a/"},
-        {"//y///","y///"},
-        {"//y//bli","y//bli"},
-        {"//y/////a/a/","y///a/a/"},
-        {"//y/////","y///"},
-        {"//y////bli","y//bli"},
-        {"////y///a/a/","y///a/a/"},
-        {"////y///","y///"},
-        {"////y//bli","y//bli"},
-        {"////y/////a/a/","y///a/a/"},
-        {"////y/////","y///"},
-        {"////y////bli","y//bli"},
-
-        {"z//y///a/a/","z//y///a/a/"},
-        {"z//y///","z//y///"},
-        {"z//y//bli","z//y//bli"},
-        {"z//y/////a/a/","z//y///a/a/"},
-        {"z//y/////","z//y///"},
-        {"z//y////bli","z//y//bli"},
-        {"//z//y///a/a/","z//y///a/a/"},
-        {"//z//y///","z//y///"},
-        {"//z//y//bli","z//y//bli"},
-        {"//z//y/////a/a/","z//y///a/a/"},
-        {"//z//y/////","z//y///"},
-        {"//z//y////bli","z//y//bli"},
-        {"z////y///a/a/","z//y///a/a/"},
-        {"z////y///","z//y///"},
-        {"z////y//bli","z//y//bli"},
-        {"z////y/////a/a/","z//y///a/a/"},
-        {"z////y/////","z//y///"},
-        {"z////y////bli","z//y//bli"},
-        {"//z////y///a/a/","z//y///a/a/"},
-        {"//z////y///","z//y///"},
-        {"//z////y//bli","z//y//bli"},
-        {"//z////y/////a/a/","z//y///a/a/"},
-        {"//z////y/////","z//y///"},
-        {"//z////y////bli","z//y//bli"},
-        {"////z////y///a/a/","z//y///a/a/"},
-        {"////z////y///","z//y///"},
-        {"////z////y//bli","z//y//bli"},
-        {"////z////y/////a/a/","z//y///a/a/"},
-        {"////z////y/////","z//y///"},
-        {"////z////y////bli","z//y//bli"},
-
-        {"bli//","bli//"},
-        {"//bli//","bli//"},
-        {"////bli//","bli//"},
-        {"y////","y//"},
-        {"y//bli//","y//bli//"},
-        {"y////","y//"},
-        {"y////bli//","y//bli//"},
-        {"//y////","y//"},
-        {"//y//bli//","y//bli//"},
-        {"//y//////","y//"},
-        {"//y////bli//","y//bli//"},
-        {"////y////","y//"},
-        {"////y//bli////","y//bli//"},
-        {"////y//////","y//"},
-        {"////y////bli////","y//bli//"},
-        {"z//y////","z//y//"},
-        {"z//y//bli//","z//y//bli//"},
-        {"z//y//////","z//y//"},
-        {"z//y////bli//","z//y//bli//"},
-        {"//z//y////","z//y//"},
-        {"//z//y//bli//","z//y//bli//"},
-        {"//z//y//////","z//y//"},
-        {"//z//y////bli//","z//y//bli//"},
-        {"z////y////","z//y//"},
-        {"z////y//bli//","z//y//bli//"},
-        {"z////y//////","z//y//"},
-        {"z////y////bli//","z//y//bli//"},
-        {"//z////y////","z//y//"},
-        {"//z////y//bli//","z//y//bli//"},
-        {"//z////y//////","z//y//"},
-        {"//z////y////bli//","z//y//bli//"},
-        {"////z////y////","z//y//"},
-        {"////z////y//bli//","z//y//bli//"},
-        {"////z////y//////","z//y//"},
-        {"////z////y////bli//","z//y//bli//"},
-
-    };
-
-    public static void testNormalizeDomain() throws Exception {
-        int i = 0;
-        for (String[] pair : testdomain) {
-            i++;
-            final String msg = "testNormalizeDomain["+i+", false] "+Arrays.asList(pair)+": ";
-            assertEquals(msg,pair[1],
-                    ObjectNameRouter.normalizeDomain(pair[0],false));
-        }
-        if (failure != null) throw new Exception(failure);
-        i = 0;
-        for (String[] pair : testnolead) {
-            i++;
-            final String msg = "testNormalizeDomain["+i+", true] "+Arrays.asList(pair)+": ";
-            assertEquals(msg,pair[1],
-                    ObjectNameRouter.normalizeDomain(pair[0],true));
-        }
-        if (failure != null) throw new Exception(failure);
-    }
-
-    public static void main(String[] args) throws Exception {
-        testDeepRewrite();
-        testNormalizeDomain();
-        testInsertPath();
-        testWildcard();
-        testGetNormalizedPath();
-    }
-
-    private static void assertEquals(Object x, Object y) {
-        assertEquals("",x,y);
-    }
-
-    private static void assertEquals(String msg, Object x, Object y) {
-        if (msg == null) msg="";
-        if (!equal(x, y))
-            failed(msg+"expected " + string(x) + "; got " + string(y));
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        if (x.getClass().isArray())
-            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
-        return x.equals(y);
-    }
-
-    private static String string(Object x) {
-        String s = Arrays.deepToString(new Object[] {x});
-        return s.substring(1, s.length() - 1);
-    }
-
-
-    private static void failed(String why) {
-        failure = why;
-        new Throwable("FAILED: " + why).printStackTrace(System.out);
-    }
-
-}
--- a/test/javax/management/namespace/JMXRemoteNamespaceTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
- * 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 JMXRemoteNamespaceTest.java
- * @summary Basic tests on a JMXRemoteNamespace.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean JMXRemoteNamespaceTest Wombat WombatMBean
- * @run build JMXRemoteNamespaceTest Wombat WombatMBean
- * @run main JMXRemoteNamespaceTest
- */
-
-import javax.management.JMX;
-import javax.management.Notification;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.NotificationListener;
-import javax.management.namespace.JMXRemoteNamespace;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.io.IOException;
-import javax.management.AttributeChangeNotification;
-
-/**
- * Test simple creation/registration of namespace.
- *
- */
-public class JMXRemoteNamespaceTest {
-
-    static class MyConnect implements NotificationListener {
-        private final JMXRemoteNamespace my;
-        private final List<Notification> list;
-        private volatile int connectCount=0;
-        private int closeCount=0;
-        private final ObjectName myname;
-        public MyConnect(JMXRemoteNamespace my, ObjectName myname) {
-            this.my=my;
-            this.myname = myname;
-            list = Collections.synchronizedList(new ArrayList<Notification>());
-            my.addNotificationListener(this, null, null);
-        }
-
-        public synchronized void connect() throws IOException {
-                my.connect();
-                if (!my.isConnected())
-                    throw new IOException(myname+" should be connected");
-                connectCount++;
-        }
-
-        public void close() throws IOException {
-                my.close();
-                if (my.isConnected())
-                    throw new IOException(myname+" shouldn't be connected");
-                closeCount++;
-        }
-
-        public synchronized int getConnectCount() {
-            return connectCount;
-        }
-        public synchronized int getClosedCount() {
-            return closeCount;
-        }
-
-        public synchronized void handleNotification(Notification notification,
-                Object handback) {
-            list.add(notification);
-        }
-
-        public synchronized void checkNotifs(int externalConnect,
-                int externalClosed) throws Exception {
-            System.err.println("Connected: "+connectCount+" time"+
-                    ((connectCount>1)?"s":""));
-            System.err.println("Closed: "+closeCount+" time"+
-                    ((closeCount>1)?"s":""));
-            System.err.println("Received:");
-            int cl=0;
-            int co=0;
-            for (Notification n : list) {
-                System.err.println("\t"+n);
-                if (!(n instanceof AttributeChangeNotification))
-                    throw new Exception("Unexpected notif: "+n.getClass());
-                final AttributeChangeNotification acn =
-                        (AttributeChangeNotification)n;
-                if (((Boolean)acn.getNewValue()).booleanValue())
-                    co++;
-                else cl++;
-                if ((((Boolean)acn.getNewValue()).booleanValue())
-                    == (((Boolean)acn.getOldValue()).booleanValue())) {
-                    throw new Exception("Bad values: old=new");
-                }
-            }
-            if (! (list.size()==(closeCount+connectCount+
-                    externalClosed+externalConnect))) {
-                throw new Exception("Bad notif count - got "+list.size());
-            }
-            if (cl!=(closeCount+externalClosed)) {
-                throw new Exception("Bad count of close notif: expected "
-                        +(closeCount+externalClosed)+", got"+cl);
-            }
-            if (co!=(connectCount+externalConnect)) {
-                throw new Exception("Bad count of connect notif: expected "
-                        +(connectCount+externalConnect)+", got"+co);
-            }
-        }
-    }
-
-    public static void testConnectClose() throws Exception {
-        final MBeanServer myServer = MBeanServerFactory.newMBeanServer();
-        final JMXConnectorServer myRMI =
-                JMXConnectorServerFactory.newJMXConnectorServer(
-                new JMXServiceURL("rmi",null,0), null, myServer);
-        myRMI.start();
-        try {
-        final JMXRemoteNamespace my =
-                JMXRemoteNamespace.newJMXRemoteNamespace(
-                myRMI.getAddress(),null);
-        final MBeanServer s = MBeanServerFactory.newMBeanServer();
-        final ObjectName myname = JMXNamespaces.getNamespaceObjectName("my");
-        final ObjectName wname = ObjectName.getInstance("backyard:type=Wombat");
-        myServer.registerMBean(new Wombat(),wname);
-        final MyConnect myc = new MyConnect(my,myname);
-        myc.connect();
-        myc.close();
-        myc.connect();
-        s.registerMBean(my,myname);
-        myc.close();
-        myc.connect();
-        if (!s.queryNames(new ObjectName("my//b*:*"),null).contains(
-                JMXNamespaces.insertPath("my", wname))) {
-            throw new RuntimeException("1: Wombat not found: "+wname);
-        }
-        myc.close();
-        myc.connect();
-        final MBeanServer cd = JMXNamespaces.narrowToNamespace(s, "my");
-        if (!cd.queryNames(new ObjectName("b*:*"),null).contains(wname)) {
-            throw new RuntimeException("2: Wombat not found: "+wname);
-        }
-        myc.close();
-        myc.connect();
-        System.out.println("Found a Wombat in my backyard.");
-
-        final String deepThoughts = "I want to leave this backyard!";
-        final WombatMBean w = JMX.newMBeanProxy(cd, wname, WombatMBean.class);
-        w.setCaption(deepThoughts);
-        if (!deepThoughts.equals(w.getCaption()))
-                throw new RuntimeException("4: Wombat is not thinking right: "+
-                        w.getCaption());
-        s.unregisterMBean(myname);
-        if (my.isConnected())
-            throw new Exception(myname+" shouldn't be connected");
-        myc.connect();
-        myc.close();
-        myc.checkNotifs(0,1);
-        } finally {
-            myRMI.stop();
-        }
-
-    }
-
-    public static void main(String... args) throws Exception {
-        testConnectClose();
-    }
-}
--- a/test/javax/management/namespace/JMXRemoteTargetNamespace.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-/*
- * 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.
- */
-
-
-import java.io.IOException;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.MBeanException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServerConnection;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.event.EventClient;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXRemoteNamespace;
-import javax.management.namespace.JMXRemoteNamespaceMBean;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXServiceURL;
-
-// These options originally in the draft of javax/management/namespaces
-// but we decided to retire them - since they could be implemented
-// by subclasses. The JMXRemoteTargetNamespace is such a subclass.
-//
-public class JMXRemoteTargetNamespace extends JMXRemoteNamespace {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(JMXRemoteTargetNamespace.class.getName());
-    public static final String CREATE_EVENT_CLIENT =
-           "jmx.test.create.event.client";
-
-    private final String sourceNamespace;
-    private final boolean createEventClient;
-
-    public JMXRemoteTargetNamespace(JMXServiceURL sourceURL,
-            Map<String,?> optionsMap) {
-        this(sourceURL,optionsMap,null);
-    }
-
-    public JMXRemoteTargetNamespace(JMXServiceURL sourceURL,
-            Map<String,?> optionsMap, String sourceNamespace) {
-        super(sourceURL, optionsMap);
-        this.sourceNamespace = sourceNamespace;
-        this.createEventClient = createEventClient(optionsMap);
-    }
-
-    private boolean createEventClient(Map<String,?> options) {
-        if (options == null) return false;
-        final Object createValue = options.get(CREATE_EVENT_CLIENT);
-        if (createValue == null) return false;
-        if (createValue instanceof Boolean)
-            return ((Boolean)createValue).booleanValue();
-        if (createValue instanceof String)
-            return Boolean.valueOf((String)createValue);
-        throw new IllegalArgumentException("Bad type for value of property " +
-                CREATE_EVENT_CLIENT+": "+createValue.getClass().getName());
-    }
-
-    @Override
-    protected MBeanServerConnection getMBeanServerConnection(JMXConnector jmxc)
-            throws IOException {
-        MBeanServerConnection mbsc = super.getMBeanServerConnection(jmxc);
-        if (sourceNamespace != null && sourceNamespace.length() > 0)
-            mbsc = JMXNamespaces.narrowToNamespace(mbsc, sourceNamespace);
-        if (createEventClient)
-            mbsc = EventClient.getEventClientConnection(mbsc);
-        return mbsc;
-    }
-
-
-    /**
-     * Creates a target name space to mirror a remote source name space in
-     * the target server.
-     * @param targetServer A connection to the target MBean server in which
-     *        the new name space should be created.
-     * @param targetPath the name space to create in the target server. Note
-     *        that if the target name space is a path - that is if
-     *        {@code targetPath} contains '//', then the parent name space
-     *        must be pre-existing in the target server. Attempting to create
-     *        {code targetPath="a//b//c"} in {@code targetServer}
-     *        will fail if name space {@code "a//b"} doesn't already exists
-     *        in {@code targetServer}.
-     * @param sourceURL a JMX service URL that can be used to connect to the
-     *        source MBean server.
-     * @param options the set of options to use when creating the
-     *        {@link #JMXRemoteNamespace JMXRemoteNamespace} that will
-     *        handle the new name space.
-     * @return An {@code ObjectInstance} representing the
-     *         {@link JMXRemoteNamespaceMBean} which handles the
-     *         new name space.
-     *
-     **/
-    public static ObjectInstance createNamespace(
-            MBeanServerConnection targetServer,
-            String targetPath,
-            JMXServiceURL sourceURL,
-            Map<String,?> options)
-        throws IOException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException {
-        final ObjectName name =
-                JMXNamespaces.getNamespaceObjectName(targetPath);
-        return createInstance(targetServer, name, sourceURL, options, null);
-    }
-
-    /**
-     * Creates a target name space to mirror a remote source name space in
-     * the target server.
-     * @param targetServer A connection to the target MBean server in which
-     *        the new name space should be created.
-     * @param targetPath the name space to create in the target server. Note
-     *        that if the target name space is a path - that is if
-     *        {@code targetPath} contains '//', then the parent name space
-     *        must be pre-existing in the target server. Attempting to create
-     *        {code targetPath="a//b//c"} in {@code targetServer}
-     *        will fail if name space {@code "a//b"} doesn't already exists
-     *        in {@code targetServer}.
-     * @param sourceURL a JMX service URL that can be used to connect to the
-     *        source MBean server.
-     * @param sourcePath the source namespace path insode the source server.
-     * @param options the set of options to use when creating the
-     *        {@link #JMXRemoteNamespace JMXRemoteNamespace} that will
-     *        handle the new name space.
-     * @return An {@code ObjectInstance} representing the
-     *         {@link JMXRemoteNamespaceMBean} which handles the
-     *         new name space.
-     *
-     **/
-    public static ObjectInstance createNamespace(
-            MBeanServerConnection targetServer,
-            String targetPath,
-            JMXServiceURL sourceURL,
-            Map<String,?> options,
-            String sourcePath)
-        throws IOException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException {
-        final ObjectName name =
-                JMXNamespaces.getNamespaceObjectName(targetPath);
-        return createInstance(targetServer, name, sourceURL, options, sourcePath);
-    }
-
-    /**
-     * Creates and registers a {@link JMXRemoteNamespaceMBean} in a target
-     * server, to mirror a remote source name space.
-     *
-     * @param server A connection to the target MBean server in which
-     *        the new name space should be created.
-     * @param handlerName the name of the JMXRemoteNamespace to create.
-     *        This must be a compliant name space handler name as returned
-     *        by {@link
-     *        JMXNamespaces#getNamespaceObjectName JMXNamespaces.getNamespaceObjectName}.
-     * @param sourceURL a JMX service URL that can be used to connect to the
-     *        source MBean server.
-     * @param sourcePath the path inside the source server
-     * @param options the set of options to use when creating the
-     *        {@link #JMXRemoteNamespace JMXRemoteNamespace} that will
-     *        handle the new name space.
-     * @return An {@code ObjectInstance} representing the new
-     *         {@link JMXRemoteNamespaceMBean} created.
-     * @see #createNamespace createNamespace
-     */
-     static ObjectInstance createInstance(MBeanServerConnection server,
-                  ObjectName handlerName,
-                  JMXServiceURL sourceURL, Map<String,?> options,
-                  String sourcePath)
-        throws IOException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException {
-        try {
-            final String[] signature = {
-                JMXServiceURL.class.getName(),
-                Map.class.getName(),
-                String.class.getName()
-            };
-            final Object[] params = {
-                sourceURL,options,sourcePath
-            };
-            final ObjectInstance instance =
-                server.createMBean(JMXRemoteTargetNamespace.class.getName(),
-                handlerName,params,signature);
-            return instance;
-        } catch (NotCompliantMBeanException ex) {
-            throw new RuntimeException("unexpected exception: " + ex, ex);
-        } catch (ReflectionException ex) {
-            throw new RuntimeException("unexpected exception: " + ex, ex);
-        }
-    }
-
-}
--- a/test/javax/management/namespace/LazyDomainTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,790 +0,0 @@
-/*
- * 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 LazyDomainTest.java
- * @bug 5072476
- * @summary Basic test for Lazy Domains.
- * @author Daniel Fuchs
- * @run clean LazyDomainTest Wombat WombatMBean
- * @run build LazyDomainTest Wombat WombatMBean
- * @run main LazyDomainTest
- */
-
-
-import java.lang.management.ClassLoadingMXBean;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.Map;
-import java.util.Set;
-import javax.management.JMX;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerBuilder;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerNotification;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXDomain;
-import javax.management.remote.MBeanServerForwarder;
-
-/**
- * Test simple creation/registration of namespace.
- *
- */
-public class LazyDomainTest {
-    private static Map<String,Object> emptyEnvMap() {
-        return Collections.emptyMap();
-    }
-
-
-    public static interface MBeanServerLoader {
-        public MBeanServer loadMBeanServer();
-    }
-
-
-    public static class MBeanServerProxy implements InvocationHandler {
-
-        private final static Map<Method,Method> localMap;
-        static {
-            localMap = new HashMap<Method, Method>();
-            for (Method m : MBeanServerForwarder.class.getDeclaredMethods()) {
-                try {
-                    final Method loc = MBeanServerProxy.class.
-                            getMethod(m.getName(), m.getParameterTypes());
-                    localMap.put(m, loc);
-                } catch (Exception x) {
-                    // not defined...
-                }
-            }
-            try {
-                localMap.put(MBeanServer.class.
-                        getMethod("getMBeanCount", (Class[]) null),
-                        MBeanServerProxy.class.
-                        getMethod("getMBeanCount", (Class[]) null));
-            } catch (NoSuchMethodException x) {
-                // OK.
-            }
-        }
-
-        private final MBeanServerLoader loader;
-        private MBeanServer server;
-        private final Set<LazyDomain> domains;
-
-        public MBeanServerProxy(MBeanServerLoader loader) {
-            if (loader == null)
-                throw new IllegalArgumentException("null loader");
-            this.loader = loader;
-            this.server = null;
-            domains = new HashSet<LazyDomain>();
-        }
-
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-                throws Throwable {
-            if (method.getDeclaringClass().equals(Object.class)) {
-                return invokeMethod(this,method,args);
-            }
-            final Method local = localMap.get(method);
-            if (local != null) {
-                return invokeMethod(this,local,args);
-            }
-            if (method.getDeclaringClass().equals(MBeanServer.class)) {
-                return invokeMethod(getMBeanServer(),method,args);
-            }
-            throw new NoSuchMethodException(method.getName());
-        }
-
-        private Object invokeMethod(Object on, Method method, Object[] args)
-            throws Throwable {
-            try {
-                return method.invoke(on, args);
-            } catch (InvocationTargetException ex) {
-                throw ex.getTargetException();
-            }
-        }
-
-        public synchronized MBeanServer getMBeanServer() {
-            if (server == null) setMBeanServer(loader.loadMBeanServer());
-            return server;
-        }
-
-        public synchronized void setMBeanServer(MBeanServer mbs) {
-            this.server = mbs;
-            if (mbs != null) {
-                for (LazyDomain dom : domains) dom.loaded();
-                domains.clear();
-            }
-        }
-
-        public synchronized boolean isLoaded() {
-            return server != null;
-        }
-
-        public synchronized void add(LazyDomain dom) {
-            if (isLoaded()) dom.loaded();
-            else domains.add(dom);
-        }
-
-        public synchronized boolean remove(LazyDomain dom) {
-            return domains.remove(dom);
-        }
-
-        public Integer getMBeanCount() {
-            if (isLoaded()) return server.getMBeanCount();
-            else return Integer.valueOf(0);
-        }
-    }
-
-    public static class LazyDomain extends JMXDomain {
-        public static MBeanServer makeProxyFor(MBeanServerProxy proxy) {
-            return (MBeanServer)
-                    Proxy.newProxyInstance(LazyDomain.class.getClassLoader(),
-                    new Class[] {MBeanServer.class, MBeanServerForwarder.class},
-                    proxy);
-        }
-
-        private final MBeanServerProxy proxy;
-        private volatile NotificationListener listener;
-        private volatile NotificationFilter   filter;
-
-        public LazyDomain(MBeanServerProxy proxy) {
-            super(makeProxyFor(proxy));
-            this.proxy = proxy;
-        }
-
-        @Override
-        public Integer getMBeanCount() {
-            if (proxy.isLoaded())
-                return super.getMBeanCount();
-            return 0;
-        }
-
-
-        @Override
-        public synchronized void addMBeanServerNotificationListener(
-                NotificationListener listener,
-                NotificationFilter filter) {
-            if (proxy.isLoaded()) {
-                super.addMBeanServerNotificationListener(listener, filter);
-            } else {
-                this.listener = listener;
-                this.filter   = filter;
-                proxy.add(this);
-            }
-        }
-
-        @Override
-        public synchronized void removeMBeanServerNotificationListener(
-                NotificationListener listener)
-                throws ListenerNotFoundException {
-            if (this.listener != listener)
-                throw new ListenerNotFoundException();
-            this.listener = null;
-            this.filter   = null;
-            if (proxy.isLoaded())
-                super.removeMBeanServerNotificationListener(listener);
-            proxy.remove(this);
-        }
-
-        public synchronized void loaded() {
-            if (listener != null)
-                addMBeanServerNotificationListener(listener, filter);
-        }
-
-    }
-
-    /**
-     * This is a use case for e.g GlassFish: the LazyStarterDomain MBean
-     * is a place holder that will unregister itself and autoload a set
-     * of MBeans in place of its own domain when that domain is
-     * accessed.
-     * This is an abstract class, where the only abstract method
-     * is loadMBeans(MBeanServer).
-     * Subclasses should implement that method to register whatever MBeans
-     * in the domain previously held by that LazyStarterDomain object.
-     * In other words: the LazyStarterDomain MBean is 'replaced' by the
-     * MBeans loaded by loadMBeans();
-     */
-    public static abstract class LazyStarterDomain extends LazyDomain {
-
-        /**
-         * This is a loader that will unregister the JMXDomain that
-         * created it, and register a bunch of MBeans in its place
-         * by calling LazyStarterDomain.loadMBeans
-         *
-         * That one gave me "la migraine".
-         */
-        private static class HalfGrainLoader implements MBeanServerLoader {
-            private volatile LazyStarterDomain domain;
-            public MBeanServer loadMBeanServer() {
-                if (domain == null)
-                    throw new IllegalStateException(
-                            "JMXDomain MBean not registered!");
-                final MBeanServer server     = domain.getMBeanServer();
-                final ObjectName  domainName = domain.getObjectName();
-                try {
-                    server.unregisterMBean(domainName);
-                } catch (Exception x) {
-                    throw new IllegalStateException("Can't unregister " +
-                            "JMXDomain: "+x,x);
-                }
-                domain.loadMBeans(server,domainName.getDomain());
-                return server;
-            }
-            public void setDomain(LazyStarterDomain domain) {
-                this.domain = domain;
-            }
-        }
-
-        /**
-         * This is an MBeanServerProxy which create a loader for the
-         * LazyStarterDomain MBean.
-         */
-        private static class DomainStarter extends MBeanServerProxy {
-
-            public DomainStarter() {
-                this(new HalfGrainLoader());
-            }
-
-            private final HalfGrainLoader loader;
-            private DomainStarter(HalfGrainLoader loader) {
-                super(loader);
-                this.loader = loader;
-            }
-
-            public void setDomain(LazyStarterDomain domain) {
-                loader.setDomain(domain);
-            }
-        }
-
-        /**
-         * A new LazyStarterDomain. When the domain monitored by this
-         * MBean is accessed, this MBean will unregister itself and call
-         * the abstract loadMBeans(MBeanServer) method.
-         * Subclasses need only to implement loadMBeans().
-         */
-        public LazyStarterDomain() {
-            this(new DomainStarter());
-        }
-
-        private LazyStarterDomain(DomainStarter starter) {
-            super(starter);
-            starter.setDomain(this);
-        }
-
-        // Contrarily to its LazyDomain superclass, this LazyDomain
-        // doesn't wrapp another MBeanServer: it simply registers a bunch
-        // of MBeans in its own MBeanServer.
-        // Thus, there's no notifications to forward.
-        //
-        @Override
-        public void addMBeanServerNotificationListener(
-                NotificationListener listener, NotificationFilter filter) {
-            // nothing to do.
-        }
-
-        // Contrarily to its LazyDomain superclass, this LazyDomain
-        // doesn't wrapp another MBeanServer: it simply registers a bunch
-        // of MBeans in its own MBeanServer.
-        // Thus, there's no notifications to forward.
-        //
-        @Override
-        public void removeMBeanServerNotificationListener(
-                NotificationListener listener) throws ListenerNotFoundException {
-            // nothing to do
-        }
-
-        // If this domain is registered, it contains no MBean.
-        // If it is not registered, then it no longer contain any MBean.
-        // The MBeanCount is thus always 0.
-        @Override
-        public Integer getMBeanCount() {
-            return 0;
-        }
-
-        /**
-         * Called when the domain is first accessed.
-         * {@code server} is the server in which this MBean was registered.
-         * A subclass must override this method in order to register
-         * the MBeans that should be contained in domain.
-         *
-         * @param server the server in which to load the MBeans.
-         * @param domain the domain in which the MBeans should be registered.
-         */
-        protected abstract void loadMBeans(MBeanServer server, String domain);
-
-
-    }
-
-    private static MBeanServerNotification pop(
-            BlockingQueue<Notification> queue,
-                                    String type,
-                                    ObjectName mbean,
-                                    String test)
-                                    throws InterruptedException {
-        final Notification n = queue.poll(1, TimeUnit.SECONDS);
-        if (!(n instanceof MBeanServerNotification))
-            fail(test+"expected MBeanServerNotification, got "+n);
-        final MBeanServerNotification msn = (MBeanServerNotification)n;
-        if (!type.equals(msn.getType()))
-            fail(test+"expected "+type+", got "+msn.getType());
-        if (!mbean.apply(msn.getMBeanName()))
-            fail(test+"expected "+mbean+", got "+msn.getMBeanName());
-        System.out.println(test+" got: "+msn);
-        return msn;
-    }
-    private static MBeanServerNotification popADD(
-            BlockingQueue<Notification> queue,
-                                    ObjectName mbean,
-                                    String test)
-                                    throws InterruptedException {
-        return pop(queue, MBeanServerNotification.REGISTRATION_NOTIFICATION,
-                mbean, test);
-    }
-
-    private static MBeanServerNotification popREM(
-            BlockingQueue<Notification> queue,
-                                    ObjectName mbean,
-                                    String test)
-                                    throws InterruptedException {
-        return pop(queue, MBeanServerNotification.UNREGISTRATION_NOTIFICATION,
-                mbean, test);
-    }
-
-
-    private static void fail(String msg) {
-        raise(new RuntimeException(msg));
-    }
-
-    private static void fail(String msg, Throwable cause) {
-        raise(new RuntimeException(msg,cause));
-    }
-
-    private static void raise(RuntimeException x) {
-        lastException = x;
-        exceptionCount++;
-        throw x;
-    }
-
-    private static volatile Exception lastException = null;
-    private static volatile int       exceptionCount = 0;
-
-    // ZZZ need to add a test case with several LazyDomains, and
-    // need to test that nothing is loaded until the lazy domains
-    // are accessed...
-    //
-
-    private static void registerWombats(MBeanServer server, String domain,
-            int count) {
-        try {
-            for (int i=0;i<count;i++) {
-                final ObjectName name =
-                        new ObjectName(domain+":type=Wombat,name=wombat#"+i);
-                server.createMBean("Wombat", name);
-            }
-        } catch (RuntimeException x) {
-            throw x;
-        } catch(Exception x) {
-            throw new RuntimeException(x.toString(),x);
-        }
-    }
-
-    public static void checkSize(String test, MBeanServer server, int size) {
-        System.out.println("We have now "+server.getMBeanCount()+
-                " MBeans in "+Arrays.toString(server.getDomains()));
-        if (server.getMBeanCount() != size)
-            fail(test+"Expected "+size+
-                    " MBeans, found " + server.getMBeanCount());
-    }
-
-    private static MBeanServer newMBeanServer() {
-        return MBeanServerFactory.newMBeanServer();
-    }
-
-    public static void lazyTest() throws Exception {
-        final String test = "lazyTest: ";
-        System.out.println("" +
-                "\nThis test checks that it is possible to perform lazy loading" +
-                "\nof MBeans in a given domain by using a JMXDomain subclass" +
-                "\nfor that domain.");
-
-        System.out.println(test + " START");
-
-        // The "global" MBeanServer...
-        final MBeanServer server = newMBeanServer();
-
-        // An MBeanServer proxy which makes it possible to `lazy load'
-        // the platform MBeanServer domains inside the global MBeanServer.
-        //
-        final MBeanServerProxy  platform =
-                new MBeanServerProxy(new MBeanServerLoader() {
-
-            public MBeanServer loadMBeanServer() {
-                return ManagementFactory.getPlatformMBeanServer();
-            }
-        });
-
-
-        // The list of domain from the platform MBeanServer that will be
-        // lazily loaded in the global MBeanServer
-        //
-        final String[] platformDomains = {
-              "java.lang", "com.sun.management",
-              "java.util.logging", "java.nio"
-        };
-
-        // We create a second MBeanServer, in which we will store some
-        // custom MBeans. We will use this server to perform lazy loading
-        // of two domains: custom.awomb and custom.bwomb.
-        //
-        // We use an MBeanServerBuilder here so that the MBeans registered
-        // in our custom domain see all the MBeans in the global MBeanServer.
-        // We do this by saying that the 'outer' MBeanServer is our global
-        // servers. This means that the MBeans registered in the global
-        // MBeanServer will see the MBeans from custom.awomb and custom.bwomb,
-        // and the MBeans from custom.awomb and custom.bwomb will also see
-        // the MBeans from the global MBeanServer, including those from
-        // the platform domains.
-        //
-        final MBeanServerBuilder builder = new MBeanServerBuilder();
-        final MBeanServerDelegate delegate = builder.newMBeanServerDelegate();
-        final MBeanServer custom = builder.newMBeanServer("custom",
-                server, delegate);
-
-        // Number of MBean that we will put in each of the custom domain.
-        //
-        final int customCount = 10;
-
-        // We use one MBeanServer proxy for each of the custom domains.
-        // This makes it possible to load custom.awomb independently of
-        // custom.bwomb.
-        //
-        // Here, the logic of the loader is to register MBeans in the loaded
-        // domain as soon as the domain is loaded.
-        //
-        final MBeanServerProxy customa =
-                new MBeanServerProxy(new MBeanServerLoader() {
-            // A loader to register awomb MBeans in the custom MBeanServer.
-            public MBeanServer loadMBeanServer() {
-                registerWombats(custom, "custom.awomb", customCount);
-                return custom;
-            }
-        });
-        final MBeanServerProxy customb =
-                new MBeanServerProxy(new MBeanServerLoader() {
-            // A loader to register bwomb MBeans in the custom MBeanServer.
-            public MBeanServer loadMBeanServer() {
-                registerWombats(custom, "custom.bwomb", customCount);
-                return custom;
-            }
-        });
-
-        // A notification queue.
-        final BlockingQueue<Notification> queue =
-                new ArrayBlockingQueue<Notification>(100);
-
-        // A listener that puts notifs in the queue.
-        final NotificationListener l = new NotificationListener() {
-
-            public void handleNotification(Notification notification,
-                    Object handback) {
-                try {
-                    if (!queue.offer(notification, 5, TimeUnit.SECONDS)) {
-                        throw new RuntimeException("timeout exceeded");
-                    }
-                } catch (Exception x) {
-                    fail(test + "failed to handle notif", x);
-                }
-            }
-        };
-
-        // Create a LazyDomain for each of the platform domain.
-        // All platform domain share the same MBeanServer proxy, which means
-        // that loading one domain will also load all the others.
-        //
-        Map<String,LazyDomain> domainsMap = new HashMap<String,LazyDomain>();
-        for (String dom : platformDomains) {
-            domainsMap.put(dom, new LazyDomain(platform));
-        }
-        domainsMap.put("custom.awomb", new LazyDomain(customa));
-        domainsMap.put("custom.bwomb", new LazyDomain(customb));
-
-        for (Map.Entry<String,LazyDomain> e : domainsMap.entrySet()) {
-            server.registerMBean(e.getValue(),
-                    JMXDomain.getDomainObjectName(e.getKey()));
-        }
-
-        // check that lazy MBeans are not there...
-        checkSize(test,server,domainsMap.size()+1);
-
-        System.out.println(test+" registering listener with delegate.");
-        server.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, l,
-                null, null);
-
-        // check that lazy MBeans are not there...
-        checkSize(test,server,domainsMap.size()+1);
-
-        // force loading of custom.awomb.
-        final ObjectName awombat = new ObjectName(
-                "custom.awomb:type=Wombat,name=wombat#"+customCount/2);
-        if (!server.isRegistered(awombat))
-            fail(test+"Expected "+awombat+" to be reggistered!");
-
-        final int oldCount = domainsMap.size()+1+customCount;
-        checkSize(test,server,oldCount);
-
-        if (queue.peek() != null)
-            fail(test+"Received unexpected notifications: "+queue);
-
-
-        System.out.println(test+"creating a proxy for ClassLoadingMXBean.");
-        final ClassLoadingMXBean cl =
-                JMX.newMXBeanProxy(server,
-                new ObjectName(ManagementFactory.CLASS_LOADING_MXBEAN_NAME),
-                ClassLoadingMXBean.class);
-
-        checkSize(test,server,oldCount);
-
-        System.out.println(test+"Loaded classes: "+cl.getLoadedClassCount());
-
-        final int newCount = server.getMBeanCount();
-        if (newCount < oldCount+6)
-            fail(test+"Expected at least "+(oldCount+6)+
-                    " MBeans. Found "+newCount);
-
-        final ObjectName jwombat = new ObjectName("java.lang:type=Wombat");
-        server.createMBean("Wombat", jwombat);
-        System.out.println(test+"Created "+jwombat);
-        checkSize(test,server,newCount+1);
-
-        popADD(queue, jwombat, test);
-        if (queue.peek() != null)
-            fail(test+"Received unexpected notifications: "+queue);
-
-
-        int platcount = 0;
-        for (String dom : platformDomains) {
-            final Set<ObjectName> found =
-                    server.queryNames(new ObjectName(dom+":*"),null);
-            final int jcount = found.size();
-            System.out.println(test+"Found "+jcount+" MBeans in "+dom+
-                    ": "+found);
-            checkSize(test,server,newCount+1);
-            platcount += (jcount-1);
-        }
-        checkSize(test,server,oldCount+platcount);
-
-        final ObjectName owombat = new ObjectName("custom:type=Wombat");
-        server.createMBean("Wombat", owombat);
-        System.out.println(test+"Created "+owombat);
-        checkSize(test,server,newCount+2);
-        popADD(queue, owombat, test);
-        if (queue.peek() != null)
-            fail(test+"Received unexpected notifications: "+queue);
-
-        final Set<ObjectName> jwombatView = (Set<ObjectName>)
-                server.invoke(jwombat, "listMatching", new Object[] {null},
-                new String[] {ObjectName.class.getName()});
-        System.out.println(test+jwombat+" sees: "+jwombatView);
-        checkSize(test, server, newCount+2);
-        if (jwombatView.size() != (platcount+1))
-            fail(test+jwombat+" sees "+jwombatView.size()+" MBeans - should" +
-                    " have seen "+(platcount+1));
-
-        final Set<ObjectName> platformMBeans =
-                ManagementFactory.getPlatformMBeanServer().
-                queryNames(null, null);
-        if (!platformMBeans.equals(jwombatView))
-            fail(test+jwombat+" should have seen "+platformMBeans);
-
-        // check that awombat triggers loading of bwombats
-        final Set<ObjectName> awombatView = (Set<ObjectName>)
-                server.invoke(awombat, "listMatching", new Object[] {null},
-                new String[] {ObjectName.class.getName()});
-        System.out.println(test+awombat+" sees: "+awombatView);
-        final int totalCount = newCount+2+customCount;
-        checkSize(test, server, totalCount);
-        if (awombatView.size() != totalCount)
-            fail(test+jwombat+" sees "+jwombatView.size()+" MBeans - should" +
-                    " have seen "+totalCount);
-
-        final Set<ObjectName> allMBeans = server.
-                queryNames(null, null);
-        if (!allMBeans.equals(awombatView))
-            fail(test+awombat+" should have seen "+allMBeans);
-
-        System.out.println(test + " PASSED");
-
-    }
-
-
-    public static void lazyStarterTest() throws Exception {
-        final String test = "lazyStarterTest: ";
-        System.out.println("" +
-                "\nThis test checks that it is possible to perform lazy loading" +
-                "\nof MBeans in a given domain by using a transient JMXDomain" +
-                "\nsubclass for that domain. ");
-
-        System.out.println(test + " START");
-
-        // The "global" MBeanServer...
-        final MBeanServer platform =
-                ManagementFactory.getPlatformMBeanServer();
-
-        // A notification queue.
-        final BlockingQueue<Notification> queue =
-                new ArrayBlockingQueue<Notification>(100);
-
-        // A listener that puts notifs in the queue.
-        final NotificationListener l = new NotificationListener() {
-
-            public void handleNotification(Notification notification,
-                    Object handback) {
-                try {
-                    if (!queue.offer(notification, 5, TimeUnit.SECONDS)) {
-                        throw new RuntimeException("timeout exceeded");
-                    }
-                } catch (Exception x) {
-                    fail(test + "failed to handle notif", x);
-                }
-            }
-        };
-
-        System.out.println(test+" registering listener with delegate.");
-        platform.addNotificationListener(MBeanServerDelegate.DELEGATE_NAME, l,
-                null, null);
-
-        final String ld1 = "lazy1";
-        final String ld2 = "lazy2";
-        final int wCount = 5;
-        final LazyStarterDomain lazy1 = new LazyStarterDomain() {
-            @Override
-            protected void loadMBeans(MBeanServer server, String domain) {
-                registerWombats(server, ld1, wCount);
-            }
-        };
-        final LazyStarterDomain lazy2 = new LazyStarterDomain() {
-            @Override
-            protected void loadMBeans(MBeanServer server, String domain) {
-                registerWombats(server, ld2, wCount);
-            }
-        };
-        final ObjectName lo1 = JMXDomain.getDomainObjectName(ld1);
-        final ObjectName lo2 = JMXDomain.getDomainObjectName(ld2);
-
-        final int initial = platform.getMBeanCount();
-
-        platform.registerMBean(lazy1, lo1);
-        System.out.println(test+"registered "+lo1);
-        checkSize(test, platform, initial+1);
-        popADD(queue, lo1, test);
-
-        platform.registerMBean(lazy2, lo2);
-        System.out.println(test+"registered "+lo2);
-        checkSize(test, platform, initial+2);
-        popADD(queue, lo2, test);
-
-
-        final ObjectName awombat = new ObjectName(
-                ld1+":type=Wombat,name=wombat#"+wCount/2);
-        if (!platform.isRegistered(awombat))
-            fail(test+"Expected "+awombat+" to be reggistered!");
-        checkSize(test,platform,initial+wCount+1);
-        popREM(queue, lo1, test);
-        final ObjectName pat1 =
-                new ObjectName(ld1+":type=Wombat,name=wombat#*");
-        for (int i=0;i<wCount;i++) {
-            popADD(queue,pat1,test);
-        }
-        System.out.println(test+"Found: "+
-                platform.queryNames(pat1,null));
-        checkSize(test,platform,initial+wCount+1);
-
-        final Set<ObjectName> all = platform.queryNames(null, null);
-        popREM(queue, lo2, test);
-        System.out.println(test+"Now found: "+all);
-        checkSize(test,platform,initial+wCount+wCount);
-        final ObjectName pat2 =
-                new ObjectName(ld2+":type=Wombat,name=wombat#*");
-        for (int i=0;i<wCount;i++) {
-            popADD(queue,pat2,test);
-        }
-
-        System.out.println(test+"check concurrent modification " +
-                "of the DomainDispatcher.");
-        System.out.println(test+"This will fail if the DomainDispatcher" +
-                " doesn't allow concurrent modifications.");
-        final HashMap<String,LazyStarterDomain> testConcurrent =
-                new HashMap<String,LazyStarterDomain>();
-        for (int i=0;i<(100/wCount);i++) {
-            final String ld = "concurrent.lazy"+i;
-            final LazyStarterDomain lazy = new LazyStarterDomain() {
-                @Override
-                protected void loadMBeans(MBeanServer server, String domain) {
-                    registerWombats(server, ld, wCount-1);
-                }
-            };
-            testConcurrent.put(ld, lazy);
-            final ObjectName lo = JMXDomain.getDomainObjectName(ld);
-            platform.registerMBean(lazy, lo);
-            popADD(queue, lo, test);
-        }
-
-        System.out.println(test+"Big autoload: "+
-                platform.queryNames(null,null));
-        System.out.println(test+"Big after load: "+
-                platform.queryNames(null,null));
-        if (!platform.queryNames(JMXDomain.getDomainObjectName("*"), null).
-                isEmpty()) {
-            fail(test+" some domains are still here: "+
-                    platform.queryNames(
-                    JMXDomain.getDomainObjectName("*"), null));
-        }
-        queue.clear();
-        System.out.println(test+"PASSED: The DomainDispatcher appears to be " +
-                "resilient to concurrent modifications.");
-    }
-
-    public static void main(String... args) throws Exception {
-
-        lazyTest();
-        lazyStarterTest();
-
-        if (lastException != null)
-            throw lastException;
-    }
-}
--- a/test/javax/management/namespace/LeadingSeparatorsTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,238 +0,0 @@
-/*
- * 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 LeadingSeparatorsTest.java
- * @summary Test that the semantics of a leading // in ObjectName is respected.
- * @author Daniel Fuchs
- * @bug 5072476 6768935
- * @run clean LeadingSeparatorsTest Wombat WombatMBean
- * @compile -XDignore.symbol.file=true  LeadingSeparatorsTest.java
- * @run build LeadingSeparatorsTest Wombat WombatMBean
- * @run main LeadingSeparatorsTest
- */
-
-import java.lang.management.ManagementFactory;
-import java.util.Arrays;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.logging.Logger;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXRemoteNamespace;
-import javax.management.namespace.JMXNamespace;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * Class LeadingSeparatorsTest
- * @author Sun Microsystems, 2005 - All rights reserved.
- */
-public class LeadingSeparatorsTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(LeadingSeparatorsTest.class.getName());
-
-    /** Creates a new instance of NullObjectNameTest */
-    public LeadingSeparatorsTest() {
-    }
-
-    public static interface MyWombatMBean extends WombatMBean {
-        public Set<ObjectName> untrue(ObjectName pat) throws Exception;
-    }
-    public static class MyWombat
-            extends Wombat implements MyWombatMBean {
-        public MyWombat() throws NotCompliantMBeanException {
-            super(MyWombatMBean.class);
-        }
-
-        public Set<ObjectName> untrue(ObjectName pat) throws Exception {
-            final Set<ObjectName> res=listMatching(pat.withDomain("*"));
-            final Set<ObjectName> untrue = new HashSet<ObjectName>();
-            for (ObjectName a:res) {
-                untrue.add(a.withDomain(pat.getDomain()+"//"+a.getDomain()));
-            }
-            return untrue;
-        }
-    }
-
-    static String failure=null;
-
-    public static void testRegister() throws Exception {
-        final MBeanServer top = ManagementFactory.getPlatformMBeanServer();
-        final MBeanServer sub = MBeanServerFactory.createMBeanServer();
-        final JMXServiceURL url = new JMXServiceURL("rmi",null,0);
-        final JMXConnectorServer srv =
-                JMXConnectorServerFactory.newJMXConnectorServer(url,null,sub);
-        srv.start();
-
-        try {
-
-            // Create a namespace rmi// that points to 'sub' and flows through
-            // a JMXRemoteNamespace connected to 'srv'
-            // The namespace rmi// will accept createMBean, but not registerMBean.
-            //
-            final JMXRemoteNamespace rmiHandler = JMXRemoteNamespace.
-                    newJMXRemoteNamespace(srv.getAddress(),null);
-            top.registerMBean(rmiHandler,
-                    JMXNamespaces.getNamespaceObjectName("rmi"));
-            top.invoke(JMXNamespaces.getNamespaceObjectName("rmi"),
-                    "connect", null, null);
-
-            // Create a namespace direct// that points to 'sub' and flows
-            // through a direct reference to 'sub'.
-            // The namespace direct// will accept createMBean, and registerMBean.
-            //
-            final JMXNamespace directHandler = new JMXNamespace(sub);
-            top.registerMBean(directHandler,
-                    JMXNamespaces.getNamespaceObjectName("direct"));
-
-            final ObjectName n1 = new ObjectName("//direct//w:type=Wombat");
-            final ObjectName n2 = new ObjectName("direct//w:type=Wombat");
-            final ObjectName n3 = new ObjectName("//rmi//w:type=Wombat");
-            final ObjectName n4 = new ObjectName("rmi//w:type=Wombat");
-
-            // register wombat using an object name with a leading //
-            final Object     obj = new MyWombat();
-            // check that returned object name doesn't have the leading //
-            assertEquals(n2,top.registerMBean(obj, n2).getObjectName());
-            System.out.println(n1+" registered");
-
-            // check that the registered Wombat can be accessed with all its
-            // names.
-            System.out.println(n2+" mood is: "+top.getAttribute(n2, "Mood"));
-            try {
-                System.out.println(n1+" mood is: "+top.getAttribute(n1, "Mood"));
-                throw new Exception("Excepected exception not thrown for "+n1);
-            } catch (InstanceNotFoundException x) {
-                System.out.println("OK: "+x);
-            }
-            System.out.println(n4+" mood is: "+top.getAttribute(n4, "Mood"));
-            try {
-                System.out.println(n3+" mood is: "+top.getAttribute(n3, "Mood"));
-                throw new Exception("Excepected exception not thrown for "+n3);
-            } catch (InstanceNotFoundException x) {
-                System.out.println("OK: "+x);
-            }
-
-            // call listMatching. The result should not contain any prefix.
-            final Set<ObjectName> res = (Set<ObjectName>)
-                    top.invoke(n4, "listMatching",
-                    // remove rmi// from rmi//*:*
-                    JMXNamespaces.deepReplaceHeadNamespace(
-                    new Object[] {ObjectName.WILDCARD.withDomain("rmi//*")},
-                    "rmi", ""), new String[] {ObjectName.class.getName()});
-
-            // add rmi// prefix to all names in res.
-            final Set<ObjectName> res1 =
-                   JMXNamespaces.deepReplaceHeadNamespace(res, "", "rmi");
-            System.out.println("got: "+res1);
-
-            // compute expected result
-            final Set<ObjectName> res2 = sub.queryNames(null,null);
-            final Set<ObjectName> res3 = new HashSet<ObjectName>();
-            for (ObjectName o:res2) {
-               res3.add(o.withDomain("rmi//"+o.getDomain()));
-            }
-            System.out.println("expected: "+res3);
-            assertEquals(res1, res3);
-
-            // invoke "untrue(//niark//niark:*)"
-            // should return a set were all ObjectNames begin with
-            // //niark//niark//
-            //
-            final Set<ObjectName> res4 = (Set<ObjectName>)
-                    top.invoke(n4, "untrue",
-                    // remove niark//niark : should remove nothing since
-                    // our ObjectName begins with a leading //
-                    JMXNamespaces.deepReplaceHeadNamespace(
-                    new Object[] {
-                       ObjectName.WILDCARD.withDomain("//niark//niark")},
-                    "niark//niark", ""),
-                    new String[] {ObjectName.class.getName()});
-            System.out.println("got: "+res4);
-
-            // add rmi// should add nothing since the returned names have a
-            // leading //
-            //
-            final Set<ObjectName> res5 =
-                   JMXNamespaces.deepReplaceHeadNamespace(res4, "", "rmi");
-            System.out.println("got#2: "+res5);
-
-            // compute expected result
-            final Set<ObjectName> res6 = new HashSet<ObjectName>();
-            for (ObjectName o:res2) {
-               res6.add(o.withDomain("//niark//niark//"+o.getDomain()));
-            }
-            System.out.println("expected: "+res6);
-
-            // both res4 and res5 should be equals to the expected result.
-            assertEquals(res4, res6);
-            assertEquals(res5, res6);
-
-        } finally {
-            srv.stop();
-        }
-
-        if (failure != null)
-            throw new Exception(failure);
-
-
-    }
-    private static void assertEquals(Object x, Object y) {
-        if (!equal(x, y))
-            failed("expected " + string(x) + "; got " + string(y));
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        if (x.getClass().isArray())
-            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
-        return x.equals(y);
-    }
-
-    private static String string(Object x) {
-        String s = Arrays.deepToString(new Object[] {x});
-        return s.substring(1, s.length() - 1);
-    }
-
-
-    private static void failed(String why) {
-        failure = why;
-        new Throwable("FAILED: " + why).printStackTrace(System.out);
-    }
-
-    public static void main(String[] args) throws Exception {
-        testRegister();
-    }
-}
--- a/test/javax/management/namespace/MXBeanRefTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 MXBeanRefTest.java
- * @bug 5072476
- * @summary Test that MXBean proxy references work correctly in the presence
- * of namespaces.
- * @author Eamonn Mcmanus
- */
-
-/**
- * The idea is that we will create a hierarchy like this:
- * a//
- *   X
- *   b//
- *     Y
- *     Z
- * and we will use MXBean references so we have links like this:
- * a//
- *   X----+
- *   b//  |
- *       /
- *     Y
- *      \
- *      /
- *     Z
- * In other words, X.getY() will return a proxy for Y, which the MXBean
- * framework will map to b//Y.  A proxy for a//X should then map this
- * into a proxy for a//b//Y.  That's easy.  But then if we call getZ()
- * on this proxy, the MXBean framework will return just Z, and the proxy
- * must map that into a proxy for a//b//Z.
- */
-
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Proxy;
-import java.lang.reflect.UndeclaredThrowableException;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerInvocationHandler;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.openmbean.OpenDataException;
-
-public class MXBeanRefTest {
-
-    public static interface ZMXBean {
-        public void success();
-    }
-    public static class ZImpl implements ZMXBean {
-        public void success() {}
-    }
-
-    public static interface YMXBean {
-        public ZMXBean getZ();
-        public void setZ(ZMXBean z);
-    }
-    public static class YImpl implements YMXBean {
-        private ZMXBean z;
-
-        public YImpl(ZMXBean z) {
-            this.z = z;
-        }
-
-        public ZMXBean getZ() {
-            return z;
-        }
-
-        public void setZ(ZMXBean z) {
-            this.z = z;
-        }
-    }
-
-    public static interface XMXBean {
-        public YMXBean getY();
-    }
-    public static class XImpl implements XMXBean {
-        private final YMXBean yProxy;
-
-        public XImpl(YMXBean yProxy) {
-            this.yProxy = yProxy;
-        }
-
-        public YMXBean getY() {
-            return yProxy;
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-
-        // Set up namespace hierarchy a//b//
-        MBeanServer ambs = MBeanServerFactory.newMBeanServer();
-        MBeanServer bmbs = MBeanServerFactory.newMBeanServer();
-        JMXNamespace bHandler = new JMXNamespace(bmbs);
-        ObjectName bHandlerName = JMXNamespaces.getNamespaceObjectName("b");
-        System.out.println(bHandlerName);
-        ambs.registerMBean(bHandler, bHandlerName);
-        JMXNamespace aHandler = new JMXNamespace(ambs);
-        ObjectName aHandlerName = JMXNamespaces.getNamespaceObjectName("a");
-        mbs.registerMBean(aHandler, aHandlerName);
-
-        ZMXBean z = new ZImpl();
-        ObjectName zName = new ObjectName("foo:type=Z");
-        bmbs.registerMBean(z, zName);
-
-        YMXBean y = new YImpl(z);
-        ObjectName yName = new ObjectName("foo:type=Y");
-        bmbs.registerMBean(y, yName);
-
-        ObjectName yNameInA = new ObjectName("b//" + yName);
-        System.out.println("MBeanInfo for Y as seen from a//:");
-        System.out.println(ambs.getMBeanInfo(yNameInA));
-        YMXBean yProxyInA = JMX.newMXBeanProxy(ambs, yNameInA, YMXBean.class);
-        XMXBean x = new XImpl(yProxyInA);
-        ObjectName xName = new ObjectName("foo:type=X");
-        ambs.registerMBean(x, xName);
-
-        ObjectName xNameFromTop = new ObjectName("a//" + xName);
-        XMXBean xProxy = JMX.newMXBeanProxy(mbs, xNameFromTop, XMXBean.class);
-        System.out.println("Name of X Proxy: " + proxyName(xProxy));
-        YMXBean yProxy = xProxy.getY();
-        System.out.println("Name of Y Proxy: " + proxyName(yProxy));
-        ZMXBean zProxy = yProxy.getZ();
-        System.out.println("Name of Z Proxy: " + proxyName(zProxy));
-
-        System.out.println("Operation through Z proxy...");
-        zProxy.success();
-
-        System.out.println("Changing Y's ref to Z...");
-        yProxy.setZ(zProxy);
-        zProxy = yProxy.getZ();
-        System.out.println("Name of Z Proxy now: " + proxyName(zProxy));
-        System.out.println("Operation through Z proxy again...");
-        zProxy.success();
-
-        System.out.println("Changing Y's ref to a bogus one...");
-        ZMXBean zProxyBad = JMX.newMXBeanProxy(mbs, zName, ZMXBean.class);
-        try {
-            yProxy.setZ(zProxyBad);
-        } catch (UndeclaredThrowableException e) {
-            Throwable cause = e.getCause();
-            if (cause instanceof OpenDataException) {
-                System.out.println("...correctly got UndeclaredThrowableException");
-                System.out.println("...wrapping: " + cause);
-            } else
-                throw new Exception("FAILED: wrong exception: " + cause);
-        }
-
-        System.out.println("Test passed");
-    }
-
-    private static ObjectName proxyName(Object proxy) {
-        InvocationHandler ih = Proxy.getInvocationHandler(proxy);
-        MBeanServerInvocationHandler mbsih = (MBeanServerInvocationHandler) ih;
-        return mbsih.getObjectName();
-    }
-}
--- a/test/javax/management/namespace/NamespaceController.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,405 +0,0 @@
-/*
- * 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.
- */
-
-import com.sun.jmx.namespace.ObjectNameRouter;
-import static javax.management.namespace.JMXNamespaces.NAMESPACE_SEPARATOR;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXRemoteNamespaceMBean;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * The {@code NamespaceController} MBean makes it possible to easily
- * create mount points ({@linkplain JMXNamespace JMXNamespaces}) in an
- * {@code MBeanServer}.
- * There is at most one instance of NamespaceController in an
- * MBeanServer - which can be created using the {@link #createInstance
- * createInstance} method. The {@code NamespaceController} MBean will
- * make it possible to remotely create name spaces by mounting remote
- * MBeanServers into the MBeanServer in which it was registered.
- */
-// This API was originally in the draft of javax/management/namespaces
-// but we decided to retire it. Rather than removing all the associated
-// tests I have moved the API to the test hierarchy - so it is now used as
-// an additional (though somewhat complex) test case...
-//
-public class NamespaceController implements NamespaceControllerMBean,
-        NotificationEmitter, MBeanRegistration {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(NamespaceController.class.getName());
-
-    private static long seqNumber=0;
-
-    private final NotificationBroadcasterSupport broadcaster =
-            new NotificationBroadcasterSupport();
-
-    private volatile MBeanServer mbeanServer = null;
-
-    private volatile ObjectName objectName = null;
-
-    //was: NamespaceController.class.getPackage().getName()
-    public static final String NAMESPACE_CONTROLLER_DOMAIN = "jmx.ns";
-
-    /**
-     * Creates a new NamespaceController.
-     * Using {@link #createInstance} should be preferred.
-     **/
-    public NamespaceController() {
-        this(null);
-    }
-
-    public NamespaceController(MBeanServer mbeanServer) {
-        this.mbeanServer = mbeanServer;
-    }
-
-    /*
-     * MBeanNotification support
-     * You shouldn't update these methods
-     */
-    public final void addNotificationListener(NotificationListener listener,
-            NotificationFilter filter, Object handback) {
-        broadcaster.addNotificationListener(listener, filter, handback);
-    }
-
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return new MBeanNotificationInfo[] {
-        };
-    }
-
-    public final void removeNotificationListener(NotificationListener listener)
-        throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener);
-    }
-
-    public final void removeNotificationListener(NotificationListener listener,
-            NotificationFilter filter, Object handback)
-            throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener, filter, handback);
-    }
-
-    public static synchronized long getNextSeqNumber() {
-        return seqNumber++;
-    }
-
-    protected final void sendNotification(Notification n) {
-        if (n.getSequenceNumber()<=0)
-            n.setSequenceNumber(getNextSeqNumber());
-        if (n.getSource()==null)
-            n.setSource(objectName);
-        broadcaster.sendNotification(n);
-    }
-
-    /**
-     * The ObjectName with which this MBean was registered.
-     * <p>Unless changed by subclasses, this is
-     * {@code
-     *  "javax.management.namespace:type="+this.getClass().getSimpleName()}.
-     * @return this MBean's ObjectName, or null if this MBean was never
-     *         registered.
-     **/
-    public final ObjectName getObjectName() {
-        return objectName;
-    }
-
-    /**
-     * The MBeanServer  served by this NamespaceController.
-     * @return the MBeanServer  served by this NamespaceController.
-     **/
-    public final MBeanServer getMBeanServer() {
-        return mbeanServer;
-    }
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * registered in the MBean server. If the name of the MBean is not
-     * specified, the MBean can provide a name for its registration. If
-     * any exception is raised, the MBean will not be registered in the
-     * MBean server. Subclasses which override {@code preRegister}
-     * must call {@code super.preRegister(name,server)};
-     * @param server The MBean server in which the MBean will be registered.
-     * @param name The object name of the MBean.
-     *        The name must be either {@code null} - or equal to that
-     *        described by {@link #getObjectName}.
-     * @return The name under which the MBean is to be registered.
-     *         This will be the name described by {@link #getObjectName}.
-     * @throws MalformedObjectNameException if the supplied name does not
-     *        meet expected requirements.
-     */
-    public ObjectName preRegister(MBeanServer server, ObjectName name)
-        throws MalformedObjectNameException {
-        objectName = name;
-        final ObjectName single =
-                ObjectName.getInstance(NAMESPACE_CONTROLLER_DOMAIN+
-                ":type="+this.getClass().getSimpleName());
-        if (name!=null && !single.equals(name))
-            throw new MalformedObjectNameException(name.toString());
-        if (mbeanServer == null) mbeanServer = server;
-        return single;
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having
-     * been registered in the MBean server or after the registration has
-     * failed.
-     * @param registrationDone Indicates whether or not the MBean has been
-     * successfully registered in the MBean server. The value false means
-     * that the registration has failed.
-     */
-    public void postRegister(Boolean registrationDone) {
-        //TODO postRegister implementation;
-    }
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * unregistered by the MBean server.
-     * @throws Exception This exception will be caught by the MBean server and
-     * re-thrown as an MBeanRegistrationException.
-     */
-    public void preDeregister() throws Exception {
-        //TODO preDeregister implementation;
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having been
-     * unregistered in the MBean server.
-     */
-    public void postDeregister() {
-        //TODO postDeregister implementation;
-    }
-
-    public String mount(JMXServiceURL url,
-            String targetPath,
-            Map<String,Object> optionsMap)
-            throws IOException {
-        return mount(url, targetPath, "", optionsMap);
-    }
-
-    // see NamespaceControllerMBean
-    public String mount(JMXServiceURL url,
-            String targetPath,
-            String sourcePath,
-            Map<String,Object> optionsMap)
-            throws IOException {
-
-        // TODO: handle description.
-        final String dirName =
-                JMXNamespaces.normalizeNamespaceName(targetPath);
-
-         try {
-            final ObjectInstance moi =
-                    JMXRemoteTargetNamespace.createNamespace(mbeanServer,
-                    dirName,url,optionsMap,
-                    JMXNamespaces.normalizeNamespaceName(sourcePath)
-                    );
-            final ObjectName nsMBean = moi.getObjectName();
-            try {
-                mbeanServer.invoke(nsMBean, "connect", null,null);
-            } catch (Throwable t) {
-                mbeanServer.unregisterMBean(nsMBean);
-                throw t;
-            }
-            return getMountPointID(nsMBean);
-        } catch (InstanceAlreadyExistsException x) {
-            throw new IllegalArgumentException(targetPath,x);
-         } catch (IOException x) {
-            throw x;
-        } catch (Throwable x) {
-            if (x instanceof Error) throw (Error)x;
-            Throwable cause = x.getCause();
-            if (cause instanceof IOException)
-                throw ((IOException)cause);
-            if (cause == null) cause = x;
-
-            final IOException io =
-                    new IOException("connect failed: "+cause);
-            io.initCause(cause);
-            throw io;
-        }
-    }
-
-    private String getMountPointID(ObjectName dirName) {
-            return dirName.toString();
-    }
-
-    private ObjectName getHandlerName(String mountPointID) {
-        try {
-            final ObjectName tryit = ObjectName.getInstance(mountPointID);
-            final ObjectName formatted =
-                    JMXNamespaces.getNamespaceObjectName(tryit.getDomain());
-            if (!formatted.equals(tryit))
-                throw new IllegalArgumentException(mountPointID+
-                        ": invalid mountPointID");
-            return formatted;
-        } catch (MalformedObjectNameException x) {
-            throw new IllegalArgumentException(mountPointID,x);
-        }
-    }
-
-    public boolean unmount(String mountPointID)
-        throws IOException {
-        final ObjectName dirName = getHandlerName(mountPointID);
-        if (!mbeanServer.isRegistered(dirName))
-            throw new IllegalArgumentException(mountPointID+
-                    ": no such name space");
-        final JMXRemoteNamespaceMBean mbean =
-                JMX.newMBeanProxy(mbeanServer,dirName,
-                    JMXRemoteNamespaceMBean.class);
-        try {
-            mbean.close();
-        } catch (IOException io) {
-            LOG.fine("Failed to close properly - ignoring exception: "+io);
-            LOG.log(Level.FINEST,
-                    "Failed to close properly - ignoring exception",io);
-        } finally {
-            try {
-                mbeanServer.unregisterMBean(dirName);
-            } catch (InstanceNotFoundException x) {
-                throw new IllegalArgumentException(mountPointID+
-                        ": no such name space", x);
-            } catch (MBeanRegistrationException x) {
-                final IOException io =
-                        new IOException(mountPointID +": failed to unmount");
-                io.initCause(x);
-                throw io;
-            }
-        }
-        return true;
-    }
-
-    public boolean ismounted(String targetPath) {
-        return mbeanServer.isRegistered(JMXNamespaces.getNamespaceObjectName(targetPath));
-    }
-
-    public ObjectName getHandlerNameFor(String targetPath) {
-        return JMXNamespaces.getNamespaceObjectName(targetPath);
-    }
-
-    public String[] findNamespaces() {
-        return findNamespaces(null,null,0);
-    }
-
-
-    private ObjectName getDirPattern(String from) {
-        try {
-            if (from == null)
-                return ObjectName.getInstance(ALL_NAMESPACES);
-            final String namespace =
-                  ObjectNameRouter.normalizeNamespacePath(from,false,true,false);
-            if (namespace.equals(""))
-                return ObjectName.getInstance(ALL_NAMESPACES);
-            if (JMXNamespaces.getNamespaceObjectName(namespace).isDomainPattern())
-                throw new IllegalArgumentException(from);
-            return ObjectName.getInstance(namespace+NAMESPACE_SEPARATOR+ALL_NAMESPACES);
-        } catch (MalformedObjectNameException x) {
-            throw new IllegalArgumentException(from,x);
-        }
-    }
-
-    public String[] findNamespaces(String from, String regex, int depth) {
-        if (depth < 0) return new String[0];
-        final Set<String> res = new TreeSet<String>();
-        final ObjectName all = getDirPattern(from);
-        Set<ObjectName> names = mbeanServer.queryNames(all,null);
-        for (ObjectName dirName : names) {
-            final String dir = dirName.getDomain();
-            if (regex == null || dir.matches(regex))
-                res.add(dir);
-            if (depth > 0)
-                res.addAll(Arrays.asList(findNamespaces(dir,regex,depth-1)));
-        }
-        return res.toArray(new String[res.size()]);
-    }
-
-    /**
-     * Creates a {@link NamespaceController} MBean in the provided
-     * {@link MBeanServerConnection}.
-     * <p>The name of the MBean is that returned by {@link #preRegister}
-     * as described by {@link #getObjectName}.
-     * @throws IOException if an {@code IOException} is raised when invoking
-     *         the provided connection.
-     * @throws InstanceAlreadyExistsException if an MBean was already
-     *         registered with the NamespaceController's name.
-     * @throws MBeanRegistrationException if thrown by {@link
-     * MBeanServerConnection#createMBean(java.lang.String,javax.management.ObjectName)
-     * server.createMBean}
-     * @throws MBeanException if thrown by {@link
-     * MBeanServerConnection#createMBean(java.lang.String,javax.management.ObjectName)
-     * server.createMBean}
-     * @return the {@link ObjectInstance}, as returned by {@link
-     * MBeanServerConnection#createMBean(java.lang.String,javax.management.ObjectName)
-     * server.createMBean}
-     **/
-    public static ObjectInstance createInstance(MBeanServerConnection server)
-        throws IOException, InstanceAlreadyExistsException,
-            MBeanRegistrationException, MBeanException {
-        try {
-            final ObjectInstance instance =
-                server.createMBean(NamespaceController.class.getName(), null);
-            return instance;
-        } catch (NotCompliantMBeanException ex) {
-            throw new RuntimeException("unexpected exception: " + ex, ex);
-        } catch (ReflectionException ex) {
-            throw new RuntimeException("unexpected exception: " + ex, ex);
-        }
-    }
-
-    private final static String ALL_NAMESPACES=
-            "*"+NAMESPACE_SEPARATOR+":"+
-            JMXNamespace.TYPE_ASSIGNMENT;
-
-}
--- a/test/javax/management/namespace/NamespaceControllerMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * 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.
- */
-
-import java.io.IOException;
-import java.util.Map;
-
-import javax.management.ObjectName;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * The {@link NamespaceController} MBean makes it possible to easily
- * create mount points ({@link JMXNamespace JMXNamespaces}) in an
- * {@code MBeanServer}.
- */
-// This API was originally in the draft of javax/management/namespaces
-// but we decided to retire it. Rather than removing all the associated
-// tests I have moved the API to the test hierarchy - so it is now used as
-// an additional (though somewhat complex) test case...
-//
-public interface NamespaceControllerMBean {
-    /**
-     * Mount MBeans from the source path of the source URL into the specified
-     * target path of the target.
-     * @param url URL of the mounted source.
-     * @param targetPath Target path in which MBeans will be mounted.
-     * @param optionsMap connection map and options. See {@link
-     *      javax.management.namespace.JMXRemoteNamespace.Options
-     *      JMXRemoteNamespace.Options}
-     * @throws IOException Connection with the source failed
-     * @throws IllegalArgumentException Supplied parameters are
-     *         illegal, or combination of supplied parameters is illegal.
-     * @return A mount point id.
-     */
-    public String mount(JMXServiceURL url,
-            String targetPath,
-            Map<String,Object> optionsMap)
-            throws IOException, IllegalArgumentException;
-
-    /**
-     * Mount MBeans from the source path of the source URL into the specified
-     * target path of the target.
-     * @param url URL of the mounted source.
-     * @param targetPath Target path in which MBeans will be mounted.
-     * @param sourcePath source namespace path.
-     * @param optionsMap connection map and options. See {@link
-     *      javax.management.namespace.JMXRemoteNamespace.Options
-     *      JMXRemoteNamespace.Options}
-     * @throws IOException Connection with the source failed
-     * @throws IllegalArgumentException Supplied parameters are
-     *         illegal, or combination of supplied parameters is illegal.
-     * @return A mount point id.
-     */
-    public String mount(JMXServiceURL url,
-            String targetPath,
-            String sourcePath,
-            Map<String,Object> optionsMap)
-            throws IOException, IllegalArgumentException;
-
-    /**
-     * Unmount a previously mounted mount point.
-     * @param mountPointId A mount point id, as previously returned
-     *        by mount.
-     * @throws IllegalArgumentException Supplied parameters are
-     *         illegal, or combination of supplied parameters is illegal.
-     * @throws IOException thrown if the mount point {@link JMXNamespace}
-     *         couldn't be unregistered.
-     */
-    public boolean unmount(String mountPointId)
-        throws IOException, IllegalArgumentException;
-
-    /**
-     * Tells whether there already exists a {@link JMXNamespace} for
-     * the given <var>targetPath</var>.
-     * @param targetPath a target name space path.
-     * @return true if a {@link JMXNamespace} is registered for that
-     *         name space path.
-     **/
-    public boolean ismounted(String targetPath);
-
-    /**
-     * Returns the handler name for the provided target name space
-     * path. Can throw IllegalArgumentException if the provided
-     * targetPath contains invalid characters (like e.g. ':').
-     * @param targetPath A target name space path.
-     * @return the handler name for the provided target name space
-     * path.
-     **/
-    public ObjectName getHandlerNameFor(String targetPath);
-
-    /**
-     * Return a sorted array of locally mounted name spaces.
-     * This is equivalent to calling {@link
-     * #findNamespaces(java.lang.String,java.lang.String,int)
-     *  findNamespaces(null,null,0)};
-     * @return a sorted array of locally mounted name spaces.
-     **/
-    public String[] findNamespaces();
-
-    /**
-     * Return a sorted array of mounted name spaces, starting at
-     * <var>from</var> (if non null), and recursively searching up to
-     * provided <var>depth</var>.
-     * @param from A name spaces from which to start the search. If null,
-     *        will start searching from the MBeanServer root.
-     *        If not null, all returned names will start with <var>from//</var>.
-     * @param regex A regular expression that the returned names must match.
-     *        If null - no matching is performed and all found names are
-     *        returned. If not null, then all returned names satisfy
-     *        {@link String#matches name.matches(regex)};
-     * @param depth the maximum number of levels that the search algorithm
-     *        will cross. 0 includes only top level name spaces, 1 top level
-     *        and first level children etc... <var>depth</var> is evaluated
-     *        with regard to where the search starts - if a non null
-     *        <var>from</var> parameter is provided - then {@code depth=0}
-     *        corresponds to all name spaces found right below
-     *        <var>from//</var>.
-     * @return A sorted array of name spaces matching the provided criteria.
-     *         All returned names end with "//".
-     **/
-    public String[] findNamespaces(String from, String regex, int depth);
-}
--- a/test/javax/management/namespace/NamespaceCreationTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,263 +0,0 @@
-/*
- * 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 NamespaceCreationTest.java
- * @summary General JMXNamespace test.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean NamespaceCreationTest Wombat WombatMBean
- * @run build NamespaceCreationTest Wombat WombatMBean
- * @run main NamespaceCreationTest
- */
-
-
-import java.util.Collections;
-import java.util.Map;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.RuntimeMBeanException;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-
-/**
- * Test simple creation/registration of namespace.
- *
- */
-public class NamespaceCreationTest {
-    private static Map<String,Object> emptyEnvMap() {
-        return Collections.emptyMap();
-    }
-
-
-    public static class LocalNamespace extends JMXNamespace {
-
-        public LocalNamespace() {
-            super(MBeanServerFactory.newMBeanServer());
-        }
-
-    }
-
-    private static MBeanServer newMBeanServer() {
-        return MBeanServerFactory.newMBeanServer();
-    }
-
-    public static interface ThingMBean {}
-    public static class Thing implements ThingMBean, MBeanRegistration {
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-                throws Exception {
-            if (name == null) return new ObjectName(":type=Thing");
-            else return name;
-        }
-        public void postRegister(Boolean registrationDone) {
-        }
-
-        public void preDeregister() throws Exception {
-        }
-        public void postDeregister() {
-        }
-    }
-
-    /**
-     * Test that it is possible to create a dummy MBean with a null
-     * ObjectName - this is just a sanity check - as there are already
-     * other JMX tests that check that.
-     *
-     * @throws java.lang.Exception
-     */
-    public static void testCreateWithNull() throws Exception {
-        final MBeanServer server = newMBeanServer();
-        final ObjectInstance oi = server.registerMBean(new Thing(),null);
-        server.unregisterMBean(oi.getObjectName());
-        System.out.println("testCreateWithNull PASSED");
-    }
-
-    /**
-     * Check that we can register a JMXNamespace MBean, using its standard
-     * ObjectName.
-     * @throws java.lang.Exception
-     */
-    public static void testGoodObjectName() throws Exception {
-        MBeanServer server = newMBeanServer();
-        final ObjectName name =
-                JMXNamespaces.getNamespaceObjectName("gloups");
-        final ObjectInstance oi =
-                server.registerMBean(new LocalNamespace(),name);
-        System.out.println("Succesfully registered namespace: "+name);
-        try {
-            if (! name.equals(oi.getObjectName()))
-                throw new RuntimeException("testGoodObjectName: TEST failed: " +
-                        "namespace registered as: "+
-                    oi.getObjectName()+" expected: "+name);
-        } finally {
-            server.unregisterMBean(oi.getObjectName());
-        }
-        System.out.println("Succesfully unregistered namespace: "+name);
-        System.out.println("testGoodObjectName PASSED");
-    }
-
-    /**
-     * Check that we cannot register a JMXNamespace MBean, if we don't use
-     * its standard ObjectName.
-     * @throws java.lang.Exception
-     */
-    public static void testBadObjectName() throws Exception {
-        MBeanServer server = newMBeanServer();
-        Throwable exp = null;
-        final ObjectName name = new ObjectName("d:k=v");
-        try {
-            server.registerMBean(new LocalNamespace(),name);
-            System.out.println("testBadObjectName: " +
-                    "Error: MBean registered, no exception thrown.");
-        } catch(RuntimeMBeanException x) {
-            exp = x.getCause();
-        } catch(Exception x) {
-            throw new RuntimeException("testBadObjectName: TEST failed: " +
-                    "expected RuntimeMBeanException - got "+
-                    x);
-        }
-        if (exp == null)  server.unregisterMBean(name);
-        if (exp == null)
-            throw new RuntimeException("testBadObjectName: TEST failed: " +
-                    "expected IllegalArgumentException - got none");
-        if (!(exp instanceof IllegalArgumentException))
-            throw new RuntimeException("testBadObjectName: TEST failed: " +
-                    "expected IllegalArgumentException - got "+
-                    exp.toString(),exp);
-        System.out.println("Got expected exception: "+exp);
-        System.out.println("testBadObjectName PASSED");
-    }
-
-    /**
-     * Check that we cannot register a Wombat MBean in a namespace that does
-     * not exists.
-     *
-     * @throws java.lang.Exception
-     */
-    public static void testBadNamespace() throws Exception {
-        MBeanServer server = newMBeanServer();
-        Throwable exp = null;
-        final ObjectName name = new ObjectName("glips//d:k=v");
-
-        try {
-            server.registerMBean(new Wombat(),name);
-            System.out.println("testBadNamespace: " +
-                    "Error: MBean registered, no exception thrown.");
-        } catch(MBeanRegistrationException x) {
-            exp = x.getCause();
-        } catch(Exception x) {
-            throw new RuntimeException("testBadNamespace: TEST failed: " +
-                    "expected MBeanRegistrationException - got "+
-                    x);
-        }
-        if (exp == null)  server.unregisterMBean(name);
-        if (exp == null)
-            throw new RuntimeException("testBadNamespace: TEST failed: " +
-                    "expected IllegalArgumentException - got none");
-        if (!(exp instanceof IllegalArgumentException))
-            throw new RuntimeException("testBadNamespace: TEST failed: " +
-                    "expected IllegalArgumentException - got "+
-                    exp.toString(),exp);
-        System.out.println("Got expected exception: "+exp);
-        System.out.println("testBadNamespace PASSED");
-    }
-
-    /**
-     * Check that we cannot register a Wombat MBean with a domain name
-     * that ends with //. This is reserved for namespaces.
-     *
-     * @throws java.lang.Exception
-     */
-    public static void testBadDomain() throws Exception {
-        MBeanServer server = newMBeanServer();
-        Throwable exp = null;
-        final ObjectName name = new ObjectName("glups//:k=v");
-
-        try {
-            server.registerMBean(new Wombat(),name);
-            System.out.println("testBadDomain: Error: MBean registered, no exception thrown.");
-        } catch(RuntimeMBeanException x) {
-            exp = x.getCause();
-        } catch(Exception x) {
-            throw new RuntimeException("testBadDomain: TEST failed: " +
-                    "expected RuntimeMBeanException - got "+
-                    x);
-        }
-        if (exp == null)  server.unregisterMBean(name);
-        if (exp == null)
-            throw new RuntimeException("testBadDomain: TEST failed: " +
-                    "expected IllegalArgumentException - got none");
-        if (!(exp instanceof IllegalArgumentException))
-            throw new RuntimeException("testBadDomain: TEST failed: " +
-                    "expected IllegalArgumentException - got "+
-                    exp.toString(),exp);
-        System.out.println("Got expected exception: "+exp);
-        System.out.println("testBadDomain PASSED");
-    }
-
-    /**
-     * Check that we cannot register a Wombat MBean as if it were a
-     * JMXNamespace. Only JMXNamespace MBeans can have JMX Namespace names.
-     * @throws java.lang.Exception
-     */
-    public static void testBadClassName() throws Exception {
-        MBeanServer server = newMBeanServer();
-        Throwable exp = null;
-        final ObjectName name =
-                JMXNamespaces.getNamespaceObjectName("glops");
-        try {
-            server.registerMBean(new Wombat(),name);
-            System.out.println("testBadClassName: " +
-                    "Error: MBean registered, no exception thrown.");
-        } catch(RuntimeMBeanException x) {
-            exp = x.getCause();
-        } catch(Exception x) {
-            throw new RuntimeException("testBadClassName: TEST failed: " +
-                    "expected RuntimeMBeanException - got "+
-                    x);
-        }
-        if (exp == null)  server.unregisterMBean(name);
-        if (exp == null)
-            throw new RuntimeException("testBadClassName: TEST failed: " +
-                    "expected IllegalArgumentException - got none");
-        if (!(exp instanceof IllegalArgumentException))
-            throw new RuntimeException("testBadClassName: TEST failed: " +
-                    "expected IllegalArgumentException - got "+
-                    exp.toString(),exp);
-        System.out.println("Got expected exception: "+exp);
-        System.out.println("testBadClassName PASSED");
-    }
-
-    public static void main(String... args) throws Exception {
-        testCreateWithNull();
-        testGoodObjectName();
-        testBadObjectName();
-        testBadNamespace();
-        testBadDomain();
-        testBadClassName();
-    }
-}
--- a/test/javax/management/namespace/NamespaceNotificationsTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,381 +0,0 @@
-/*
- * 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 NamespaceNotificationsTest.java 1.12
- * @summary General Namespace & Notifications test.
- * @bug 5072476
- * @author Daniel Fuchs
- * @run clean NamespaceNotificationsTest
- *            Wombat WombatMBean JMXRemoteTargetNamespace
- *            NamespaceController NamespaceControllerMBean
- * @compile -XDignore.symbol.file=true  NamespaceNotificationsTest.java
- *            Wombat.java WombatMBean.java JMXRemoteTargetNamespace.java
- *            NamespaceController.java NamespaceControllerMBean.java
- * @run main NamespaceNotificationsTest
- */
-import com.sun.jmx.remote.util.EventClientConnection;
-import java.lang.management.ManagementFactory;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerFactory;
-import javax.management.MBeanServerNotification;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.loading.MLet;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.remote.JMXAddressable;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- *
- * @author Sun Microsystems, Inc.
- */
-public class NamespaceNotificationsTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(NamespaceNotificationsTest.class.getName());
-
-    /** Creates a new instance of NamespaceNotificationsTest */
-    public NamespaceNotificationsTest() {
-    }
-
-
-    public static JMXServiceURL export(MBeanServer server)
-    throws Exception {
-        final JMXServiceURL in = new JMXServiceURL("rmi",null,0);
-        final JMXConnectorServer cs =
-                JMXConnectorServerFactory.newJMXConnectorServer(in,null,null);
-        final ObjectName csname = ObjectName.
-                getInstance(cs.getClass().getPackage().getName()+
-                ":type="+cs.getClass().getSimpleName());
-        server.registerMBean(cs,csname);
-        cs.start();
-        return cs.getAddress();
-    }
-
-    public static class Counter {
-        int count;
-        public synchronized int count() {
-            count++;
-            notifyAll();
-            return count;
-        }
-        public synchronized int peek() {
-            return count;
-        }
-        public synchronized int waitfor(int max, long timeout)
-        throws InterruptedException {
-            final long start = System.currentTimeMillis();
-            while (count < max && timeout > 0) {
-                final long rest = timeout -
-                        (System.currentTimeMillis() - start);
-                if (rest <= 0) break;
-                wait(rest);
-            }
-            return count;
-        }
-    }
-
-    public static class CounterListener
-            implements NotificationListener {
-        final private Counter counter;
-        public CounterListener(Counter counter) {
-            this.counter = counter;
-        }
-        public void handleNotification(Notification notification,
-                Object handback) {
-            System.out.println("Received notif from " + handback +
-                    ":\n\t" + notification);
-            if (!notification.getSource().equals(handback)) {
-                System.err.println("OhOh... Unexpected source: \n\t"+
-                        notification.getSource()+"\n\twas expecting:\n\t"+
-                        handback);
-            }
-            counter.count();
-        }
-    }
-
-    public static void simpleTest(String[] args) {
-        try {
-            final MBeanServer server1 =
-                    ManagementFactory.getPlatformMBeanServer();
-            final JMXServiceURL url1 = export(server1);
-
-            final MBeanServer server2 =
-                    MBeanServerFactory.createMBeanServer("server2");
-            final JMXServiceURL url2 = export(server2);
-
-            final MBeanServer server3 =
-                    MBeanServerFactory.createMBeanServer("server3");
-            final JMXServiceURL url3 = export(server3);
-
-            final ObjectInstance ncinst =
-                    NamespaceController.createInstance(server1);
-
-            final NamespaceControllerMBean nc =
-                    JMX.newMBeanProxy(server1,ncinst.getObjectName(),
-                    NamespaceControllerMBean.class);
-
-            final Map<String,Object> options = new HashMap<String,Object>();
-            options.put(JMXRemoteTargetNamespace.CREATE_EVENT_CLIENT,"true");
-
-            final String mount1 =
-                    nc.mount(url1,"server1",options);
-            final String mount2 = nc.mount(url2,"server1//server2",
-                    options);
-            final String mount3 = nc.mount(url3,
-                    "server1//server2//server3",
-                    options);
-            final String mount13 = nc.mount(
-                    url1,
-                    "server3",
-                    "server2//server3",
-                    options);
-            final String mount21 = nc.mount(url1,"server2//server1",
-                    options);
-            final String mount31 = nc.mount(
-                    url1,
-                    "server3//server1",
-                    "server1",
-                    options);
-            final String mount32 = nc.mount(
-                    url1,
-                    "server3//server2",
-                    "server2",
-                    options);
-
-
-            final ObjectName deep =
-                    new ObjectName("server1//server2//server3//bush:type=Wombat,name=kanga");
-            server1.createMBean(Wombat.class.getName(),deep);
-
-            System.err.println("There's a wombat in the bush!");
-
-            final Counter counter = new Counter();
-
-            final NotificationListener listener =
-                    new CounterListener(counter);
-
-            final JMXConnector jc = JMXConnectorFactory.connect(url1);
-            final MBeanServerConnection aconn =
-                    EventClientConnection.getEventConnectionFor(
-                        jc.getMBeanServerConnection(),null);
-            aconn.addNotificationListener(deep,listener,null,deep);
-
-
-            MBeanServerConnection iconn =
-                    JMXNamespaces.narrowToNamespace(aconn, "server1//server1");
-            MBeanServerConnection bconn =
-                    JMXNamespaces.narrowToNamespace(aconn, "server3");
-            final ObjectName shallow =
-                    new ObjectName("bush:"+
-                    deep.getKeyPropertyListString());
-            final WombatMBean proxy =
-                    JMX.newMBeanProxy(EventClientConnection.getEventConnectionFor(
-                        bconn,null),shallow,WombatMBean.class,true);
-
-            ((NotificationEmitter)proxy).
-                    addNotificationListener(listener,null,shallow);
-            proxy.setCaption("I am a new Wombat!");
-            System.err.println("New caption: "+proxy.getCaption());
-            final int rcvcount = counter.waitfor(2,3000);
-            if (rcvcount != 2)
-                throw new RuntimeException("simpleTest failed: "+
-                        "received count is " +rcvcount);
-
-            System.err.println("simpleTest passed: got "+rcvcount+
-                    " notifs");
-
-        } catch (RuntimeException x) {
-            throw x;
-        } catch (Exception x) {
-            throw new RuntimeException("simpleTest failed: " + x,x);
-        }
-    }
-
-    public static class LocalNamespace extends
-            JMXNamespace {
-        LocalNamespace() {
-            super(MBeanServerFactory.newMBeanServer());
-        }
-
-    }
-
-    public static class ContextObject<K,V> {
-        public final K name;
-        public final V object;
-        public ContextObject(K name, V object) {
-            this.name = name;
-            this.object = object;
-        }
-        private Object[] data() {
-            return new Object[] {name,object};
-        }
-
-        @Override
-        public boolean equals(Object x) {
-            if (x instanceof ContextObject)
-                return Arrays.deepEquals(data(),((ContextObject<?,?>)x).data());
-            return false;
-        }
-        @Override
-        public int hashCode() {
-            return Arrays.deepHashCode(data());
-        }
-    }
-
-    private static <K,V> ContextObject<K,V> context(K k, V v) {
-        return new ContextObject<K,V>(k,v);
-    }
-
-    private static ObjectName name(String name) {
-        try {
-            return new ObjectName(name);
-        } catch(MalformedObjectNameException x) {
-            throw new IllegalArgumentException(name,x);
-        }
-    }
-
-    public static void simpleTest2() {
-        try {
-            System.out.println("\nsimpleTest2: STARTING\n");
-            final LocalNamespace foo = new LocalNamespace();
-            final LocalNamespace joe = new LocalNamespace();
-            final LocalNamespace bar = new LocalNamespace();
-            final MBeanServer server = MBeanServerFactory.newMBeanServer();
-
-            server.registerMBean(foo,JMXNamespaces.getNamespaceObjectName("foo"));
-            server.registerMBean(joe,JMXNamespaces.getNamespaceObjectName("foo//joe"));
-            server.registerMBean(bar,JMXNamespaces.getNamespaceObjectName("foo//bar"));
-            final BlockingQueue<ContextObject<String,MBeanServerNotification>> queue =
-                    new ArrayBlockingQueue<ContextObject<String,MBeanServerNotification>>(20);
-
-            final NotificationListener listener = new NotificationListener() {
-                public void handleNotification(Notification n, Object handback) {
-                    if (!(n instanceof MBeanServerNotification)) {
-                        System.err.println("Error: expected MBeanServerNotification");
-                        return;
-                    }
-                    final MBeanServerNotification mbsn =
-                            (MBeanServerNotification) n;
-
-                    // We will pass the namespace name in the handback.
-                    //
-                    final String namespace = (String) handback;
-                    System.out.println("Received " + mbsn.getType() +
-                            " for MBean " + mbsn.getMBeanName() +
-                            " from name space " + namespace);
-                    try {
-                        queue.offer(context(namespace,mbsn),500,TimeUnit.MILLISECONDS);
-                    } catch (Exception x) {
-                        System.err.println("Failed to enqueue received notif: "+mbsn);
-                        x.printStackTrace();
-                    }
-                }
-            };
-
-            server.addNotificationListener(JMXNamespaces.insertPath("foo//joe",
-                    MBeanServerDelegate.DELEGATE_NAME),listener,null,"foo//joe");
-            server.addNotificationListener(JMXNamespaces.insertPath("foo//bar",
-                    MBeanServerDelegate.DELEGATE_NAME),listener,null,"foo//bar");
-            server.createMBean(MLet.class.getName(),
-                    name("foo//joe//domain:type=MLet"));
-            checkQueue(queue,"foo//joe",
-                    MBeanServerNotification.REGISTRATION_NOTIFICATION);
-            server.createMBean(MLet.class.getName(),
-                    name("foo//bar//domain:type=MLet"));
-            checkQueue(queue,"foo//bar",
-                    MBeanServerNotification.REGISTRATION_NOTIFICATION);
-            server.unregisterMBean(
-                    name("foo//joe//domain:type=MLet"));
-            checkQueue(queue,"foo//joe",
-                    MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
-            server.unregisterMBean(
-                    name("foo//bar//domain:type=MLet"));
-            checkQueue(queue,"foo//bar",
-                    MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
-        } catch (RuntimeException x) {
-            System.err.println("FAILED: "+x);
-            throw x;
-        } catch(Exception x) {
-            System.err.println("FAILED: "+x);
-            throw new RuntimeException("Unexpected exception: "+x,x);
-        }
-    }
-
-
-    private static void checkQueue(
-            BlockingQueue<ContextObject<String,MBeanServerNotification>> q,
-                              String path, String type) {
-        try {
-          final ContextObject<String,MBeanServerNotification> ctxt =
-                    q.poll(500,TimeUnit.MILLISECONDS);
-          if (ctxt == null)
-            throw new RuntimeException("Timeout expired: expected notif from "+
-                    path +", type="+type);
-          if (!ctxt.name.equals(path))
-            throw new RuntimeException("expected notif from "+
-                    path +", got "+ctxt.name);
-          if (!ctxt.object.getType().equals(type))
-            throw new RuntimeException(ctxt.name+": expected type="+
-                    type +", got "+ctxt.object.getType());
-          if (!ctxt.object.getType().equals(type))
-            throw new RuntimeException(ctxt.name+": expected type="+
-                    type +", got "+ctxt.object.getType());
-          if (!ctxt.object.getMBeanName().equals(name("domain:type=MLet")))
-            throw new RuntimeException(ctxt.name+": expected MBean=domain:type=MLet"+
-                    ", got "+ctxt.object.getMBeanName());
-        } catch(InterruptedException x) {
-            throw new RuntimeException("unexpected interruption: "+x,x);
-        }
-    }
-
-    public static void main(String[] args) {
-        simpleTest(args);
-        simpleTest2();
-    }
-
-}
--- a/test/javax/management/namespace/NullDomainObjectNameTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,307 +0,0 @@
-/*
- * 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 NullDomainObjectNameTest.java
- * @summary Test that null domains are correctly handled in namespaces.
- * @author Daniel Fuchs
- * @run clean NullDomainObjectNameTest Wombat WombatMBean
- * @compile -XDignore.symbol.file=true  NullDomainObjectNameTest.java
- * @run build NullDomainObjectNameTest Wombat WombatMBean
- * @run main NullDomainObjectNameTest
- */
-
-import com.sun.jmx.namespace.RoutingServerProxy;
-import java.lang.management.ManagementFactory;
-import java.util.Arrays;
-import java.util.logging.Logger;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXRemoteNamespace;
-import javax.management.namespace.JMXNamespace;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * Class NullDomainObjectNameTest
- * @author Sun Microsystems, 2005 - All rights reserved.
- */
-public class NullDomainObjectNameTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(NullDomainObjectNameTest.class.getName());
-
-    /** Creates a new instance of NullDomainObjectNameTest */
-    public NullDomainObjectNameTest() {
-    }
-
-    public static class MyWombat
-            extends Wombat {
-        public MyWombat() throws NotCompliantMBeanException {
-            super();
-        }
-        @Override
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-        throws Exception {
-
-            if (name == null)
-                name = new ObjectName(":type=Wombat");
-
-            return super.preRegister(server, name);
-        }
-
-    }
-
-    static String failure=null;
-
-    public static void testRegister() throws Exception {
-        final MBeanServer top = ManagementFactory.getPlatformMBeanServer();
-        final MBeanServer sub = MBeanServerFactory.createMBeanServer();
-        final JMXServiceURL url = new JMXServiceURL("rmi",null,0);
-        final JMXConnectorServer srv =
-                JMXConnectorServerFactory.newJMXConnectorServer(url,null,sub);
-        srv.start();
-
-        try {
-
-            // Create a namespace rmi// that points to 'sub' and flows through
-            // a JMXRemoteNamespace connected to 'srv'
-            // The namespace rmi// will accept createMBean, but not registerMBean.
-            //
-            final JMXRemoteNamespace rmiHandler = JMXRemoteNamespace.
-                    newJMXRemoteNamespace(srv.getAddress(),
-                    null);
-            top.registerMBean(rmiHandler,JMXNamespaces.getNamespaceObjectName("rmi"));
-            top.invoke(JMXNamespaces.getNamespaceObjectName("rmi"),
-                    "connect", null, null);
-
-            // Create a namespace direct// that points to 'sub' and flows
-            // through a direct reference to 'sub'.
-            // The namespace direct// will accept createMBean, and registerMBean.
-            //
-            final JMXNamespace directHandler = new JMXNamespace(sub);
-            top.registerMBean(directHandler,
-                    JMXNamespaces.getNamespaceObjectName("direct"));
-
-            // Now cd to each of the created namespace.
-            //
-            MBeanServer cdrmi = JMXNamespaces.narrowToNamespace(top,"rmi");
-            MBeanServer cddirect = JMXNamespaces.narrowToNamespace(top,"direct");
-            boolean ok = false;
-
-            // Check that calling createMBean with a null domain works
-            // for namespace rmi//
-            //
-            try {
-                final ObjectInstance moi1 =
-                        cdrmi.createMBean(MyWombat.class.getName(),
-                        new ObjectName(":type=Wombat"));
-                System.out.println(moi1.getObjectName().toString()+
-                        ": created through rmi//");
-                assertEquals(moi1.getObjectName().getDomain(),
-                        cddirect.getDefaultDomain());
-                cddirect.unregisterMBean(moi1.getObjectName());
-            } catch (MBeanRegistrationException x) {
-                System.out.println("Received unexpected exception: " + x);
-                failed("Received unexpected exception: " + x);
-            }
-
-            // Check that calling refgisterMBean with a null domain works
-            // for namespace direct//
-            //
-            try {
-                final ObjectInstance moi2 =
-                        cddirect.registerMBean(new MyWombat(),
-                        new ObjectName(":type=Wombat"));
-                System.out.println(moi2.getObjectName().toString()+
-                        ": created through direct//");
-                assertEquals(moi2.getObjectName().getDomain(),
-                        cdrmi.getDefaultDomain());
-                cdrmi.unregisterMBean(moi2.getObjectName());
-            } catch (MBeanRegistrationException x) {
-                System.out.println("Received unexpected exception: " + x);
-                failed("Received unexpected exception: " + x);
-            }
-
-            // Now artificially pretend that 'sub' is contained in a faked//
-            // namespace.
-            //
-            RoutingServerProxy proxy =
-                    new RoutingServerProxy(sub, "", "faked", true);
-
-            // These should fail because the ObjectName doesn't start
-            // with "faked//"
-            try {
-                final ObjectInstance moi3 =
-                    proxy.registerMBean(new MyWombat(),
-                    new ObjectName(":type=Wombat"));
-                System.out.println(moi3.getObjectName().toString()+
-                    ": created through faked//");
-                failed("expected MBeanRegistrationException");
-            } catch (MBeanRegistrationException x) {
-                System.out.println("Received expected exception: " + x);
-                if (!(x.getCause() instanceof IllegalArgumentException)) {
-                    System.err.println("Bad wrapped exception: "+ x.getCause());
-                    failed("expected IllegalArgumentException");
-                }
-            }
-
-            // null should work with "faked//"
-            final ObjectInstance moi3 =
-                    proxy.registerMBean(new MyWombat(),null);
-            assertEquals(moi3.getObjectName().getDomain(),
-                         "faked//"+sub.getDefaultDomain());
-
-            System.out.println(moi3.getObjectName().toString() +
-                    ": created through faked//");
-
-            // Now check that null is correctly handled (accepted or rejected)
-            // in queries for each of the above configs.
-            //
-            ObjectName wombat = moi3.getObjectName().withDomain(
-                    moi3.getObjectName().getDomain().substring("faked//".length()));
-            ObjectInstance moi = new ObjectInstance(wombat,moi3.getClassName());
-
-            System.out.println("Checking queryNames(" +
-                    "new ObjectName(\":*\"),null) with rmi//");
-            assertEquals(cdrmi.queryNames(
-                    new ObjectName(":*"),null).contains(wombat),true);
-            System.out.println("Checking queryNames(" +
-                    "new ObjectName(\":*\"),null) with direct//");
-            assertEquals(cddirect.queryNames(
-                    new ObjectName(":*"),null).contains(wombat),true);
-            System.out.println("Checking queryMBeans(" +
-                    "new ObjectName(\":*\"),null) with rmi//");
-            assertEquals(cdrmi.queryMBeans(
-                    new ObjectName(":*"),null).contains(moi),true);
-            System.out.println("Checking queryMBeans(" +
-                    "new ObjectName(\":*\"),null) with direct//");
-            assertEquals(cddirect.queryMBeans(
-                    new ObjectName(":*"),null).contains(moi),true);
-
-            // These should fail because the ObjectName doesn't start
-            // with "faked//"
-            try {
-                System.out.println("Checking queryNames(" +
-                    "new ObjectName(\":*\"),null) with faked//");
-                assertEquals(proxy.queryNames(
-                        new ObjectName(":*"),null).
-                        contains(moi3.getObjectName()),true);
-                failed("queryNames(new ObjectName(\":*\"),null) " +
-                        "should have failed for faked//");
-            } catch (RuntimeOperationsException x) {
-                if (x.getCause() instanceof IllegalArgumentException)
-                    System.out.println(
-                            "Received expected exception for faked//: "+x);
-                else {
-                    System.err.println(
-                            "Expected exception has unexpected cause " +
-                            "for faked//: "+x.getCause());
-                    x.printStackTrace();
-                    failed("queryNames(new ObjectName(\":*\"),null)" +
-                            " failed with unexpected cause for faked//");
-                }
-            }
-            // These should fail because the ObjectName doesn't start
-            // with "faked//"
-            try {
-                System.out.println("Checking queryMBeans(" +
-                    "new ObjectName(\":*\"),null) with faked//");
-                assertEquals(proxy.queryMBeans(
-                        new ObjectName(":*"),null).contains(moi3),true);
-                failed("queryMBeans(new ObjectName(\":*\"),null)" +
-                    " should have failed for faked//");
-            } catch (RuntimeOperationsException x) {
-                if (x.getCause() instanceof IllegalArgumentException)
-                    System.out.println(
-                            "Received expected exception for faked//: "+x);
-                else {
-                    System.err.println(
-                            "Expected exception has unexpected cause " +
-                            "for faked//: "+x.getCause());
-                    x.printStackTrace();
-                    failed("queryMBeans(new ObjectName(\":*\"),null) " +
-                            "failed with unexpected cause for faked//");
-                }
-            }
-
-            System.out.println("Checking queryNames(faked//*:*,null)");
-            assertEquals(proxy.queryNames(new ObjectName("faked//*:*"),null).
-                    contains(moi3.getObjectName()),true);
-
-            System.out.println("Checking queryMBeans(faked//*:*,null)");
-            assertEquals(proxy.queryMBeans(new ObjectName("faked//*:*"),null).
-                    contains(moi3),true);
-
-            proxy.unregisterMBean(moi3.getObjectName());
-
-            // ADD NEW TESTS HERE ^^^
-
-        } finally {
-            srv.stop();
-        }
-
-        if (failure != null)
-            throw new Exception(failure);
-
-
-    }
-    private static void assertEquals(Object x, Object y) {
-        if (!equal(x, y))
-            failed("expected " + string(x) + "; got " + string(y));
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        if (x.getClass().isArray())
-            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
-        return x.equals(y);
-    }
-
-    private static String string(Object x) {
-        String s = Arrays.deepToString(new Object[] {x});
-        return s.substring(1, s.length() - 1);
-    }
-
-
-    private static void failed(String why) {
-        failure = why;
-        new Throwable("FAILED: " + why).printStackTrace(System.out);
-    }
-
-    public static void main(String[] args) throws Exception {
-        testRegister();
-    }
-}
--- a/test/javax/management/namespace/NullObjectNameTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,273 +0,0 @@
-/*
- * 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 NullObjectNameTest.java
- * @summary Test that null ObjectName are correctly handled in namespaces.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean NullObjectNameTest Wombat WombatMBean
- * @compile -XDignore.symbol.file=true  NullObjectNameTest.java
- * @run build NullObjectNameTest Wombat WombatMBean
- * @run main NullObjectNameTest
- */
-
-import com.sun.jmx.namespace.RoutingServerProxy;
-import java.lang.management.ManagementFactory;
-import java.util.Arrays;
-import java.util.logging.Logger;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.JMXRemoteNamespace;
-import javax.management.namespace.JMXNamespace;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-/**
- * Class NullObjectNameTest
- * @author Sun Microsystems, 2005 - All rights reserved.
- */
-public class NullObjectNameTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(NullObjectNameTest.class.getName());
-
-    /** Creates a new instance of NullObjectNameTest */
-    public NullObjectNameTest() {
-    }
-
-    public static class MyWombat
-            extends Wombat {
-        public MyWombat() throws NotCompliantMBeanException {
-            super();
-        }
-        @Override
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-        throws Exception {
-
-            if (name == null)
-                name = new ObjectName(":type=Wombat");
-
-            return super.preRegister(server, name);
-        }
-
-    }
-
-    static String failure=null;
-
-    public static void testRegister() throws Exception {
-        final MBeanServer top = ManagementFactory.getPlatformMBeanServer();
-        final MBeanServer sub = MBeanServerFactory.createMBeanServer();
-        final JMXServiceURL url = new JMXServiceURL("rmi",null,0);
-        final JMXConnectorServer srv =
-                JMXConnectorServerFactory.newJMXConnectorServer(url,null,sub);
-        srv.start();
-
-        try {
-
-            // Create a namespace rmi// that points to 'sub' and flows through
-            // a JMXRemoteNamespace connected to 'srv'
-            // The namespace rmi// will accept createMBean, but not registerMBean.
-            //
-            final JMXRemoteNamespace rmiHandler = JMXRemoteNamespace.
-                    newJMXRemoteNamespace(srv.getAddress(),null);
-            top.registerMBean(rmiHandler,JMXNamespaces.getNamespaceObjectName("rmi"));
-            top.invoke(JMXNamespaces.getNamespaceObjectName("rmi"),
-                    "connect", null, null);
-
-            // Create a namespace direct// that points to 'sub' and flows
-            // through a direct reference to 'sub'.
-            // The namespace direct// will accept createMBean, and registerMBean.
-            //
-            final JMXNamespace directHandler = new JMXNamespace(sub);
-            top.registerMBean(directHandler,
-                    JMXNamespaces.getNamespaceObjectName("direct"));
-
-            // Now cd to each of the created namespace.
-            //
-            MBeanServer cdrmi = JMXNamespaces.narrowToNamespace(top,"rmi");
-            MBeanServer cddirect = JMXNamespaces.narrowToNamespace(top,"direct");
-            boolean ok = false;
-
-            // Check that calling createMBean with a null ObjectName fails
-            // gracefully for namespace rmi// (we can't add rmi// to a null
-            // ObjectName.
-            //
-            // TODO: do this test for all createMBean flavors!
-            try {
-                final ObjectInstance moi1 =
-                        cdrmi.createMBean(MyWombat.class.getName(),null);
-                System.out.println(moi1.getObjectName().toString()+
-                        ": created through rmi//");
-                cddirect.unregisterMBean(moi1.getObjectName());
-                failed("expected MBeanRegistrationException");
-            } catch (MBeanRegistrationException x) {
-                System.out.println("Received expected exception: " + x);
-                if (!(x.getCause() instanceof IllegalArgumentException)) {
-                    System.err.println("Bad wrapped exception: "+ x.getCause());
-                    failed("expected IllegalArgumentException");
-                }
-            }
-
-            // Check that calling refgisterMBean with a null ObjectName fails
-            // gracefully for namespace direct// (we can't add direct// to a null
-            // ObjectName.
-            //
-            try {
-                final ObjectInstance moi2 =
-                        cddirect.registerMBean(new MyWombat(), (ObjectName)null);
-                System.out.println(moi2.getObjectName().toString()+
-                        ": created through direct//");
-                cdrmi.unregisterMBean(moi2.getObjectName());
-                failed("expected MBeanRegistrationException");
-            } catch (MBeanRegistrationException x) {
-                System.out.println("Received expected exception: " + x);
-                if (!(x.getCause() instanceof IllegalArgumentException)) {
-                    System.err.println("Bad wrapped exception: "+ x.getCause());
-                    failed("expected IllegalArgumentException");
-                }
-            }
-
-            // Now artificially pretend that 'sub' is contained in a faked//
-            // namespace.
-            // We should be able to use 'null' in registerMBean/createMBean in
-            // this case.
-            //
-            RoutingServerProxy proxy =
-                    new RoutingServerProxy(sub, "", "faked", true);
-            final ObjectInstance moi3 =
-                    proxy.registerMBean(new MyWombat(),null);
-            System.out.println(moi3.getObjectName().toString()+
-                    ": created through faked//");
-
-            // Now check that null is correctly handled (accepted or rejected)
-            // in queries for each of the above configs.
-            //
-            ObjectName wombat = moi3.getObjectName().withDomain(
-                    moi3.getObjectName().getDomain().substring("faked//".length()));
-            ObjectInstance moi = new ObjectInstance(wombat,moi3.getClassName());
-
-            System.out.println("Checking queryNames(null,null) with rmi//");
-            assertEquals(cdrmi.queryNames(null,null).contains(wombat),true);
-            System.out.println("Checking queryNames(null,null) with direct//");
-            assertEquals(cddirect.queryNames(null,null).contains(wombat),true);
-            System.out.println("Checking queryMBeans(null,null) with rmi//");
-            assertEquals(cdrmi.queryMBeans(null,null).contains(moi),true);
-            System.out.println("Checking queryMBeans(null,null) with direct//");
-            assertEquals(cddirect.queryMBeans(null,null).contains(moi),true);
-
-            try {
-                System.out.println("Checking queryNames(null,null) with faked//");
-                assertEquals(proxy.queryNames(null,null).
-                        contains(moi3.getObjectName()),true);
-                failed("queryNames(null,null) should have failed for faked//");
-            } catch (RuntimeOperationsException x) {
-                if (x.getCause() instanceof IllegalArgumentException)
-                    System.out.println(
-                            "Received expected exception for faked//: "+x);
-                else {
-                    System.err.println(
-                            "Expected exception has unexpected cause " +
-                            "for faked//: "+x.getCause());
-                    x.printStackTrace();
-                    failed("queryNames(null,null) failed with unexpected " +
-                            "cause for faked//");
-                }
-            }
-            try {
-                System.out.println("Checking queryMBeans(null,null) with faked//");
-                assertEquals(proxy.queryMBeans(null,null).contains(moi3),true);
-                failed("queryMBeans(null,null) should have failed for faked//");
-            } catch (RuntimeOperationsException x) {
-                if (x.getCause() instanceof IllegalArgumentException)
-                    System.out.println(
-                            "Received expected exception for faked//: "+x);
-                else {
-                    System.err.println(
-                            "Expected exception has unexpected cause " +
-                            "for faked//: "+x.getCause());
-                    x.printStackTrace();
-                    failed("queryMBeans(null,null) failed with unexpected " +
-                            "cause for faked//");
-                }
-            }
-            System.out.println("Checking queryNames(faked//*:*,null)");
-            assertEquals(proxy.queryNames(new ObjectName("faked//*:*"),null).
-                    contains(moi3.getObjectName()),true);
-
-            System.out.println("Checking queryMBeans(faked//*:*,null)");
-            assertEquals(proxy.queryMBeans(new ObjectName("faked//*:*"),null).
-                    contains(moi3),true);
-
-            proxy.unregisterMBean(moi3.getObjectName());
-
-            // ADD NEW TESTS HERE ^^^
-
-        } finally {
-            srv.stop();
-        }
-
-        if (failure != null)
-            throw new Exception(failure);
-
-
-    }
-    private static void assertEquals(Object x, Object y) {
-        if (!equal(x, y))
-            failed("expected " + string(x) + "; got " + string(y));
-    }
-
-    private static boolean equal(Object x, Object y) {
-        if (x == y)
-            return true;
-        if (x == null || y == null)
-            return false;
-        if (x.getClass().isArray())
-            return Arrays.deepEquals(new Object[] {x}, new Object[] {y});
-        return x.equals(y);
-    }
-
-    private static String string(Object x) {
-        String s = Arrays.deepToString(new Object[] {x});
-        return s.substring(1, s.length() - 1);
-    }
-
-
-    private static void failed(String why) {
-        failure = why;
-        new Throwable("FAILED: " + why).printStackTrace(System.out);
-    }
-
-    public static void main(String[] args) throws Exception {
-        testRegister();
-    }
-}
--- a/test/javax/management/namespace/QueryNamesTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,473 +0,0 @@
-/*
- * 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 QueryNamesTest.java 1.4
- * @summary Test how queryNames works with Namespaces.
- * @author Daniel Fuchs
- * @bug 5072476 6768935
- * @run clean QueryNamesTest Wombat WombatMBean
- * @run build QueryNamesTest Wombat WombatMBean
- * @run main QueryNamesTest
- */
-
-
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.Set;
-import java.util.logging.Logger;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-
-/**
- * Class QueryNamesTest
- * @author Sun Microsystems, 2005 - All rights reserved.
- */
-public class QueryNamesTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(QueryNamesTest.class.getName());
-
-    public static class LocalNamespace
-            extends JMXNamespace {
-
-        private static MBeanServer check(MBeanServer server) {
-            if (server == null)
-                throw new IllegalArgumentException("MBeanServer can't be null");
-            return server;
-        }
-
-        public LocalNamespace() {
-            this(MBeanServerFactory.createMBeanServer());
-        }
-
-        public LocalNamespace(MBeanServer server) {
-            super(check(server));
-        }
-
-
-        public static String add(MBeanServerConnection server,
-                String nspath)
-                throws IOException, JMException {
-            server.createMBean(LocalNamespace.class.getName(),
-                    JMXNamespaces.getNamespaceObjectName(nspath));
-            return nspath;
-        }
-    }
-
-    /** Creates a new instance of QueryNamesTest */
-    public QueryNamesTest() {
-    }
-
-    private static String[] namespaces = {
-        "greg", "greg//chichille", "greg//chichille//petard",
-        "greg//alambic", "greg//alambic//canette",
-        "greg//chichille/virgule", "greg//chichille/funeste",
-        "greg//chichille/virgule//bidouble",
-        "greg//chichille/virgule//bi/double",
-        "fran", "fran//gast", "fran//gast//gaf",
-        "fran//longtar", "fran//longtar//parcmetre"
-    };
-
-    private static void createNamespaces(MBeanServer server) throws Exception {
-        final LinkedList<String> all = new LinkedList<String>();
-        try {
-            for (String ns : namespaces)
-                all.addFirst(LocalNamespace.add(server,ns));
-        } catch (Exception e) {
-            removeNamespaces(server,all.toArray(new String[all.size()]));
-            throw e;
-        }
-    }
-
-    // Dummy test that checks that all JMXNamespaces are registered,
-    // but are not returned by queryNames("*:*");
-    //
-    private static void checkRegistration(MBeanServer server)
-        throws Exception {
-        final Set<ObjectName> handlerNames = new HashSet<ObjectName>(namespaces.length);
-        for (String ns : namespaces)
-            handlerNames.add(JMXNamespaces.getNamespaceObjectName(ns));
-        for (ObjectName nh : handlerNames) // check handler registration
-            if (!server.isRegistered(nh))
-                throw new InstanceNotFoundException("handler "+nh+
-                        " is not registered");
-
-        // global: queryNames("*:*") from top level
-        final Set<ObjectName> all1 = server.queryNames(null,null);
-        final Set<ObjectName> all2 = server.queryNames(ObjectName.WILDCARD,null);
-        if (!all1.equals(all2))
-            throw new Exception("queryNames(*:*) != queryNames(null)");
-        final Set<ObjectName> common = new HashSet<ObjectName>(all1);
-        common.retainAll(handlerNames);
-
-        final Set<ObjectName> ref = new HashSet<ObjectName>();
-        for (String ns : namespaces) {
-            if (!ns.contains(JMXNamespaces.NAMESPACE_SEPARATOR))
-                ref.add(JMXNamespaces.getNamespaceObjectName(ns));
-        }
-        if (!common.equals(ref)) {
-            throw new Exception("some handler names were not returned by " +
-                    "wildcard query - only returned: "+common+
-                    ", expected: "+ref);
-        }
-
-        // for each namespace: queryNames("<namespace>//*:*");
-        for (String ns : namespaces) {
-            final ObjectName pattern = new ObjectName(ns+
-                    JMXNamespaces.NAMESPACE_SEPARATOR+"*:*");
-            final Set<ObjectName> all4 =
-                    server.queryNames(pattern,null);
-            final Set<ObjectName> common4 = new HashSet<ObjectName>(all4);
-            common4.retainAll(handlerNames);
-
-            final Set<ObjectName> ref4 = new HashSet<ObjectName>();
-            for (String ns2 : namespaces) {
-                if (! ns2.startsWith(ns+JMXNamespaces.NAMESPACE_SEPARATOR))
-                    continue;
-                if (!ns2.substring(ns.length()+
-                        JMXNamespaces.NAMESPACE_SEPARATOR.length()).
-                        contains(JMXNamespaces.NAMESPACE_SEPARATOR))
-                    ref4.add(JMXNamespaces.getNamespaceObjectName(ns2));
-            }
-            if (!common4.equals(ref4)) {
-                throw new Exception("some handler names were not returned by " +
-                    "wildcard query on "+pattern+" - only returned: "+common4+
-                    ", expected: "+ref4);
-            }
-        }
-    }
-
-    // Make a Map<parent, direct children>
-    private static Map<String,Set<String>> makeNsTree(String[] nslist) {
-        final Map<String,Set<String>> nsTree =
-                new LinkedHashMap<String,Set<String>>(nslist.length);
-        for (String ns : nslist) {
-            if (nsTree.get(ns) == null)
-                nsTree.put(ns,new LinkedHashSet<String>());
-            final String[] elts = ns.split(JMXNamespaces.NAMESPACE_SEPARATOR);
-            int last = ns.lastIndexOf(JMXNamespaces.NAMESPACE_SEPARATOR);
-            if (last<0) continue;
-            while (last > 0 && ns.charAt(last-1) == '/') last--;
-            final String parent = ns.substring(0,last);
-            if (nsTree.get(parent) == null)
-                nsTree.put(parent,new LinkedHashSet<String>());
-            nsTree.get(parent).add(ns);
-        }
-        return nsTree;
-    }
-
-    private static class Rigolo {
-        final static String[] ones = { "a", "e", "i", "o", "u", "y", "ai", "oo",
-        "ae", "ey", "ay", "oy", "au", "ou", "eu", "oi", "ei", "ea"};
-        final static String[] twos = { "b", "bz", "c", "cz", "ch",
-        "ct", "ck", "cs", "d", "ds", "f",  "g", "gh", "h", "j", "k", "l", "m",
-        "n", "p", "ps", "q", "r", "s", "sh", "t", "v", "w", "x",
-        "z"};
-        final static String[] threes = {"rr","tt","pp","ss","dd","ff","ll", "mm", "nn",
-        "zz", "cc", "bb"};
-        final static String[] fours = {"x", "s", "ght", "cks", "rt", "rts", "ghts", "bs",
-          "ts", "gg" };
-        final static String[] fives = { "br", "bl", "cr", "cn", "cth", "dr",
-        "fr", "fl", "cl", "chr",  "gr", "gl", "kr", "kh", "pr", "pl", "ph",
-        "rh", "sr", "tr", "vr"};
-
-        private Random rg = new Random();
-
-        private String next(String[] table) {
-            return table[rg.nextInt(table.length)];
-        }
-
-        public String nextName(int max) {
-            final Random rg = new Random();
-            final int nl = 3 + rg.nextInt(max);
-            boolean begin = rg.nextBoolean();
-            StringBuilder sb = new StringBuilder();
-            for (int j = 0; j < nl ; j++) {
-                if (begin) {
-                    sb.append(next(ones));
-                } else if (j > 0 && j < nl-1 && rg.nextInt(4)==0) {
-                    sb.append(next(threes));
-                } else if (j < nl-1 && rg.nextInt(3)==0) {
-                    sb.append(next(fives));
-                } else {
-                    sb.append(next(twos));
-                }
-                begin = !begin;
-            }
-            if (!begin && rg.nextInt(2)==0)
-                sb.append(next(fours));
-            return sb.toString();
-        }
-
-        private ObjectName getWombatName(String ns, String domain, String name)
-            throws MalformedObjectNameException {
-            String d = domain;
-            if (ns != null && !ns.equals(""))
-                d = ns + JMXNamespaces.NAMESPACE_SEPARATOR + domain;
-            return new ObjectName(d+":type=Wombat,name="+name);
-        }
-
-        public Set<ObjectName> nextWombats(String ns)
-            throws MalformedObjectNameException  {
-            final int dcount = 1 + rg.nextInt(5);
-            final Set<ObjectName> wombats = new HashSet<ObjectName>();
-            for (int i = 0; i < dcount ; i++) {
-                final String d = nextName(7);
-                final int ncount = 5 + rg.nextInt(20);
-                for (int j = 0 ; j<ncount; j++) {
-                    final String n = nextName(5);
-                    wombats.add(getWombatName(ns,d,n));
-                }
-            }
-            return wombats;
-        }
-    }
-
-    public static void checkNsQuery(MBeanServer server)
-        throws Exception {
-        final Map<String,Set<String>> nsTree = makeNsTree(namespaces);
-        final Random rg = new Random();
-        final Rigolo rigolo = new Rigolo();
-        for (String ns : namespaces) {
-            final ObjectName name = JMXNamespaces.getNamespaceObjectName(ns);
-            final String[] doms =
-                    (String[])server.getAttribute(name,"Domains");
-            final Set<String> subs = new HashSet<String>();
-            for (String d : doms) {
-                if (d.endsWith(JMXNamespaces.NAMESPACE_SEPARATOR)) {
-                    subs.add(ns+JMXNamespaces.NAMESPACE_SEPARATOR+d.substring(0,
-                            d.length()-JMXNamespaces.NAMESPACE_SEPARATOR.length()));
-                }
-            }
-
-            final Set<String> expectNs = new HashSet<String>(nsTree.get(ns));
-
-            if (! subs.containsAll(expectNs))
-                throw new Exception("getDomains didn't return all namespaces: "+
-                        "returned="+subs+", expected="+expectNs);
-            if (! expectNs.containsAll(subs))
-                throw new Exception("getDomains returned additional namespaces: "+
-                        "returned="+subs+", expected="+expectNs);
-
-            final Set<ObjectName> nsNames = server.queryNames(
-                    new ObjectName(ns+
-                    JMXNamespaces.NAMESPACE_SEPARATOR+"*"+
-                    JMXNamespaces.NAMESPACE_SEPARATOR+":*"),null);
-
-            final Set<ObjectName> expect =
-                    new HashSet<ObjectName>(expectNs.size());
-            for (String sub : expectNs) {
-                expect.add(JMXNamespaces.getNamespaceObjectName(sub));
-            }
-
-            if (! nsNames.containsAll(expect))
-                throw new Exception("queryNames didn't return all namespaces: "+
-                        "returned="+nsNames+", expected="+expect);
-            if (! expect.containsAll(nsNames))
-                throw new Exception("getDomains returned additional namespaces: "+
-                        "returned="+nsNames+", expected="+expect);
-
-        }
-    }
-
-    private static void addWombats(MBeanServer server, Set<ObjectName> names)
-        throws Exception {
-        for (ObjectName on : names) {
-            if (! server.isRegistered(on)) {
-                server.createMBean(Wombat.class.getName(),on);
-                System.out.println("A new wombat is born: "+on);
-            }
-        }
-    }
-
-    private static void addWombats(MBeanServer server,
-             Map<String,Set<ObjectName>> wombats)
-        throws Exception {
-        for (String ns : wombats.keySet()) {
-            addWombats(server,wombats.get(ns));
-        }
-    }
-
-    private static Map<String,Set<ObjectName>> nameWombats()
-        throws Exception {
-        final Rigolo rigolo = new Rigolo();
-        final Map<String,Set<ObjectName>> wombats =
-                new HashMap<String,Set<ObjectName>>(namespaces.length);
-
-        for (String ns : namespaces) {
-            wombats.put(ns,rigolo.nextWombats(ns));
-        }
-        wombats.put("",rigolo.nextWombats(""));
-        return wombats;
-    }
-
-    private static boolean removeWombats(MBeanServer server,
-            Map<String,Set<ObjectName>> wombats) {
-        boolean res = true;
-        for (String ns : wombats.keySet()) {
-            res = res && removeWombats(server,wombats.get(ns));
-        }
-        return res;
-    }
-
-    private static boolean removeWombats(MBeanServer server,
-            Set<ObjectName> wombats) {
-        boolean res = true;
-        for (ObjectName on : wombats) {
-            try {
-                if (server.isRegistered(on))
-                    server.unregisterMBean(on);
-            } catch (Exception x) {
-                res = false;
-                System.out.println("Failed to remove "+on+": "+x);
-            }
-        }
-        return res;
-    }
-
-    private static void checkNsPattern(MBeanServer server) throws Exception {
-        final List<String> list = new ArrayList<String>();
-        for (String s : namespaces) {
-            final String[] cmpnt = s.split("//");
-            for (int i=0;i<cmpnt.length;i++) {
-                final String[] clone = cmpnt.clone();
-                if (clone[i].length() < 3) {
-                    clone[i] = "*";
-                } else {
-                    clone[i] = "?"+cmpnt[i].substring(1, cmpnt[i].length()-2)+"*";
-                }
-                final StringBuilder sb = new StringBuilder();
-                for (int j=0;j<cmpnt.length;j++) {
-                    sb.append(clone[j]).append("//");
-                }
-                list.add(sb.toString()+"*:*");
-            }
-        }
-        for (String s : list) {
-            final Set<ObjectName> res = new HashSet<ObjectName>();
-
-            try {
-                res.addAll(server.queryNames(ObjectName.valueOf(s),null));
-            } catch (RuntimeOperationsException x) {
-                if (x.getCause() instanceof IllegalArgumentException) {
-                    System.out.println("queryNames("+s+"): OK - received "+x.getCause());
-                    continue;
-                }
-                System.err.println("queryNames("+s+"): Bad cause: "+x.getCause());
-                throw x;
-            } catch (Exception x) {
-                System.err.println("queryNames("+s+"): Bad exception: "+x);
-                throw x;
-            }
-            System.err.println("queryNames("+s+"): Bad result: "+res);
-            System.err.println("queryNames("+s+"): Excpected exception not thrown.");
-            throw new Exception("queryNames("+s+"): Excpected exception not thrown.");
-        }
-        for (String s : list) {
-            final Set<ObjectInstance> res = new HashSet<ObjectInstance>();
-
-            try {
-                res.addAll(server.queryMBeans(ObjectName.valueOf(s),null));
-            } catch (RuntimeOperationsException x) {
-                if (x.getCause() instanceof IllegalArgumentException) {
-                    System.out.println("queryMBeans("+s+"): OK - received "+x.getCause());
-                    continue;
-                }
-                System.err.println("queryMBeans("+s+"): Bad cause: "+x.getCause());
-                throw x;
-            } catch (Exception x) {
-                System.err.println("queryMBeans("+s+"): Bad exception: "+x);
-                throw x;
-            }
-            System.err.println("queryMBeans("+s+"): Bad result: "+res);
-            System.err.println("queryMBeans("+s+"): Excpected exception not thrown.");
-            throw new Exception("queryMBeans("+s+"): Excpected exception not thrown.");
-        }
-    }
-
-    public static void main(String[] args)
-        throws Exception {
-        final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-        Map<String,Set<ObjectName>>  wombats = nameWombats();
-        createNamespaces(server);
-        try {
-            addWombats(server,wombats);
-            System.out.println("MBeans: " +server.getMBeanCount());
-            System.out.println("Visible: " +server.queryNames(null,null).size());
-            System.out.println("Domains: " +Arrays.asList(server.getDomains()));
-            checkRegistration(server);
-            checkNsQuery(server);
-            checkNsPattern(server);
-        } finally {
-            boolean res = true;
-            res = res && removeWombats(server, wombats);
-            if (!res)
-                throw new RuntimeException("failed to cleanup some namespaces");
-        }
-
-    }
-
-    private static boolean removeNamespaces(MBeanServer server) {
-        final List<String> l = Arrays.asList(namespaces);
-        Collections.reverse(l);
-        return removeNamespaces(server, l.toArray(new String[namespaces.length]));
-    }
-
-    private static boolean removeNamespaces(MBeanServer server, String[] t) {
-        boolean success = true;
-        for (String ns : t) {
-            try {
-                server.unregisterMBean(JMXNamespaces.getNamespaceObjectName(ns));
-            } catch (Exception x) {
-                System.out.println("failed to remove namespace: "+ ns);
-                success = false;
-            }
-        }
-        return success;
-    }
-
-}
--- a/test/javax/management/namespace/RemoveNotificationListenerTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,377 +0,0 @@
-/*
- * 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 RemoveNotificationListenerTest.java 1.8
- * @summary General RemoveNotificationListenerTest test.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean RemoveNotificationListenerTest JMXRemoteTargetNamespace
- * @compile -XDignore.symbol.file=true  JMXRemoteTargetNamespace.java
- * @run build RemoveNotificationListenerTest JMXRemoteTargetNamespace
- * @run main/othervm RemoveNotificationListenerTest
- */
-
-import com.sun.jmx.remote.util.EventClientConnection;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Logger;
-import javax.management.JMException;
-import javax.management.JMX;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.Notification;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.remote.JMXAuthenticator;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXConnectorServerMBean;
-import javax.management.remote.JMXPrincipal;
-import javax.management.remote.JMXServiceURL;
-import javax.security.auth.Subject;
-
-/**
- * Class RemoveNotificationListenerTest
- */
-public class RemoveNotificationListenerTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(RemoveNotificationListenerTest.class.getName());
-
-    /** Creates a new instance of RemoveNotificationListenerTest */
-    public RemoveNotificationListenerTest() {
-    }
-
-    public static class SubjectAuthenticator implements JMXAuthenticator {
-        final Set<Subject> authorized;
-        public SubjectAuthenticator(Subject[] authorized) {
-            this.authorized = new HashSet<Subject>(Arrays.asList(authorized));
-        }
-
-        public Subject authenticate(Object credentials) {
-            if (authorized.contains(credentials))
-                return (Subject)credentials;
-            else
-                throw new SecurityException("Subject not authorized: "+credentials);
-        }
-
-    }
-
-    public static interface LongtarMBean {
-        public void sendNotification(Object userData)
-            throws IOException, JMException;
-    }
-    public static class Longtar extends NotificationBroadcasterSupport
-            implements LongtarMBean {
-        public Longtar() {
-            super(new MBeanNotificationInfo[] {
-                new MBeanNotificationInfo(new String[] {"papillon"},
-                        "pv","M'enfin???")
-            });
-        }
-
-        public void sendNotification(Object userData)
-        throws IOException, JMException {
-            final Notification n =
-                    new Notification("papillon",this,nextseq(),"M'enfin???");
-            n.setUserData(userData);
-            System.out.println("Sending notification: "+userData);
-            sendNotification(n);
-        }
-
-        private static synchronized long nextseq() {return ++seqnb;}
-        private static volatile long seqnb=0;
-    }
-
-    private static final String NS = JMXNamespaces.NAMESPACE_SEPARATOR;
-    private static final String CS = "jmx.rmi:type=JMXConnectorServer";
-    private static final String BD = "longtar:type=Longtar";
-
-    private static void createNamespace(MBeanServerConnection server,
-            String namespace, Subject creator, boolean forwarding)
-            throws Exception {
-        final MBeanServer sub = MBeanServerFactory.createMBeanServer();
-        final JMXServiceURL url = new JMXServiceURL("rmi",null,0);
-        final Map<String,Object> smap = new HashMap<String,Object>();
-        smap.put(JMXConnectorServer.AUTHENTICATOR,
-                new SubjectAuthenticator(new Subject[] {creator}));
-        final JMXConnectorServer rmi =
-                JMXConnectorServerFactory.newJMXConnectorServer(url,smap,null);
-        final ObjectName name = new ObjectName(CS);
-        sub.registerMBean(rmi,name);
-        rmi.start();
-        final Map<String,Object> cmap = new HashMap<String,Object>();
-        cmap.put(JMXConnector.CREDENTIALS,creator);
-        final Map<String,Object> options = new HashMap<String,Object>(cmap);
-        options.put(JMXRemoteTargetNamespace.CREATE_EVENT_CLIENT,"true");
-        JMXRemoteTargetNamespace.createNamespace(server,
-                namespace,
-                rmi.getAddress(),
-                options
-                );
-        server.invoke(JMXNamespaces.getNamespaceObjectName(namespace),
-                "connect", null,null);
-    }
-    private static void closeNamespace(MBeanServerConnection server,
-            String namespace) {
-        try {
-            final ObjectName hname =
-                    JMXNamespaces.getNamespaceObjectName(namespace);
-            if (!server.isRegistered(hname))
-                return;
-            final ObjectName sname =
-                    new ObjectName(namespace+NS+CS);
-            if (!server.isRegistered(sname))
-                return;
-            final JMXConnectorServerMBean cs =
-                    JMX.newMBeanProxy(server,sname,
-                    JMXConnectorServerMBean.class,true);
-            try {
-                cs.stop();
-            } finally {
-                server.unregisterMBean(hname);
-            }
-        } catch (Throwable t) {
-            t.printStackTrace();
-        }
-    }
-
-    private static Subject newSubject(String[] principals) {
-        final Set<Principal> ps = new HashSet<Principal>();
-        for (String p:principals) ps.add(new JMXPrincipal(p));
-        return new Subject(true,ps,Collections.emptySet(),Collections.emptySet());
-    }
-
-
-    public static void testSubject() throws Exception {
-        final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-        final String a = "a";
-        final String b = a + NS + "b";
-
-        final Subject s1 = newSubject(new String[] {"chichille"});
-        final Subject s2 = newSubject(new String[] {"alambic"});
-        final Subject s3 = newSubject(new String[] {"virgule"});
-        final Subject s4 = newSubject(new String[] {"funeste"});
-
-        final JMXServiceURL url = new JMXServiceURL("rmi",null,0);
-        final Map<String,Object> smap = new HashMap<String,Object>();
-        smap.put(JMXConnectorServer.AUTHENTICATOR,
-                new SubjectAuthenticator(new Subject[] {s1}));
-        final JMXConnectorServer rmi =
-                JMXConnectorServerFactory.newJMXConnectorServer(url,smap,null);
-        final ObjectName name = new ObjectName(CS);
-        server.registerMBean(rmi,name);
-        rmi.start();
-
-        try {
-
-            final Map<String,Object> map = new HashMap<String,Object>();
-            map.put(JMXConnector.CREDENTIALS,s1);
-            final JMXConnector c =
-                    JMXConnectorFactory.connect(rmi.getAddress(),map);
-            final MBeanServerConnection mbsorig = c.getMBeanServerConnection();
-
-            final MBeanServerConnection mbs =
-                    EventClientConnection.getEventConnectionFor(mbsorig,null);
-
-            createNamespace(mbs,a,s2,true);
-            createNamespace(mbs,b,s3,true);
-
-            final ObjectName longtar = new ObjectName(b+NS+BD);
-
-            mbs.createMBean(Longtar.class.getName(),longtar);
-            final LongtarMBean proxy =
-                    JMX.newMBeanProxy(mbs,longtar,LongtarMBean.class,true);
-
-
-            final BlockingQueue<Notification> bbq =
-                    new ArrayBlockingQueue<Notification>(10);
-            final NotificationListener listener1 = new NotificationListener() {
-                public void handleNotification(Notification notification,
-                        Object handback) {
-                    System.out.println(notification.getSequenceNumber()+": "+
-                            notification.getMessage());
-                    bbq.add(notification);
-                }
-            };
-            final NotificationListener listener2 = new NotificationListener() {
-                public void handleNotification(Notification notification,
-                        Object handback) {
-                    System.out.println(notification.getSequenceNumber()+": "+
-                            notification.getMessage());
-                    bbq.add(notification);
-                }
-            };
-
-            final NotificationEmitter ubpdalfdla = (NotificationEmitter)proxy;
-            try {
-
-                // Add 1 NL, send 1 notif (1)
-                ubpdalfdla.addNotificationListener(listener1,null,listener1);
-                proxy.sendNotification(new Integer(1));
-                // Thread.sleep(180000);
-
-                // We should have 1 notif with userdata = 1
-                final Notification n1 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n1.getUserData()).intValue() != 1)
-                    throw new Exception("Expected 1, got"+n1.getUserData());
-
-                // remove NL, send 1 notif (2) => we shouldn't receive it
-                ubpdalfdla.removeNotificationListener(listener1,null,listener1);
-                proxy.sendNotification(new Integer(2));
-
-                // add NL, send 1 notif (3)
-                ubpdalfdla.addNotificationListener(listener1,null,listener1);
-                proxy.sendNotification(new Integer(3));
-
-                // we should receive only 1 notif (3)
-                final Notification n3 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n3.getUserData()).intValue() != 3)
-                    throw new Exception("Expected 3, got"+n3.getUserData());
-
-                // remove NL, send 1 notif (4) => we shouldn't receive it.
-                ubpdalfdla.removeNotificationListener(listener1);
-                proxy.sendNotification(new Integer(4));
-
-                // add NL, send 1 notif (5).
-                ubpdalfdla.addNotificationListener(listener1,null,listener1);
-                proxy.sendNotification(new Integer(5));
-
-                // next notif in queue should be (5)
-                final Notification n5 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n5.getUserData()).intValue() != 5)
-                    throw new Exception("Expected 5, got"+n5.getUserData());
-
-                // add 2 NL, send 1 notif (6)
-                ubpdalfdla.addNotificationListener(listener2,null,listener2);
-                ubpdalfdla.addNotificationListener(listener2,null,null);
-                proxy.sendNotification(new Integer(6));
-
-                // We have 3 NL, we should receive (6) 3 times....
-                final Notification n61 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n61.getUserData()).intValue() != 6)
-                    throw new Exception("Expected 6 (#1), got"+n61.getUserData());
-                final Notification n62 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n62.getUserData()).intValue() != 6)
-                    throw new Exception("Expected 6 (#2), got"+n62.getUserData());
-                final Notification n63 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n63.getUserData()).intValue() != 6)
-                    throw new Exception("Expected 6 (#3), got"+n63.getUserData());
-
-                // Remove 1 NL, send 1 notif (7)
-                ubpdalfdla.removeNotificationListener(listener2,null,null);
-                proxy.sendNotification(new Integer(7));
-
-                // next notifs in queue should be (7), twice...
-                final Notification n71 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n71.getUserData()).intValue() != 7)
-                    throw new Exception("Expected 7 (#1), got"+n71.getUserData());
-                final Notification n72 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n72.getUserData()).intValue() != 7)
-                    throw new Exception("Expected 7 (#2), got"+n72.getUserData());
-
-                // Add 1 NL, send 1 notif (8)
-                ubpdalfdla.addNotificationListener(listener2,null,null);
-                proxy.sendNotification(new Integer(8));
-
-                // Next notifs in queue should be (8), 3 times.
-                final Notification n81 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n81.getUserData()).intValue() != 8)
-                    throw new Exception("Expected 8 (#1), got"+n81.getUserData());
-                final Notification n82 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n82.getUserData()).intValue() != 8)
-                    throw new Exception("Expected 8 (#2), got"+n82.getUserData());
-                final Notification n83 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n83.getUserData()).intValue() != 8)
-                    throw new Exception("Expected 8 (#3), got"+n83.getUserData());
-
-                // Remove 2 NL, send 1 notif (9)
-                ubpdalfdla.removeNotificationListener(listener2);
-                proxy.sendNotification(new Integer(9));
-
-                // Next notifs in queue should be (9), 1 time only.
-                final Notification n9 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n9.getUserData()).intValue() != 9)
-                    throw new Exception("Expected 9, got"+n9.getUserData());
-
-                // send 1 notif (10)
-                proxy.sendNotification(new Integer(10));
-
-                // Next notifs in queue should be (10), 1 time only.
-                final Notification n10 = bbq.poll(3,TimeUnit.SECONDS);
-                // may throw NPE => would indicate a bug.
-                if (((Integer)n10.getUserData()).intValue() != 10)
-                    throw new Exception("Expected 10, got"+n10.getUserData());
-
-                ubpdalfdla.removeNotificationListener(listener1);
-                mbs.unregisterMBean(longtar);
-
-            } finally {
-                c.close();
-            }
-        } finally {
-            closeNamespace(server,b);
-            closeNamespace(server,a);
-            rmi.stop();
-        }
-
-    }
-
-    public static void main(String[] args) throws Exception {
-        testSubject();
-    }
-
-}
--- a/test/javax/management/namespace/RoutingServerProxyTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,400 +0,0 @@
-/*
- * 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 RoutingServerProxyTest.java 1.6
- * @summary General RoutingServerProxyTest test.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean RoutingServerProxyTest Wombat WombatMBean
- * @compile -XDignore.symbol.file=true RoutingServerProxyTest.java
- * @run build RoutingServerProxyTest Wombat WombatMBean
- * @run main RoutingServerProxyTest
- */
-
-import com.sun.jmx.namespace.RoutingServerProxy;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Logger;
-
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-import javax.management.JMX;
-import javax.management.MBeanInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationEmitter;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.StandardEmitterMBean;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.MBeanServerSupport;
-
-/**
- * Class RoutingServerProxyTest
- *
- * @author Sun Microsystems, Inc.
- */
-public class RoutingServerProxyTest {
-
-    /**
-     * A logger for this class.
-     **/
-    private static final Logger LOG =
-            Logger.getLogger(RoutingServerProxyTest.class.getName());
-
-    /**
-     * Creates a new instance of RoutingServerProxyTest
-     */
-    public RoutingServerProxyTest() {
-    }
-
-    public static class DynamicWombat extends StandardEmitterMBean {
-        DynamicWombat(Wombat w) throws NotCompliantMBeanException {
-            super(w,WombatMBean.class,w);
-        }
-
-        @Override
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-            throws Exception {
-            final ObjectName myname = ((Wombat)getImplementation()).
-                    preRegister(server,name);
-            return super.preRegister(server,myname);
-        }
-
-        @Override
-        public void postRegister(Boolean registrationDone) {
-            try {
-                ((Wombat)getImplementation()).
-                    postRegister(registrationDone);
-            } finally {
-                super.postRegister(registrationDone);
-            }
-        }
-
-        @Override
-        public void preDeregister() throws Exception {
-                ((Wombat)getImplementation()).
-                    preDeregister();
-                super.preDeregister();
-
-        }
-
-        @Override
-        public void postDeregister() {
-            try {
-                ((Wombat)getImplementation()).
-                    postDeregister();
-            } finally {
-                super.postDeregister();
-            }
-        }
-    }
-
-    public static class VirtualWombatHandler
-            extends JMXNamespace {
-
-        public static class VirtualWombatRepository
-                extends MBeanServerSupport {
-
-            final Map<ObjectName, DynamicMBean> bush;
-
-            VirtualWombatRepository(Map<ObjectName, DynamicMBean> bush) {
-                this.bush = bush;
-            }
-
-            @Override
-            protected Set<ObjectName> getNames() {
-                return bush.keySet();
-            }
-
-            @Override
-            public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                    throws InstanceNotFoundException {
-                final DynamicMBean mb = bush.get(name);
-                if (mb == null) {
-                    throw new InstanceNotFoundException(String.valueOf(name));
-                }
-                return mb;
-            }
-
-            @Override
-            public NotificationEmitter getNotificationEmitterFor(
-                    ObjectName name) throws InstanceNotFoundException {
-                DynamicMBean mbean = getDynamicMBeanFor(name);
-                if (mbean instanceof NotificationEmitter) {
-                    return (NotificationEmitter) mbean;
-                }
-                return null;
-            }
-        }
-        VirtualWombatRepository bush;
-
-        VirtualWombatHandler(Map<ObjectName, DynamicMBean> bush) {
-            this(new VirtualWombatRepository(Collections.synchronizedMap(bush)));
-        }
-
-        private VirtualWombatHandler(VirtualWombatRepository repository) {
-            super(repository);
-            bush = repository;
-        }
-
-        @Override
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-                throws Exception {
-            final ObjectName myname = super.preRegister(server, name);
-            return myname;
-        }
-
-        @Override
-        public void postRegister(Boolean registrationDone) {
-            if (!registrationDone.booleanValue()) {
-                return;
-            }
-            final MBeanServer me = JMXNamespaces.narrowToNamespace(getMBeanServer(),
-                    getObjectName().getDomain());
-            for (Map.Entry<ObjectName, DynamicMBean> e : bush.bush.entrySet()) {
-                final DynamicMBean obj = e.getValue();
-                try {
-                    if (obj instanceof MBeanRegistration) {
-                        ((MBeanRegistration) obj).preRegister(me, e.getKey());
-                    }
-                } catch (Exception x) {
-                    System.err.println("preRegister failed for " +
-                            e.getKey() + ": " + x);
-                    bush.bush.remove(e.getKey());
-                }
-            }
-            for (Map.Entry<ObjectName, DynamicMBean> e : bush.bush.entrySet()) {
-                final Object obj = e.getValue();
-                if (obj instanceof MBeanRegistration) {
-                    ((MBeanRegistration) obj).postRegister(registrationDone);
-                }
-            }
-        }
-
-        @Override
-        public void preDeregister() throws Exception {
-            for (Map.Entry<ObjectName, DynamicMBean> e : bush.bush.entrySet()) {
-                final Object obj = e.getValue();
-                if (obj instanceof MBeanRegistration) {
-                    ((MBeanRegistration) obj).preDeregister();
-                }
-            }
-        }
-
-        @Override
-        public void postDeregister() {
-            for (Map.Entry<ObjectName, DynamicMBean> e : bush.bush.entrySet()) {
-                final Object obj = e.getValue();
-                if (obj instanceof MBeanRegistration) {
-                    ((MBeanRegistration) obj).postDeregister();
-                }
-            }
-        }
-    }
-
-    public static ObjectName getWombatName(String name)
-        throws MalformedObjectNameException {
-        return ObjectName.getInstance("australian.bush:type=Wombat,name="+name);
-    }
-
-    public static ObjectName addDir(String dir, ObjectName name)
-        throws MalformedObjectNameException {
-        return name.withDomain(
-                dir+JMXNamespaces.NAMESPACE_SEPARATOR+ name.getDomain());
-    }
-
-    public static void simpleTest()
-        throws JMException, IOException {
-        final MBeanServer master = MBeanServerFactory.createMBeanServer();
-        final MBeanServer agent1 = MBeanServerFactory.createMBeanServer();
-        final Wombat w1 = new Wombat();
-        final Wombat w2 = new Wombat();
-        final Wombat w3 = new Wombat();
-        final Map<ObjectName,DynamicMBean> wombats =
-                new ConcurrentHashMap<ObjectName,DynamicMBean>();
-        wombats.put(getWombatName("LittleWombat"),
-                new DynamicWombat(w2));
-        wombats.put(getWombatName("BigWombat"),
-                new DynamicWombat(w3));
-        final Wombat w4 = new Wombat();
-        final Wombat w5 = new Wombat();
-
-        final JMXNamespace agent2 =
-                new VirtualWombatHandler(wombats);
-        agent1.registerMBean(w4,getWombatName("LittleWombat"));
-        master.registerMBean(w1,getWombatName("LittleWombat"));
-        master.registerMBean(new JMXNamespace(agent1),
-                JMXNamespaces.getNamespaceObjectName("south.east"));
-        master.registerMBean(agent2,
-                JMXNamespaces.getNamespaceObjectName("north"));
-        master.registerMBean(w5,addDir("south.east",
-                getWombatName("GrandWombat")));
-
-        MBeanServer se = null;
-
-        try {
-            se = JMXNamespaces.narrowToNamespace(master,"south.easht");
-        } catch (Exception x) {
-            System.out.println("Caught expected exception: "+x);
-        }
-        if (se != null)
-            throw new RuntimeException("Expected exception for "+
-                    "cd(south.easht)");
-        se = JMXNamespaces.narrowToNamespace(master,"south.east");
-
-        MBeanServer nth = JMXNamespaces.narrowToNamespace(master,"north");
-
-        final ObjectName ln = getWombatName("LittleWombat");
-        MBeanInfo mb1 = master.getMBeanInfo(ln);
-        MBeanInfo mb2 = se.getMBeanInfo(ln);
-        MBeanInfo mb3 = nth.getMBeanInfo(ln);
-
-        final WombatMBean grand = JMX.newMBeanProxy(se,
-                getWombatName("GrandWombat"),WombatMBean.class);
-        final WombatMBean big = JMX.newMBeanProxy(nth,
-                getWombatName("BigWombat"),WombatMBean.class);
-        grand.getCaption();
-        big.getCaption();
-        grand.setCaption("I am GrandWombat");
-        big.setCaption("I am BigWombat");
-
-        final WombatMBean grand2 =
-                JMX.newMBeanProxy(master,addDir("south.east",
-                getWombatName("GrandWombat")),WombatMBean.class);
-        final WombatMBean big2 =
-                JMX.newMBeanProxy(master,addDir("north",
-                getWombatName("BigWombat")),WombatMBean.class);
-        if (!"I am GrandWombat".equals(grand2.getCaption()))
-            throw new RuntimeException("bad caption for GrandWombat"+
-                    grand2.getCaption());
-        if (!"I am BigWombat".equals(big2.getCaption()))
-            throw new RuntimeException("bad caption for BigWombat"+
-                    big2.getCaption());
-
-
-        final Set<ObjectInstance> northWombats =
-                nth.queryMBeans(ObjectName.WILDCARD,null);
-        final Set<ObjectInstance> seWombats =
-                se.queryMBeans(ObjectName.WILDCARD,null);
-        if (!northWombats.equals(
-                agent2.getSourceServer().queryMBeans(ObjectName.WILDCARD,null))) {
-            throw new RuntimeException("Bad Wombat census in northern territory: got "
-                    +northWombats+", expected "+
-                    agent2.getSourceServer().
-                    queryMBeans(ObjectName.WILDCARD,null));
-        }
-        if (!seWombats.equals(
-                agent1.queryMBeans(ObjectName.WILDCARD,null))) {
-            throw new RuntimeException("Bad Wombat census in south east: got "
-                    +seWombats+", expected "+
-                    agent1.
-                    queryMBeans(ObjectName.WILDCARD,null));
-        }
-
-        final MBeanServer supermaster = MBeanServerFactory.createMBeanServer();
-        supermaster.registerMBean(new JMXNamespace(master),
-            JMXNamespaces.getNamespaceObjectName("australia"));
-        final MBeanServer proxymaster =
-                JMXNamespaces.narrowToNamespace(supermaster,"australia");
-        final MBeanServer sem =
-                JMXNamespaces.narrowToNamespace(proxymaster,"south.east");
-        final MBeanServer nthm =
-                JMXNamespaces.narrowToNamespace(proxymaster,"north");
-        final Set<ObjectInstance> northWombats2 =
-                nthm.queryMBeans(ObjectName.WILDCARD,null);
-        final Set<ObjectInstance> seWombats2 =
-                sem.queryMBeans(ObjectName.WILDCARD,null);
-        if (!northWombats2.equals(
-                agent2.getSourceServer().queryMBeans(ObjectName.WILDCARD,null))) {
-            throw new RuntimeException("Bad Wombat census in " +
-                    "Australia // North");
-        }
-        if (!seWombats2.equals(
-                agent1.queryMBeans(ObjectName.WILDCARD,null))) {
-            throw new RuntimeException("Bad Wombat census in " +
-                    "Australia // South East");
-        }
-        final WombatMBean grand3 =
-                JMX.newMBeanProxy(supermaster,
-                addDir("australia//south.east",
-                getWombatName("GrandWombat")),WombatMBean.class);
-        final WombatMBean big3 =
-                JMX.newMBeanProxy(supermaster,addDir("australia//north",
-                getWombatName("BigWombat")),WombatMBean.class);
-        if (!"I am GrandWombat".equals(grand3.getCaption()))
-            throw new RuntimeException("bad caption for " +
-                    "australia//south.east//GrandWombat"+
-                    grand3.getCaption());
-        if (!"I am BigWombat".equals(big3.getCaption()))
-            throw new RuntimeException("bad caption for " +
-                    "australia//north//BigWombat"+
-                    big3.getCaption());
-        final WombatMBean grand4 =
-                JMX.newMBeanProxy(sem,
-                getWombatName("GrandWombat"),WombatMBean.class);
-        final WombatMBean big4 =
-                JMX.newMBeanProxy(nthm,
-                getWombatName("BigWombat"),WombatMBean.class);
-        if (!"I am GrandWombat".equals(grand4.getCaption()))
-            throw new RuntimeException("bad caption for " +
-                    "[australia//south.east//] GrandWombat"+
-                    grand4.getCaption());
-        if (!"I am BigWombat".equals(big4.getCaption()))
-            throw new RuntimeException("bad caption for " +
-                    "[australia//north//] BigWombat"+
-                    big4.getCaption());
-
-        if (!(nthm instanceof RoutingServerProxy))
-            throw new AssertionError("expected RoutingServerProxy for nthm");
-        if (!(sem instanceof RoutingServerProxy))
-            throw new AssertionError("expected RoutingServerProxy for sem");
-
-        if (!"australia//north".equals((
-                (RoutingServerProxy)nthm).getSourceNamespace()))
-            throw new RuntimeException("north territory should be in australia");
-        if (!"australia//south.east".equals((
-                (RoutingServerProxy)sem).getSourceNamespace()))
-            throw new RuntimeException("south east territory should be in australia");
-
-    }
-
-    public static  void main(String[] args) {
-        try {
-            simpleTest();
-        } catch (Exception x) {
-            System.err.println("SimpleTest failed: "+x);
-            throw new RuntimeException(x);
-        }
-    }
-
-}
--- a/test/javax/management/namespace/SerialParamProcessorTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,572 +0,0 @@
-/*
- * 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 SerialParamProcessorTest.java 1.8
- * @summary General SerialParamProcessorTest test.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean SerialParamProcessorTest Wombat WombatMBean
- * @compile -XDignore.symbol.file=true  SerialParamProcessorTest.java
- * @run build SerialParamProcessorTest Wombat WombatMBean
- * @run main SerialParamProcessorTest
- */
-
-import com.sun.jmx.namespace.serial.RewritingProcessor;
-import java.beans.ConstructorProperties;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import javax.management.AttributeChangeNotification;
-import javax.management.AttributeList;
-import javax.management.JMException;
-import javax.management.Notification;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-/**
- * Class SerialParamProcessorTest
- *
- * @author Sun Microsystems, Inc.
- */
-public class SerialParamProcessorTest {
-
-    /**
-     * Creates a new instance of SerialParamProcessorTest
-     */
-    public SerialParamProcessorTest() {
-    }
-
-    public static class MyCompositeData implements Serializable {
-        private static final long serialVersionUID = 3186492415099133506L;
-        public MyCompositeData(ObjectName foobar,ObjectName absolute,
-                long count, String name) {
-            this(foobar,absolute,count,name,new ObjectName[]{foobar,absolute});
-        }
-        @ConstructorProperties(value={"fooBar","absolute","count","name",
-                                        "allNames"})
-        public MyCompositeData(ObjectName foobar,ObjectName absolute,
-                long count, String name, ObjectName[] allnames) {
-            this.foobar = foobar;
-            this.absolute = absolute;
-            this.count = count;
-            this.name = name;
-            this.allnames = allnames;
-        }
-        ObjectName foobar,absolute,allnames[];
-        long count;
-        String name;
-        public ObjectName getFooBar() {
-            return foobar;
-        }
-        public ObjectName getAbsolute() {
-            return absolute;
-        }
-        public ObjectName[] getAllNames() {
-            return allnames;
-        }
-        public long getCount() {
-            return count;
-        }
-        public String getName() {
-            return name;
-        }
-        private Object[] toArray() {
-            final Object[] props = {
-                getName(),getFooBar(),getAbsolute(),getAllNames(),getCount()
-            };
-            return props;
-        }
-        @Override
-        public boolean equals(Object o) {
-            if (o instanceof MyCompositeData)
-                return Arrays.deepEquals(toArray(),
-                        ((MyCompositeData)o).toArray());
-            return false;
-        }
-        @Override
-        public int hashCode() {
-            return Arrays.deepHashCode(toArray());
-        }
-    }
-
-    public static interface MyMXBean {
-        public Map<String,MyCompositeData> getAll();
-        public MyCompositeData lookup(String name);
-        public void put(String name, MyCompositeData data);
-        public MyCompositeData remove(String name);
-    }
-
-    public static class My implements MyMXBean {
-        Map<String,MyCompositeData> datas =
-                new HashMap<String,MyCompositeData>();
-        public Map<String,MyCompositeData> getAll() {
-            return datas;
-        }
-        public MyCompositeData lookup(String name) {
-            return datas.get(name);
-        }
-        public void put(String name, MyCompositeData data) {
-            datas.put(name,data);
-        }
-        public MyCompositeData remove(String name) {
-            return datas.remove(name);
-        }
-    }
-
-    public static class BandicootClass implements Serializable {
-        private static final long serialVersionUID = -5494055748633966355L;
-        public final Object gloups;
-        public BandicootClass(Object gloups) {
-            this.gloups = gloups;
-        }
-        private Object[] toArray() {
-            final Object[] one = {gloups};
-            return one;
-        }
-        @Override
-        public boolean equals(Object obj) {
-            if (!(obj instanceof BandicootClass)) return false;
-            final Object[] one = {gloups};
-            return Arrays.deepEquals(toArray(),((BandicootClass)obj).toArray());
-        }
-        @Override
-        public int hashCode() {
-            if (gloups == null) return 0;
-            return Arrays.deepHashCode(toArray());
-        }
-    }
-
-    // Need this to override equals.
-    public static class BandicootNotification extends Notification {
-        private static final long serialVersionUID = 664758643764049001L;
-        public BandicootNotification(String type, Object source, long seq) {
-            super(type,source,seq,0L,"");
-        }
-        private Object[] toArray() {
-            final Object[] vals = {getMessage(),getSequenceNumber(),
-                getSource(),getTimeStamp(),getType(),getUserData()};
-            return vals;
-        }
-        @Override
-        public boolean equals(Object o) {
-            if (!(o instanceof BandicootNotification)) return false;
-            return Arrays.deepEquals(toArray(),
-                    ((BandicootNotification)o).toArray());
-        }
-        @Override
-        public int hashCode() {
-            return Arrays.deepHashCode(toArray());
-        }
-
-    }
-
-    // Need this to override equals.
-    public static class BandicootAttributeChangeNotification
-            extends AttributeChangeNotification {
-        private static final long serialVersionUID = -1392435607144396125L;
-        public BandicootAttributeChangeNotification(Object source,
-                long seq, long time, String msg, String name, String type,
-                Object oldv, Object newv) {
-            super(source,seq,time,msg,name,type,oldv,newv);
-        }
-        private Object[] toArray() {
-            final Object[] vals = {getMessage(),getSequenceNumber(),
-                getSource(),getTimeStamp(),getType(),getUserData(),
-                getAttributeName(), getAttributeType(),getNewValue(),
-                getOldValue()};
-            return vals;
-        }
-        @Override
-        public boolean equals(Object o) {
-            if (!(o instanceof BandicootAttributeChangeNotification))
-                return false;
-            return Arrays.deepEquals(toArray(),
-                    ((BandicootAttributeChangeNotification)o).toArray());
-        }
-        @Override
-        public int hashCode() {
-            return Arrays.deepHashCode(toArray());
-        }
-        @Override
-        public String toString() {
-            final StringBuilder b = new StringBuilder();
-            b.append(this.getClass().getName()).append(": ");
-            b.append("[type=").append(getType()).append("]");
-            b.append("[source=").append(getSource()).append("]");
-            b.append("[message=").append(getMessage()).append("]");
-            b.append("[sequence=").append(getSequenceNumber()).append("]");
-
-            b.append("[attribute=").append(getAttributeName()).append("]");
-            b.append("[class=").append(getAttributeType()).append("]");
-            b.append("[oldvalue=").append(getOldValue()).append("]");
-            b.append("[newvalue=").append(getNewValue()).append("]");
-
-            b.append("[time=").append(getTimeStamp()).append("]");
-            b.append("[data=").append(getUserData()).append("]");
-            return b.toString();
-        }
-    }
-
-    private static void addToList(Object[] foos, List<Object> foolist) {
-        final ArrayList<Object> fal = new ArrayList<Object>(foos.length);
-        for (Object f : foos) {
-            if (f.getClass().isArray()) {
-                foolist.add(new BandicootClass(f));
-                fal.add(new BandicootClass(f));
-            } else {
-                foolist.add(f);
-                fal.add(f);
-            }
-        }
-        foolist.add(new BandicootClass(foos));
-        foolist.add(fal);
-    }
-
-    public static void testSerial(String msg, Object foo, Object bar,
-            RewritingProcessor procForFoo,
-            RewritingProcessor procForBar, List<Object> foolist,
-            List<Object> barlist, boolean recurse) {
-        System.err.println(msg+" Testing serial - "+foo.getClass().getName());
-        final Object bar1  = procForFoo.rewriteInput(foo);
-        final Object foo1  = procForFoo.rewriteOutput(bar);
-        final Object bar2  = procForFoo.rewriteInput(foo1);
-        final Object foo2  = procForFoo.rewriteOutput(bar1);
-
-        final Object bar3  = procForBar.rewriteOutput(foo);
-        final Object foo3  = procForBar.rewriteInput(bar);
-        final Object bar4  = procForBar.rewriteOutput(foo3);
-        final Object foo4  = procForBar.rewriteInput(bar3);
-
-        final Object bar5  = procForFoo.rewriteInput(foo3);
-        final Object foo5  = procForFoo.rewriteOutput(bar3);
-
-        final Object bar6  = procForBar.rewriteOutput(foo1);
-        final Object foo6  = procForBar.rewriteInput(bar1);
-
-        final Object[] foos = {foo, foo1, foo2, foo3, foo4, foo5, foo6};
-        final Object[] bars = {bar, bar1, bar2, bar3, bar4, bar5, bar6};
-
-        final Object[] foot = { foo };
-        final Object[] bart = { bar };
-        for (int j=1;j<foos.length;j++) {
-            final Object[] foox = { foos[j] };
-            final Object[] barx = { bars[j] };
-            if (!Arrays.deepEquals(foot,foox)) {
-                System.err.println(msg+" foo"+j+" "+foos[j]+" != "+foo);
-                throw new RuntimeException(msg+" foo"+j+" != foo");
-            }
-            if (!Arrays.deepEquals(bart,barx)) {
-                System.err.println(msg+" bar"+j+" "+bars[j]+" != "+bar);
-                throw new RuntimeException(msg+" bar"+j+" != bar");
-            }
-
-        }
-        if (recurse) {
-            testSerial("Array: " + msg,foos,bars,procForFoo,
-                    procForBar,foolist,barlist,false);
-            addToList(foos,foolist);
-            addToList(bars,barlist);
-        }
-    }
-    public static void testSerial(Object[][] objects,
-            RewritingProcessor procForFoo,
-            RewritingProcessor procForBar) {
-        int i=0;
-        final List<Object> foolist  = new LinkedList<Object>();
-        final List<Object> barlist = new LinkedList<Object>();
-        for (Object[] row : objects) {
-            i++;
-            Object foo = row[0];
-            Object bar = row[1];
-            String msg1 = "[" +foo.getClass().getName() + "] step " +
-                    i +": ";
-
-            testSerial(msg1,foo,bar,procForFoo,procForBar,foolist,barlist,true);
-
-            final BandicootClass kfoo = new BandicootClass(foo);
-            final BandicootClass kbar = new BandicootClass(bar);
-
-            String msg2 = "[" +kfoo.getClass().getName() + "] step " +
-                    i +": ";
-            testSerial(msg2,kfoo,kbar,procForFoo,procForBar,foolist,barlist,true);
-        }
-        String msg31 = "foo[] and bar[]: ";
-        testSerial(msg31,foolist.toArray(),barlist.toArray(),
-                   procForFoo,procForBar,foolist,barlist,false);
-
-        String msg3 = "foolist and barlist: ";
-        testSerial(msg3,new LinkedList<Object>(foolist),
-                   new LinkedList<Object>(barlist),
-                   procForFoo,procForBar,foolist,barlist,false);
-
-        final BandicootClass kfoolist = new BandicootClass(foolist);
-        final BandicootClass kbarlist = new BandicootClass(barlist);
-        String msg4 = "kfoolist and kbarlist: ";
-        testSerial(msg4,kfoolist,kbarlist,procForFoo,procForBar,foolist,barlist,false);
-    }
-
-    /**
-     * The idea of this  method is to convert {@code foo} things into
-     * {@code bar} things...
-     * @param foo the string to replace.
-     * @param bar the replacement for {@code foo}
-     *        ({@code foo} becomes {@code bar}).
-     * @param sfoo a string that may contain {@code foo}, that will be embedded
-     *        in non-replaceable parts of the domain in order to attempt to
-     *        trick the replacement logic.
-     * @param sbar a string that may contain {@code bar}, that will be embedded
-     *        in non-replaceable parts of the domain in order to attempt to
-     *        trick the replacement logic.
-     **/
-    public static void doSerialTest(String foo, String bar, String sfoo,
-                               String sbar) {
-        try {
-        final RewritingProcessor procForFoo = RewritingProcessor.
-                newRewritingProcessor(foo,bar);
-        final RewritingProcessor procForBar =RewritingProcessor.
-                newRewritingProcessor(bar,foo);
-        final String foop = (foo.isEmpty())?foo:foo+"//";
-        final String pfoo = (foo.isEmpty())?foo:"//"+foo;
-        final String barp = (bar.isEmpty())?bar:bar+"//";
-        final String pbar = (bar.isEmpty())?bar:"//"+bar;
-        final String sfoop = (sfoo.isEmpty())?sfoo:sfoo+"//";
-        final String psfoo = (sfoo.isEmpty())?sfoo:"//"+sfoo;
-        final String sbarp = (sbar.isEmpty())?sbar:sbar+"//";
-        final String psbar = (sbar.isEmpty())?sbar:"//"+sbar;
-
-        // A trick to avoid writing Open Data by hand...
-        final My tricks = new My();
-
-        // A treat to automagically convert trick things into Open Data.
-        final StandardMBean treats =
-                new StandardMBean(tricks,MyMXBean.class,true);
-
-        // datas[i][0] is expected to be transformed in datas[i][1]
-        //
-        final MyCompositeData[][] datas = {
-            { // this foo thing:
-            new MyCompositeData(new ObjectName(foop+sbarp+"x:y=z"),
-                    new ObjectName("//"+foop+sbarp+"x:y=z"),1,sfoop+sbarp+"foobar"),
-              // should be transformed into this bar thing:
-            new MyCompositeData(new ObjectName(barp+sbarp+"x:y=z"),
-                    new ObjectName("//"+foop+sbarp+"x:y=z"),1,sfoop+sbarp+"foobar"),
-            },
-            { // this foo thing:
-            new MyCompositeData(new ObjectName(foop+sfoop+"x:y=z"),
-                    new ObjectName("//"+foop+sfoop+"x:y=z"),1,sfoop+sbarp+"barfoo"),
-              // should be transformed into this bar thing:
-            new MyCompositeData(new ObjectName(barp+sfoop+"x:y=z"),
-                    new ObjectName("//"+foop+sfoop+"x:y=z"),1,sfoop+sbarp+"barfoo"),
-            }
-        };
-
-        // objects[i][0] is expected to be transformed into objects[i][1]
-        //
-        final Object[][] objects = new Object[][] {
-            {new Long(1), new Long(1)},
-            {
-                new ObjectName(foop+sbarp+"x:y=z"),
-                        new ObjectName(barp+sbarp+"x:y=z")
-            },
-            {
-                new ObjectName(foop+sfoop+"x:y=z"),
-                        new ObjectName(barp+sfoop+"x:y=z")
-            },
-            {
-                new ObjectName("//"+foop+sbarp+"x:y=z"),
-                new ObjectName("//"+foop+sbarp+"x:y=z"),
-            },
-            {
-                new ObjectName("//"+foop+sfoop+"x:y=z"),
-                new ObjectName("//"+foop+sfoop+"x:y=z")
-            },
-            {
-                foop+sbarp+"x:y=z",foop+sbarp+"x:y=z"
-            },
-            {
-                foop+sfoop+"x:y=z",foop+sfoop+"x:y=z"
-            },
-            {
-                barp+sbarp+"x:y=z",barp+sbarp+"x:y=z"
-            },
-            {
-                barp+sfoop+"x:y=z",barp+sfoop+"x:y=z"
-            },
-            {
-            new BandicootNotification("test",new ObjectName(foop+sfoop+"x:y=z"),1L),
-            new BandicootNotification("test",new ObjectName(barp+sfoop+"x:y=z"),1L),
-            },
-            {
-            new BandicootNotification("test",new ObjectName("//"+foop+sfoop+"x:y=z"),2L),
-            new BandicootNotification("test",new ObjectName("//"+foop+sfoop+"x:y=z"),2L),
-            },
-            {
-            new BandicootAttributeChangeNotification(
-                    new ObjectName(foop+sfoop+"x:y=z"),1L,2L,"blah","attrname",
-                    ObjectName.class.getName(),
-                    new ObjectName(foop+sfoop+"x:y=old"),
-                    new ObjectName(foop+sfoop+"x:y=new")),
-            new BandicootAttributeChangeNotification(
-                    new ObjectName(barp+sfoop+"x:y=z"),1L,2L,"blah","attrname",
-                    ObjectName.class.getName(),
-                    new ObjectName(barp+sfoop+"x:y=old"),
-                    new ObjectName(barp+sfoop+"x:y=new")),
-            },
-            {
-            new BandicootAttributeChangeNotification(
-                    new ObjectName("//"+foop+sfoop+"x:y=z"),1L,2L,"blah","attrname",
-                    ObjectName.class.getName(),
-                    new ObjectName("//"+foop+sfoop+"x:y=old"),
-                    new ObjectName(foop+sfoop+"x:y=new")),
-            new BandicootAttributeChangeNotification(
-                    new ObjectName("//"+foop+sfoop+"x:y=z"),1L,2L,"blah","attrname",
-                    ObjectName.class.getName(),
-                    new ObjectName("//"+foop+sfoop+"x:y=old"),
-                    new ObjectName(barp+sfoop+"x:y=new")),
-            }
-        };
-
-        // List that will merge datas & objects & datas converted to open
-        // types...
-        //
-        final List<Object[]> list = new ArrayList<Object[]>();
-
-        // Add all objects...
-        //
-        list.addAll(Arrays.asList(objects));
-
-        // Build Map<String,MyCompositeData> with datas[i][0] (cfoo)
-        //
-        for (int i=0;i<datas.length;i++) {
-            tricks.put(sfoop+sbarp+"x"+i,datas[i][0]);
-        }
-
-        // Let MXBean convert Map<String,MyCompositeData> to TabularData
-        // (foo things)
-        final Object cfoo = treats.getAttribute("All");
-        final AttributeList afoo = treats.getAttributes(new String[] {"All"});
-
-        // Build Map<String,MyCompositeData> with datas[i][1] (cbar)
-        //
-        for (int i=0;i<datas.length;i++) {
-            tricks.remove(sfoop+sbarp+"x"+i);
-            tricks.put(sfoop+sbarp+"x"+i,datas[i][1]);
-        }
-
-        // Let MXBean convert Map<String,MyCompositeData> to TabularData
-        // (bar things)
-        final Object cbar = treats.getAttribute("All");
-        final AttributeList abar = treats.getAttributes(new String[] {"All"});
-
-        // Add all datas to list
-        for (int i=0;i<datas.length;i++) {
-            list.add(datas[i]);
-        }
-
-        // Add converted TabularDatas to list
-        list.add(new Object[] {cfoo,cbar});
-
-        // Add AttributeList containing TabularData to list
-        list.add(new Object[] {afoo,abar});
-
-        // Add Arrays of the above to list...
-        list.add(new Object[] {new Object[] {cfoo,afoo,1L},
-                               new Object[] {cbar,abar,1L}});
-
-        // Add MBeanInfo...
-        list.add(new Object[] {treats.getMBeanInfo(),treats.getMBeanInfo()});
-
-        // No ready to test conversion of all foo things into bar things.
-        //
-        testSerial(list.toArray(new Object[list.size()][]),
-                procForFoo,procForBar);
-        } catch (JMException x) {
-            throw new RuntimeException(x);
-        }
-    }
-
-    public static void aaaTest() {
-        System.err.println("\n--------------------- aaaTest ----------------");
-        System.err.println("---------------- 'foo' becomes 'bar' ---------\n");
-        doSerialTest("foo","bar","foo","bar");
-    }
-
-    public static void aabTest() {
-        System.err.println("\n--------------------- aabTest ----------------");
-        System.err.println("---------- 'foo//bar' becomes 'bar//foo' -----\n");
-        doSerialTest("foo//bar","bar//foo","foo","bar");
-    }
-
-    public static void aacTest() {
-        System.err.println("\n----------------- aacTest --------------------");
-        System.err.println("------------ 'foo//bar' becomes '' -----------\n");
-        doSerialTest("foo//bar","","foo","bar");
-    }
-
-    public static void aadTest() {
-        System.err.println("\n----------------- aadTest --------------------");
-        System.err.println("----------- '' becomes 'bar//foo' ------------\n");
-        doSerialTest("","bar//foo","","bar//foo");
-    }
-
-    public static void aaeTest() {
-        System.err.println("\n----------------- aaeTest --------------------");
-        System.err.println("----------------- '' becomes '' --------------\n");
-        doSerialTest("","","foo","bar//foo");
-    }
-
-    // Let's be wild...
-    public static void aafTest() {
-        System.err.println("\n----------------- aafTest --------------------");
-        System.err.println("----------- '' becomes '' -- (bis) -----------\n");
-        doSerialTest("","","","");
-    }
-    public static void aagTest() {
-        System.err.println("\n----------------- aagTest --------------------");
-        System.err.println("----------- foobar becomes foobar ------------\n");
-        doSerialTest("foobar","foobar","foobar","foobar");
-    }
-
-    // TODO add test with descriptor, MBeanInfo, Open Types, etc...
-    public static void main(String[] args) {
-        aaaTest();
-        aabTest();
-        aacTest();
-        aadTest();
-        aaeTest();
-        aafTest();
-        aagTest();
-
-        // TODO: add a test case to test *exactly* the serialization
-        // of Notification and AttributeChangeNotification, and not of
-        // a subclass of these.
-        // This will involve implementing some hack, because we
-        // can't use equals() to compare the results.
-    }
-}
--- a/test/javax/management/namespace/SourceNamespaceTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
- * 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 SourceNamespaceTest.java
- * @summary Test how queryNames works with Namespaces.
- * @bug 5072476
- * @author Daniel Fuchs
- * @run clean SourceNamespaceTest Wombat WombatMBean
- * @run build SourceNamespaceTest Wombat WombatMBean
- * @run main SourceNamespaceTest
- */
-
-
-import javax.management.JMException;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-
-/**
- * A simple test to test the source directory parameter...
- * @author dfuchs
- */
-public class SourceNamespaceTest {
-
-
-    public static void localTest() throws JMException {
-        final JMXNamespace adir =
-                new JMXNamespace(MBeanServerFactory.newMBeanServer());
-
-        // put a wombat in adir...
-        final Wombat w1 = new Wombat();
-        final ObjectName wn1 = new ObjectName("wilderness:type=Wombat,name=gloups");
-        adir.getSourceServer().registerMBean(w1,wn1);
-
-        // register adir
-        final MBeanServer server = MBeanServerFactory.newMBeanServer();
-        server.registerMBean(adir, JMXNamespaces.getNamespaceObjectName("adir"));
-
-        if (! (server.isRegistered(JMXNamespaces.insertPath("adir", wn1))))
-            throw new RuntimeException("Test failed: " +
-                    JMXNamespaces.insertPath("adir", wn1) + " not found");
-
-        System.out.println("Wombat gloups correctly registered...");
-
-        // put another wombat in adir...
-        final Wombat w2 = new Wombat();
-        final ObjectName wn2 =
-                new ObjectName("wilderness:type=Wombat,name=pasgloups");
-        server.registerMBean(w2,JMXNamespaces.insertPath("adir", wn2));
-
-        if (! (server.isRegistered(JMXNamespaces.insertPath("adir", wn2))))
-            throw new RuntimeException("Test failed: " +
-                    JMXNamespaces.insertPath("adir", wn2) + " not found");
-
-        System.out.println("Wombat pasgloups correctly registered...");
-
-
-        // make an alias
-        final JMXNamespace alias = new JMXNamespace(
-                JMXNamespaces.narrowToNamespace(server,"adir"));
-        server.registerMBean(alias,
-                JMXNamespaces.getNamespaceObjectName("alias"));
-
-        if (! (server.isRegistered(JMXNamespaces.insertPath("alias", wn1))))
-            throw new RuntimeException("Test failed: " +
-                    JMXNamespaces.insertPath("alias", wn1) + " not found");
-
-        System.out.println("Wombat gloups accessible through alias...");
-
-        if (! (server.isRegistered(JMXNamespaces.insertPath("alias", wn2))))
-            throw new RuntimeException("Test failed: " +
-                    JMXNamespaces.insertPath("alias", wn2) + " not found");
-
-        System.out.println("Wombat pasgloups accessible through alias...");
-
-        final WombatMBean wp2 = JMX.newMBeanProxy(server,
-                JMXNamespaces.insertPath("alias",wn2), WombatMBean.class);
-        System.out.println(JMXNamespaces.insertPath("alias",wn2).toString()
-                +" says: "+wp2.getCaption());
-
-        // We're going to make another alias, but register it in a different
-        // MBeanServer. This is to make sure that source server and target
-        // server are not mixed up.
-        //
-        final MBeanServer server2 = MBeanServerFactory.newMBeanServer();
-        final JMXNamespace alias2 = new JMXNamespace(
-                JMXNamespaces.narrowToNamespace(server,"adir"));
-        server2.registerMBean(alias2,
-                JMXNamespaces.getNamespaceObjectName("alias2"));
-
-
-        if (! (server2.isRegistered(JMXNamespaces.insertPath("alias2", wn1))))
-            throw new RuntimeException("Test failed: " +
-                    JMXNamespaces.insertPath("alias2", wn1) + " not found");
-
-        System.out.println("Wombat gloups accessible through alias2...");
-
-        if (! (server2.isRegistered(JMXNamespaces.insertPath("alias2", wn2))))
-            throw new RuntimeException("Test failed: " +
-                    JMXNamespaces.insertPath("alias2", wn2) + " not found");
-
-        System.out.println("Wombat pasgloups accessible through alias...");
-
-        final WombatMBean wp22 = JMX.newMBeanProxy(server2,
-                JMXNamespaces.insertPath("alias2",wn2), WombatMBean.class);
-        System.out.println(JMXNamespaces.insertPath("alias2",wn2).toString()
-                +" says: "+wp22.getCaption());
-
-
-
-    }
-
-    public static void main(String[] args) throws Exception {
-        localTest();
-    }
-
-}
--- a/test/javax/management/namespace/VirtualMBeanNotifTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,569 +0,0 @@
-/*
- * 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 VirtualMBeanNotifTest.java
- * @bug 5108776
- * @build VirtualMBeanNotifTest Wombat WombatMBean
- * @run main VirtualMBeanNotifTest
- * @summary Test that Virtual MBeans can be implemented and emit notifs.
- * @author  Daniel Fuchs
- */
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.TimeUnit;
-import javax.management.Attribute;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-import javax.management.StandardMBean;
-import javax.management.event.EventSubscriber;
-import javax.management.namespace.VirtualEventManager;
-import javax.management.namespace.MBeanServerSupport;
-
-public class VirtualMBeanNotifTest {
-
-    /**
-     * An invocation handler that can implement DynamicMBean,
-     * NotificationBroadcaster, NotificationEmitter.
-     * The invocation handler works by forwarding all calls received from
-     * the implemented interfaces through a wrapped MBeanServer object.
-     */
-    public static class DynamicWrapper
-            implements InvocationHandler {
-
-        /**
-         * Inserts an additional class at the head of a signature array.
-         * @param first The first class in the signature
-         * @param rest  The other classes in the signature
-         * @return A signature array, of length rest.length+1.
-         */
-        static Class[] concat(Class first, Class... rest) {
-            if (rest == null || rest.length == 0) {
-                return new Class[] { first };
-            }
-            final Class[] sig = new Class[rest.length+1];
-            sig[0] = first;
-            System.arraycopy(rest, 0, sig, 1, rest.length);
-            return sig;
-        }
-
-        /**
-         * Inserts an additional object at the head of a parameters array.
-         * @param first The first object in the parameter array.
-         * @param rest  The other objects in the parameter array.
-         * @return A parameter array, of length rest.length+1.
-         */
-        static Object[] concat(Object first, Object... rest) {
-            if (rest == null || rest.length == 0) {
-                return new Object[] { first };
-            }
-            final Object[] params = new Object[rest.length+1];
-            params[0] = first;
-            System.arraycopy(rest, 0, params, 1, rest.length);
-            return params;
-        }
-
-        /**
-         * These two sets are used to check that all methods from
-         * implemented interfaces are mapped.
-         * unmapped is the set of methods that couldn't be mapped.
-         * mapped is the set of methods that could be mapped.
-         */
-        final static Set<Method> unmapped = new HashSet<Method>();
-        final static Set<Method> mapped = new HashSet<Method>();
-
-        /**
-         * For each method define in one of the interfaces intf, tries
-         * to find a corresponding method in the reference class ref, where
-         * the method in ref has the same name, and takes an additional
-         * ObjectName as first parameter.
-         *
-         * So for instance, if ref is MBeanServer and intf is {DynamicMBean}
-         * the result map is:
-         *     DynamicMBean.getAttribute -> MBeanServer.getAttribute
-         *     DynamicMBean.setAttribute -> MBeanServer.setAttribute
-         *     etc...
-         * If a method was mapped, it is additionally added to 'mapped'
-         * If a method couldn't be mapped, it is added to 'unmmapped'.
-         * In our example above, DynamicMBean.getNotificationInfo will end
-         * up in 'unmapped'.
-         *
-         * @param ref   The reference class - to which calls will be forwarded
-         *              with an additional ObjectName parameter inserted.
-         * @param intf  The proxy interface classes - for which we must find an
-         *              equivalent in 'ref'
-         * @return A map mapping the methods from intfs to the method of ref.
-         */
-        static Map<Method,Method> makeMapFor(Class<?> ref, Class<?>... intf) {
-            final Map<Method,Method> map = new HashMap<Method,Method>();
-            for (Class<?> clazz : intf) {
-                for (Method m : clazz.getMethods()) {
-                    try {
-                        final Method m2 =
-                            ref.getMethod(m.getName(),
-                            concat(ObjectName.class,m.getParameterTypes()));
-                        map.put(m,m2);
-                        mapped.add(m);
-                    } catch (Exception x) {
-                        unmapped.add(m);
-                    }
-                }
-            }
-            return map;
-        }
-
-        /**
-         * Tries to map all methods from DynamicMBean.class and
-         * NotificationEmitter.class to their equivalent in MBeanServer.
-         * This should be all the methods except
-         * DynamicMBean.getNotificationInfo.
-         */
-        static final Map<Method,Method> mbeanmap =
-                makeMapFor(MBeanServer.class,DynamicMBean.class,
-                NotificationEmitter.class);
-        /**
-         * Tries to map all methods from DynamicMBean.class and
-         * NotificationEmitter.class to an equivalent in DynamicWrapper.
-         * This time only DynamicMBean.getNotificationInfo will be mapped.
-         */
-        static final Map<Method,Method> selfmap =
-                makeMapFor(DynamicWrapper.class,DynamicMBean.class,
-                NotificationEmitter.class);
-
-        /**
-         * Now check that we have mapped all methods.
-         */
-        static {
-            unmapped.removeAll(mapped);
-            if (unmapped.size() > 0)
-                throw new ExceptionInInitializerError("Couldn't map "+ unmapped);
-        }
-
-        /**
-         * The wrapped MBeanServer to which everything is delegated.
-         */
-        private final MBeanServer server;
-
-        /**
-         * The name of the MBean we're proxying.
-         */
-        private final ObjectName name;
-        DynamicWrapper(MBeanServer server, ObjectName name) {
-            this.server=server;
-            this.name=name;
-        }
-
-        /**
-         * Creates a new proxy for the given MBean. Implements
-         * NotificationEmitter/NotificationBroadcaster if the proxied
-         * MBean also does.
-         * @param name    the name of the proxied MBean
-         * @param server  the wrapped server
-         * @return a DynamicMBean proxy
-         * @throws javax.management.InstanceNotFoundException
-         */
-        public static DynamicMBean newProxy(ObjectName name, MBeanServer server)
-            throws InstanceNotFoundException {
-            if (server.isInstanceOf(name,
-                    NotificationEmitter.class.getName())) {
-                // implements NotificationEmitter
-                return (DynamicMBean)
-                        Proxy.newProxyInstance(
-                        DynamicWrapper.class.getClassLoader(),
-                        new Class[] {NotificationEmitter.class,
-                        DynamicMBean.class},
-                        new DynamicWrapper(server, name));
-            }
-            if (server.isInstanceOf(name,
-                    NotificationBroadcaster.class.getName())) {
-                // implements NotificationBroadcaster
-                return (DynamicMBean)
-                        Proxy.newProxyInstance(
-                        DynamicWrapper.class.getClassLoader(),
-                        new Class[] {NotificationBroadcaster.class,
-                        DynamicMBean.class},
-                        new DynamicWrapper(server, name));
-            }
-            // Only implements DynamicMBean.
-            return (DynamicMBean)
-                        Proxy.newProxyInstance(
-                        DynamicWrapper.class.getClassLoader(),
-                        new Class[] {DynamicMBean.class},
-                        new DynamicWrapper(server, name));
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args)
-                throws Throwable {
-            // Look for a method on this class (takes precedence)
-            final Method self = selfmap.get(method);
-            if (self != null)
-                return call(this,self,concat(name,args));
-
-            // no method found on this class, look for the same method
-            // on the wrapped MBeanServer
-            final Method mbean = mbeanmap.get(method);
-            if (mbean != null)
-                return call(server,mbean,concat(name,args));
-
-            // This isn't a method that can be forwarded to MBeanServer.
-            // If it's a method from Object, call it on this.
-            if (method.getDeclaringClass().equals(Object.class))
-                return call(this,method,args);
-            throw new NoSuchMethodException(method.getName());
-        }
-
-        // Call a method using reflection, unwraps invocation target exceptions
-        public Object call(Object handle, Method m, Object[] args)
-                throws Throwable {
-            try {
-                return m.invoke(handle, args);
-            } catch (InvocationTargetException x) {
-               throw x.getCause();
-            }
-        }
-
-        // this method is called when DynamicMBean.getNotificationInfo() is
-        // called. This is the method that should be mapped in
-        // 'selfmap'
-        public MBeanNotificationInfo[] getNotificationInfo(ObjectName name)
-            throws JMException {
-            return server.getMBeanInfo(name).getNotifications();
-        }
-    }
-
-    /**
-     * Just so that we can call the same test twice but with two
-     * different implementations of VirtualMBeanServerSupport.
-     */
-    public static interface MBeanServerWrapperFactory {
-        public MBeanServer wrapMBeanServer(MBeanServer wrapped);
-    }
-
-    /**
-     * A VirtualMBeanServerSupport that wrapps an MBeanServer and does not
-     * use VirtualEventManager.
-     */
-    public static class VirtualMBeanServerTest
-            extends MBeanServerSupport {
-
-        final MBeanServer wrapped;
-
-        public VirtualMBeanServerTest(MBeanServer wrapped) {
-            this.wrapped=wrapped;
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(final ObjectName name)
-                throws InstanceNotFoundException {
-            if (wrapped.isRegistered(name))
-                return DynamicWrapper.newProxy(name,wrapped);
-            throw new InstanceNotFoundException(String.valueOf(name));
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            return wrapped.queryNames(null, null);
-        }
-
-        public final static MBeanServerWrapperFactory factory =
-                new MBeanServerWrapperFactory() {
-
-            public MBeanServer wrapMBeanServer(MBeanServer wrapped) {
-                return new VirtualMBeanServerTest(wrapped);
-            }
-            @Override
-            public String toString() {
-                return VirtualMBeanServerTest.class.getName();
-            }
-        };
-    }
-
-     /**
-     * A VirtualMBeanServerSupport that wrapps an MBeanServer and
-     * uses a VirtualEventManager.
-     */
-    public static class VirtualMBeanServerTest2
-            extends VirtualMBeanServerTest {
-
-        final EventSubscriber sub;
-        final NotificationListener nl;
-        final VirtualEventManager  mgr;
-
-        /**
-         * We use an EventSubscriber to subscribe for all notifications from
-         * the wrapped MBeanServer, and publish them through a
-         * VirtualEventManager. Not a very efficient way of doing things.
-         * @param wrapped
-         */
-        public VirtualMBeanServerTest2(MBeanServer wrapped) {
-            super(wrapped);
-            this.sub = EventSubscriber.getEventSubscriber(wrapped);
-            this.mgr = new VirtualEventManager();
-            this.nl = new NotificationListener() {
-                public void handleNotification(Notification notification, Object handback) {
-                    mgr.publish((ObjectName)notification.getSource(), notification);
-                }
-            };
-            try {
-                sub.subscribe(ObjectName.WILDCARD, nl, null, null);
-            } catch (RuntimeException x) {
-                throw x;
-            } catch (Exception x) {
-                throw new IllegalStateException("can't subscribe for notifications!");
-            }
-        }
-
-        @Override
-        public NotificationEmitter
-                getNotificationEmitterFor(ObjectName name)
-                throws InstanceNotFoundException {
-            final DynamicMBean mbean = getDynamicMBeanFor(name);
-            if (mbean instanceof NotificationEmitter)
-                return mgr.getNotificationEmitterFor(name);
-            return null;
-        }
-
-        public final static MBeanServerWrapperFactory factory =
-                new MBeanServerWrapperFactory() {
-
-            public MBeanServer wrapMBeanServer(MBeanServer wrapped) {
-                return new VirtualMBeanServerTest2(wrapped);
-            }
-            @Override
-            public String toString() {
-                return VirtualMBeanServerTest2.class.getName();
-            }
-        };
-    }
-
-
-    public static void test(MBeanServerWrapperFactory factory) throws Exception {
-        final MBeanServer server = ManagementFactory.getPlatformMBeanServer();
-
-        // names[] are NotificationEmitters
-        final ObjectName[] emitters = new ObjectName[2];
-        // shields[] have been shielded by wrapping them in a StandardMBean,
-        // so although the resource is an MBean that implements
-        // NotificationEmitter, the registered MBean (the wrapper) doesn't.
-        final ObjectName[] shielded = new ObjectName[2];
-
-        final List<ObjectName> registered = new ArrayList<ObjectName>(4);
-
-        try {
-            // register two MBeans before wrapping
-            server.registerMBean(new Wombat(),
-                    emitters[0] = new ObjectName("bush:type=Wombat,name=wom"));
-            registered.add(emitters[0]);
-
-            // we shield the second MBean in a StandardMBean so that it does
-            // not appear as a NotificationEmitter.
-            server.registerMBean(
-                    new StandardMBean(new Wombat(), WombatMBean.class),
-                    shielded[0] = new ObjectName("bush:type=Wombat,name=womshield"));
-            registered.add(shielded[0]);
-
-            final MBeanServer vserver = factory.wrapMBeanServer(server);
-
-            // register two other MBeans after wrapping
-            server.registerMBean(new Wombat(),
-                    emitters[1] = new ObjectName("bush:type=Wombat,name=bat"));
-            registered.add(emitters[1]);
-
-            // we shield the second MBean in a StandardMBean so that it does
-            // not appear as a NotificationEmitter.
-            server.registerMBean(
-                    new StandardMBean(new Wombat(), WombatMBean.class),
-                    shielded[1] = new ObjectName("bush:type=Wombat,name=batshield"));
-            registered.add(shielded[1]);
-
-            // Call test with this config - we have two wombats who broadcast
-            // notifs (emitters) and two wombats who don't (shielded).
-            test(vserver, emitters, shielded);
-
-            System.out.println("*** Test passed for: " + factory);
-        } finally {
-            // Clean up the platform mbean server for the next test...
-            for (ObjectName n : registered) {
-                try {
-                    server.unregisterMBean(n);
-                } catch (Exception x) {
-                    x.printStackTrace();
-                }
-            }
-        }
-    }
-
-    /**
-     * Perform the actual test.
-     * @param vserver    A virtual MBeanServerSupport implementation
-     * @param emitters   Names of NotificationBroadcaster MBeans
-     * @param shielded   Names of non NotificationBroadcaster MBeans
-     * @throws java.lang.Exception
-     */
-    public static void test(MBeanServer vserver, ObjectName[] emitters,
-            ObjectName[] shielded) throws Exception {
-
-        // To catch exception in NotificationListener
-        final List<Exception> fail = new CopyOnWriteArrayList<Exception>();
-
-        // A queue of received notifications
-        final BlockingQueue<Notification> notifs =
-                new ArrayBlockingQueue<Notification>(50);
-
-        // A notification listener that puts the notification it receives
-        // in the queue.
-        final NotificationListener handler = new NotificationListener() {
-
-            public void handleNotification(Notification notification,
-                    Object handback) {
-                try {
-                    notifs.put(notification);
-                } catch (Exception x) {
-                    fail.add(x);
-                }
-            }
-        };
-
-        // A list of attribute names for which we might receive an
-        // exception. If an exception is received when getting these
-        // attributes - the test will not fail.
-        final List<String> exceptions = Arrays.asList( new String[] {
-           "UsageThresholdCount","UsageThreshold","UsageThresholdExceeded",
-           "CollectionUsageThresholdCount","CollectionUsageThreshold",
-           "CollectionUsageThresholdExceeded"
-        });
-
-        // This is just a sanity check. Get all attributes of all MBeans.
-        for (ObjectName n : vserver.queryNames(null, null)) {
-            final MBeanInfo m = vserver.getMBeanInfo(n);
-            for (MBeanAttributeInfo mba : m.getAttributes()) {
-                // System.out.println(n+":");
-                Object val;
-                try {
-                    val = vserver.getAttribute(n, mba.getName());
-                } catch (Exception x) {
-                    // only accept exception for those attributes that
-                    // have a valid reason to fail...
-                    if (exceptions.contains(mba.getName())) val = x;
-                    else throw new Exception("Failed to get " +
-                            mba.getName() + " from " + n,x);
-                }
-                // System.out.println("\t "+mba.getName()+": "+ val);
-            }
-        }
-
-        // The actual tests. Register for notifications with notif emitters
-        for (ObjectName n : emitters) {
-            vserver.addNotificationListener(n, handler, null, n);
-        }
-
-        // Trigger the emission of notifications, check that we received them.
-        for (ObjectName n : emitters) {
-            vserver.setAttribute(n,
-                    new Attribute("Caption","I am a new wombat!"));
-            final Notification notif = notifs.poll(4, TimeUnit.SECONDS);
-            if (!notif.getSource().equals(n))
-                throw new Exception("Bad source for "+ notif);
-            if (fail.size() > 0)
-                throw new Exception("Failed to handle notif",fail.remove(0));
-        }
-
-        // Check that we didn't get more notifs than expected
-        if (notifs.size() > 0)
-            throw new Exception("Extra notifications in queue: "+notifs);
-
-        // Check that if the MBean doesn't exist, we get InstanceNotFound.
-        try {
-            vserver.addNotificationListener(new ObjectName("toto:toto=toto"),
-                    handler, null, null);
-            throw new Exception("toto:toto=toto doesn't throw INFE");
-        } catch (InstanceNotFoundException x) {
-            System.out.println("Received "+x+" as expected.");
-        }
-
-        // For those MBeans that shouldn't be NotificationEmitters, check that
-        // we get IllegalArgumentException
-        for (ObjectName n : shielded) {
-            try {
-                vserver.addNotificationListener(n, handler, null, n);
-            } catch (RuntimeOperationsException x) {
-                System.out.println("Received "+x+" as expected.");
-                System.out.println("Cause is: "+x.getCause());
-                if (!(x.getCause() instanceof IllegalArgumentException))
-                    throw new Exception("was expecting IllegalArgumentException cause. Got "+x.getCause(),x);
-            }
-        }
-
-        // Sanity check. Remove our listeners.
-        for (ObjectName n : emitters) {
-            vserver.removeNotificationListener(n, handler, null, n);
-        }
-
-        // That's it.
-        // Sanity check: we shouldn't have received any new notif.
-        if (notifs.size() > 0)
-            throw new Exception("Extra notifications in queue: "+notifs);
-        // The NotifListener shouldn't have logged any new exception.
-        if (fail.size() > 0)
-                throw new Exception("Failed to handle notif",fail.remove(0));
-    }
-
-    public static void main(String[] args) throws Exception {
-        // test with a regular MBeanServer (no VirtualMBeanServerSupport)
-        final MBeanServerWrapperFactory identity =
-                new MBeanServerWrapperFactory() {
-            public MBeanServer wrapMBeanServer(MBeanServer wrapped) {
-                return wrapped;
-            }
-        };
-        test(identity);
-        // test with no EventManager
-        test(VirtualMBeanServerTest.factory);
-        // test with VirtualEventManager
-        test(VirtualMBeanServerTest2.factory);
-    }
-}
--- a/test/javax/management/namespace/VirtualMBeanTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,409 +0,0 @@
-/*
- * 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 VirtualMBeanTest.java
- * @bug 5108776 5072476
- * @summary Test that Virtual MBeans can be implemented and emit notifs.
- * @author Eamonn McManus
- */
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationBroadcaster;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.RuntimeOperationsException;
-import javax.management.SendNotification;
-import javax.management.StandardEmitterMBean;
-import javax.management.StandardMBean;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.VirtualEventManager;
-import javax.management.namespace.MBeanServerSupport;
-import javax.management.timer.TimerMBean;
-
-// In this test, we check that the two main use case types for
-// MBeanServerSupport work correctly:
-// (1) as a special-purpose implementation of MBeanServer for a fixed number
-//     of MBeans (e.g. for QueryNotificationFilter)
-// (2) as an MBeanServer supporting Virtual MBeans.
-// In each case we are particularly interested in the notification behaviour.
-// We check that the behaviour is correct when calling addNotificationListener
-// (a) for an MBean that does not exist; (b) for an MBean that does exist but
-// is not a NotificationEmitter; and (c) for an MBean that exists and is
-// a NotificationEmitter.  We also check the degenerate and usual case
-// where the MBeanServerSupport subclass does not support notifications
-// at all.
-//
-// Each subclass will have an MBean called test:type=NotEmitter that
-// does not support addNotificationListener. If it also has MBeans called
-// test:type=Emitter,* then they are expected to support addNL. No subclass
-// will have any other MBeans, so in particular no subclass will have
-// test:type=Nonexistent.
-//
-public class VirtualMBeanTest {
-    static final ObjectName
-            nonExistentName, notEmitterName, emitterName1, emitterName2;
-    static {
-        try {
-            nonExistentName = new ObjectName("test:type=NonExistent");
-            notEmitterName = new ObjectName("test:type=NotEmitter");
-            emitterName1 = new ObjectName("test:type=Emitter,id=1");
-            emitterName2 = new ObjectName("test:type=Emitter,id=2");
-        } catch (MalformedObjectNameException e) {
-            throw new AssertionError(e);
-        }
-    }
-
-    static final StandardMBean.Options wrappedVisible = new StandardMBean.Options();
-    static {
-        wrappedVisible.setWrappedObjectVisible(true);
-    }
-
-    public static interface NothingMBean {}
-    public static class Nothing implements NothingMBean {}
-    public static class NothingNBS extends NotificationBroadcasterSupport
-            implements NothingMBean {}
-
-    // Class that has hardwired MBeans test:type=NotEmitter,
-    // test:type=Broadcaster, and test:type=Emitter.
-    private static class HardwiredMBS extends MBeanServerSupport
-            implements SendNotification {
-        private final DynamicMBean notEmitter =
-                new StandardMBean(new Nothing(), NothingMBean.class, wrappedVisible);
-        private final StandardEmitterMBean emitter1, emitter2;
-        {
-            NothingNBS nnbs1 = new NothingNBS();
-            emitter1 = new StandardEmitterMBean(
-                    nnbs1, NothingMBean.class, wrappedVisible, nnbs1);
-            NothingNBS nnbs2 = new NothingNBS();
-            emitter2 = new StandardEmitterMBean(
-                    nnbs2, NothingMBean.class, wrappedVisible, nnbs2);
-        }
-
-        private final Map<ObjectName, DynamicMBean> map =
-                new TreeMap<ObjectName, DynamicMBean>();
-        {
-            map.put(notEmitterName, notEmitter);
-            map.put(emitterName1, emitter1);
-            map.put(emitterName2, emitter2);
-        }
-
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            DynamicMBean mbean = map.get(name);
-            if (mbean != null)
-                return mbean;
-            else
-                throw new InstanceNotFoundException(name);
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            return map.keySet();
-        }
-
-        @Override
-        public String toString() {
-            return "Hardwired MBeanServerSupport";
-        }
-
-        public void sendNotification(Notification notification) {
-            emitter1.sendNotification(notification);
-            emitter2.sendNotification(notification);
-        }
-    }
-
-    // Class that has the notEmitter MBean but not either of the others, so does
-    // not support listeners.
-    private static class VirtualMBSWithoutListeners
-            extends MBeanServerSupport {
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            if (name.equals(notEmitterName)) {
-                return new StandardMBean(
-                        new Nothing(), NothingMBean.class, wrappedVisible);
-            } else
-                throw new InstanceNotFoundException(name);
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            return Collections.singleton(notEmitterName);
-        }
-
-        @Override
-        public String toString() {
-            return "Virtual MBeanServerSupport without listener support";
-        }
-    }
-
-    // Class that has the notEmitter and emitter MBeans as Virtual MBeans, using
-    // VirtualEventManager to handle listeners for the emitter MBean.  We
-    // implement the broadcaster MBean (which is a NotificationBroadcaster but
-    // not a NotificationEmitter) even though it's very hard to imagine a real
-    // use case where that would happen.
-    private static class VirtualMBSWithListeners
-            extends MBeanServerSupport implements SendNotification {
-        private final VirtualEventManager vem = new VirtualEventManager();
-
-        private static final List<ObjectName> names =
-                Arrays.asList(notEmitterName, emitterName1, emitterName2);
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            if (names.contains(name)) {
-                return new StandardMBean(
-                        new Nothing(), NothingMBean.class, wrappedVisible);
-            } else
-                throw new InstanceNotFoundException(name);
-        }
-
-        @Override
-        public NotificationEmitter getNotificationEmitterFor(
-                ObjectName name) throws InstanceNotFoundException {
-            if (name.equals(emitterName1) || name.equals(emitterName2))
-                return vem.getNotificationEmitterFor(name);
-            else if (name.equals(notEmitterName))
-                return null;
-            else
-                throw new InstanceNotFoundException(name);
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            return new TreeSet<ObjectName>(Arrays.asList(notEmitterName, emitterName2));
-        }
-
-        @Override
-        public String toString() {
-            return "Virtual MBeanServerSupport with listener support";
-        }
-
-        public void sendNotification(Notification notification) {
-            vem.publish(emitterName1, notification);
-            vem.publish(emitterName2, notification);
-        }
-    }
-
-    private static final MBeanServer[] vmbsss = {
-        new HardwiredMBS(),
-        new VirtualMBSWithoutListeners(),
-        new VirtualMBSWithListeners(),
-    };
-
-    public static void main(String[] args) throws Exception {
-        Exception lastEx = null;
-        for (MBeanServer vmbs : vmbsss) {
-            String testName = "\"" + vmbs + "\"";
-            System.out.println("===Test " + testName + "===");
-            try {
-                test(vmbs);
-            } catch (Exception e) {
-                System.out.println(
-                        "===Test " + testName + " failed with exception " + e);
-                StringWriter sw = new StringWriter();
-                PrintWriter pw = new PrintWriter(sw);
-                e.printStackTrace(pw);
-                pw.flush();
-                String es = sw.toString();
-                System.out.println("......" + es.replace("\n", "\n......"));
-                lastEx = e;
-            }
-        }
-        if (lastEx != null)
-            throw lastEx;
-        System.out.println("TEST PASSED");
-    }
-
-    private static class NothingListener implements NotificationListener {
-        public void handleNotification(Notification notification,
-                                       Object handback) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-    }
-
-    private static class QueueListener implements NotificationListener {
-        final BlockingQueue<Notification> queue =
-                new ArrayBlockingQueue<Notification>(10);
-
-        public void handleNotification(Notification notification,
-                                       Object handback) {
-            queue.add(notification);
-        }
-    }
-
-    private static void test(MBeanServer vmbs) throws Exception {
-        MBeanServer mmbs = MBeanServerFactory.newMBeanServer();
-        ObjectName namespaceName = new ObjectName("test//:type=JMXNamespace");
-        JMXNamespace namespace = new JMXNamespace(vmbs);
-        mmbs.registerMBean(namespace, namespaceName);
-        MBeanServer mbs = JMXNamespaces.narrowToNamespace(mmbs, "test");
-
-        Set<ObjectName> names = mbs.queryNames(null, null);
-        //names.remove(new ObjectName(":type=JMXNamespace"));
-
-        // Make sure that notEmitterName exists according to query...
-        System.out.println("Checking query");
-        if (!names.contains(notEmitterName))
-            throw new Exception("Bad query result: " + names);
-
-        // ...and according to getMBeanInfo
-        System.out.println("Checking getMBeanInfo(" + notEmitterName + ")");
-        MBeanInfo mbi = mbs.getMBeanInfo(notEmitterName);
-        if (mbi.getNotifications().length > 0)
-            throw new Exception("notEmitter has NotificationInfo");
-
-        // Make sure we get the right exception for getMBeanInfo on a
-        // non-existent MBean
-        System.out.println("Checking getMBeanInfo on a non-existent MBean");
-        try {
-            mbi = mbs.getMBeanInfo(nonExistentName);
-            throw new Exception("getMBI succeeded but should not have");
-        } catch (InstanceNotFoundException e) {
-        }
-
-        // Make sure we get the right exception for addNotificationListener on a
-        // non-existent MBean
-        System.out.println(
-                "Checking addNotificationListener on a non-existent MBean");
-        try {
-            mbs.addNotificationListener(
-                    nonExistentName, new NothingListener(), null, null);
-            throw new Exception("addNL succeeded but should not have");
-        } catch (InstanceNotFoundException e) {
-        }
-
-        // Make sure we get the right exception for isInstanceOf on a
-        // non-existent MBean
-        System.out.println(
-                "Checking isInstanceOf on a non-existent MBean");
-        for (Class<?> c : new Class<?>[] {
-            Object.class, NotificationBroadcaster.class, NotificationEmitter.class,
-        }) {
-            try {
-                boolean is = mbs.isInstanceOf(nonExistentName, c.getName());
-                throw new Exception(
-                        "isInstanceOf " + c.getName() +
-                        " succeeded but should not have");
-            } catch (InstanceNotFoundException e) {
-            }
-        }
-
-        // Make sure isInstanceOf works correctly for classes without special
-        // treatment
-        System.out.println(
-                "Checking isInstanceOf on normal classes");
-        for (ObjectName name : names) {
-            boolean isNothing = mbs.isInstanceOf(name, NothingMBean.class.getName());
-            if (!isNothing) {
-                throw new Exception("isInstanceOf " + NothingMBean.class.getName() +
-                        " returned false, should be true");
-            }
-            boolean isTimer = mbs.isInstanceOf(name, TimerMBean.class.getName());
-            if (isTimer) {
-                throw new Exception("isInstanceOf " + TimerMBean.class.getName() +
-                        " returned true, should be false");
-            }
-        }
-
-        // Make sure that addNL on notEmitterName gets the right exception
-        System.out.println("Checking addNL on non-broadcaster");
-        try {
-            mbs.addNotificationListener(
-                    notEmitterName, new NothingListener(), null, null);
-            throw new Exception("addNL succeeded but should not have");
-        } catch (RuntimeOperationsException e) {
-            if (!(e.getCause() instanceof IllegalArgumentException))
-                throw new Exception("Wrong exception from addNL", e);
-        }
-
-        if (!(vmbs instanceof SendNotification)) {
-            System.out.println("Not testing notifications for this implementation");
-            return;
-        }
-
-        QueueListener qListener = new QueueListener();
-
-        System.out.println("Testing addNL on emitters");
-        mbs.addNotificationListener(emitterName1, qListener, null, null);
-        mbs.addNotificationListener(emitterName2, qListener, null, null);
-
-        System.out.println("Testing that listeners work");
-        Notification notif = new Notification("notif.type", "source", 0L);
-
-        ((SendNotification) vmbs).sendNotification(notif);
-        testListeners(qListener, "notif.type", 2);
-
-        System.out.println("Testing 2-arg removeNL on emitter1");
-        mbs.removeNotificationListener(emitterName1, qListener);
-
-        ((SendNotification) vmbs).sendNotification(notif);
-        testListeners(qListener, "notif.type", 1);
-
-        System.out.println("Testing 4-arg removeNL on emitter2");
-        mbs.removeNotificationListener(emitterName2, qListener, null, null);
-
-        ((SendNotification) vmbs).sendNotification(notif);
-        testListeners(qListener, "notif.type", 0);
-    }
-
-    private static void testListeners(
-            QueueListener qListener, String expectedNotifType, int expectedNotifs)
-            throws Exception {
-        for (int i = 1; i <= expectedNotifs; i++) {
-            Notification rNotif = qListener.queue.poll(1, TimeUnit.SECONDS);
-            if (rNotif == null)
-                throw new Exception("Notification " + i + " never arrived");
-            if (!rNotif.getType().equals(expectedNotifType))
-                throw new Exception("Wrong type notif: " + rNotif.getType());
-        }
-        Notification xNotif = qListener.queue.poll(10, TimeUnit.MILLISECONDS);
-        if (xNotif != null)
-            throw new Exception("Extra notif: " + xNotif);
-    }
-}
--- a/test/javax/management/namespace/VirtualNamespaceQueryTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * 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 VirtualNamespaceQueryTest.java
- * @summary General VirtualNamespaceQueryTest test.
- * @author Daniel Fuchs
- * @bug 5072476
- * @run clean VirtualNamespaceQueryTest Wombat WombatMBean
- *            NamespaceController NamespaceControllerMBean
- *            JMXRemoteTargetNamespace
- * @compile -XDignore.symbol.file=true VirtualNamespaceQueryTest.java
- *          Wombat.java WombatMBean.java
- *          NamespaceController.java NamespaceControllerMBean.java
- *          JMXRemoteTargetNamespace.java
- * @run main VirtualNamespaceQueryTest
- */
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Set;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.NotificationEmitter;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.MBeanServerSupport;
-
-/**
- *
- * @author dfuchs
- */
-public class VirtualNamespaceQueryTest {
-    public static class WombatRepository extends MBeanServerSupport {
-        final Wombat wombat;
-        final StandardMBean mbean;
-        final ObjectName wombatName;
-
-        public WombatRepository(ObjectName wombatName) {
-            try {
-                wombat = new Wombat();
-                mbean  = wombat;
-                this.wombatName = wombatName;
-                wombat.preRegister(null,wombatName);
-            } catch (Exception x) {
-                throw new IllegalArgumentException(x);
-            }
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-            throws InstanceNotFoundException {
-            if (wombatName.equals(name)) return mbean;
-            else throw new InstanceNotFoundException(String.valueOf(name));
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            final Set<ObjectName> res = Collections.singleton(wombatName);
-            return res;
-        }
-
-        @Override
-        public NotificationEmitter getNotificationEmitterFor(
-                ObjectName name) throws InstanceNotFoundException {
-            DynamicMBean mb = getDynamicMBeanFor(name);
-            if (mb instanceof NotificationEmitter)
-                return (NotificationEmitter)mb;
-            return null;
-        }
-    }
-    public static class WombatNamespace extends JMXNamespace {
-        public WombatNamespace(ObjectName wombatName) {
-            super(new WombatRepository(wombatName));
-        }
-    }
-
-    public static void simpleTest() throws Exception {
-        final MBeanServer  server = MBeanServerFactory.newMBeanServer();
-        final ObjectName   wombatName = new ObjectName("burrow:type=Wombat");
-        final JMXNamespace ns = new WombatNamespace(wombatName);
-        server.registerMBean(ns, JMXNamespaces.getNamespaceObjectName("wombats"));
-        final Set<ObjectName> dirs =
-                server.queryNames(new ObjectName("wombats//*//:type=JMXNamespace"),
-                wombatName);
-        System.out.println("all dirs: "+dirs);
-        if (dirs.size()>0)
-            throw new RuntimeException("Unexpected ObjectNames returned: "+dirs);
-
-        final ObjectInstance inst = NamespaceController.createInstance(server);
-        final NamespaceControllerMBean controller =
-                JMX.newMBeanProxy(server, inst.getObjectName(),
-                NamespaceControllerMBean.class);
-        final String[] dirNames = controller.findNamespaces(null,null,2);
-        System.err.println(Arrays.toString(dirNames));
-    }
-
-    public static void main(String[] args) throws Exception {
-        simpleTest();
-    }
-}
--- a/test/javax/management/namespace/VirtualPropsTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-/*
- * 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 5108776 5072476
- * @summary Test the properties use case for Virtual MBeans that is documented
- * in MBeanServerSupport.
- * @author Eamonn McManus
- */
-
-import java.lang.management.ManagementFactory;
-import java.util.Properties;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.VirtualEventManager;
-import javax.management.namespace.MBeanServerSupport;
-
-public class VirtualPropsTest {
-    public static interface PropertyMBean {
-        public String getValue();
-    }
-
-    public static class PropsMBS extends MBeanServerSupport {
-        private static ObjectName newObjectName(String name) {
-            try {
-                return new ObjectName(name);
-            } catch (MalformedObjectNameException e) {
-                throw new AssertionError(e);
-            }
-        }
-
-        public static class PropertyImpl implements PropertyMBean {
-            private final String name;
-
-            public PropertyImpl(String name) {
-                this.name = name;
-            }
-
-            public String getValue() {
-                return System.getProperty(name);
-            }
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            ObjectName namePattern = newObjectName(
-                        "com.example:type=Property,name=\"*\"");
-            if (!namePattern.apply(name))
-                throw new InstanceNotFoundException(name);
-
-            String propName = ObjectName.unquote(name.getKeyProperty("name"));
-            if (System.getProperty(propName) == null)
-                throw new InstanceNotFoundException(name);
-            PropertyMBean propMBean = new PropertyImpl(propName);
-            return new StandardMBean(propMBean, PropertyMBean.class, false);
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            Set<ObjectName> names = new TreeSet<ObjectName>();
-            Properties props = System.getProperties();
-            for (String propName : props.stringPropertyNames()) {
-                ObjectName objectName = newObjectName(
-                        "com.example:type=Property,name=" +
-                        ObjectName.quote(propName));
-                names.add(objectName);
-            }
-            return names;
-        }
-
-        private final VirtualEventManager vem = new VirtualEventManager();
-
-        @Override
-        public NotificationEmitter getNotificationEmitterFor(
-                ObjectName name) throws InstanceNotFoundException {
-            getDynamicMBeanFor(name);  // check that the name is valid
-            return vem.getNotificationEmitterFor(name);
-        }
-
-        public void propertyChanged(String name, String newValue) {
-            ObjectName objectName = newObjectName(
-                    "com.example:type=Property,name=" + ObjectName.quote(name));
-            Notification n = new Notification(
-                    "com.example.property.changed", objectName, 0L,
-                    "Property " + name + " changed");
-            n.setUserData(newValue);
-            vem.publish(objectName, n);
-        }
-    }
-
-    static class QueueListener implements NotificationListener {
-        BlockingQueue<Notification> q = new ArrayBlockingQueue<Notification>(10);
-        public void handleNotification(Notification notification,
-                                       Object handback) {
-            q.add(notification);
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mmbs = ManagementFactory.getPlatformMBeanServer();
-        String namespace = "props";
-        PropsMBS pmbs = new PropsMBS();
-        Object namespaceMBean = new JMXNamespace(pmbs);
-        mmbs.registerMBean(namespaceMBean, new ObjectName(
-                namespace + "//:type=JMXNamespace"));
-        MBeanServer mbs = JMXNamespaces.narrowToNamespace(mmbs, namespace);
-
-        Properties props = System.getProperties();
-
-        int nprops = props.stringPropertyNames().size();
-        if (nprops != mbs.getMBeanCount()) {
-            throw new Exception(String.format("Properties: %d; MBeans: %d",
-                    nprops, mbs.getMBeanCount()));
-        }
-
-        for (String propName : props.stringPropertyNames()) {
-            ObjectName propObjectName = new ObjectName(
-                    "com.example:type=Property,name=" + ObjectName.quote(propName));
-            PropertyMBean propProx = JMX.newMBeanProxy(
-                    mbs, propObjectName, PropertyMBean.class);
-            String propValue = propProx.getValue();
-            String realPropValue = props.getProperty(propName);
-            if (!realPropValue.equals(propValue)) {
-                throw new Exception(String.format("Property %s: value is \"%s\"; " +
-                        "mbean says \"%s\"", propName, realPropValue, propValue));
-            }
-        }
-
-        ObjectName fooPropObjectName =
-                new ObjectName("com.example:type=Property,name=\"java.home\"");
-        QueueListener ql = new QueueListener();
-        mbs.addNotificationListener(fooPropObjectName, ql, null, null);
-        pmbs.propertyChanged("java.home", "bar");
-        Notification n = ql.q.poll(1, TimeUnit.SECONDS);
-        if (n == null)
-            throw new Exception("Notif didn't arrive");
-        if (!"bar".equals(n.getUserData()))
-            throw new Exception("Bad user data: " + n.getUserData());
-
-        System.out.println("TEST PASSED");
-    }
-}
--- a/test/javax/management/namespace/Wombat.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,259 +0,0 @@
-/*
- * 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.Random;
-import java.util.Set;
-import javax.management.AttributeChangeNotification;
-import javax.management.ListenerNotFoundException;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanNotificationInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.NotificationBroadcasterSupport;
-import javax.management.NotificationEmitter;
-import javax.management.NotificationFilter;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-
-/**
- * Dynamic MBean based on StandardMBean
- * Class Wombat
- * Wombat Description
- * @author dfuchs
- */
-public class Wombat extends StandardMBean
-        implements WombatMBean, NotificationEmitter, MBeanRegistration {
-
-    /**
-     * Attribute : Caption
-     */
-    private String caption = "I'm a wombat";
-
-    private final long MAX_SEED = 36000;
-    private final long seed;
-    private final long period;
-    private volatile int mood = 0;
-
-    public int getMood() {
-        final long  degree = seed + (System.currentTimeMillis()/period)%MAX_SEED;
-        final double angle = ((double)degree)/100;
-        mood = (int)(100.0*Math.sin(angle));
-        return mood;
-    }
-
-    public Wombat() throws NotCompliantMBeanException {
-        this(WombatMBean.class);
-    }
-
-    public Wombat(Class<? extends WombatMBean> clazz)
-            throws NotCompliantMBeanException {
-        super(clazz);
-        final Random r = new Random();
-        seed = ((r.nextLong() % MAX_SEED) + MAX_SEED)%MAX_SEED;
-        period = 200 + (((r.nextLong()%80)+80)%80)*10;
-    }
-
-    /**
-     * Next are the methods to compute MBeanInfo.
-     * You shouldn't update these methods.
-     */
-    @Override
-    protected String getDescription(MBeanInfo info) {
-        return "Wombats are strange beasts. You will find them down under " +
-                "and in some computer programms.";
-    }
-
-    @Override
-    protected String getDescription(MBeanAttributeInfo info) {
-        String description = null;
-        if (info.getName().equals("Caption")) {
-            description = "A simple caption to describe a wombat";
-        }
-        if (info.getName().equals("Mood")) {
-            description = "This Wombat's mood on a [-100,+100] scale."+
-                      " -100 means that this wombat is very angry.";
-        }
-        return description;
-    }
-
-    @Override
-    protected String getDescription(MBeanOperationInfo op,
-            MBeanParameterInfo param,
-            int sequence) {
-        return null;
-    }
-
-    @Override
-    protected String getParameterName(MBeanOperationInfo op,
-            MBeanParameterInfo param,
-            int sequence) {
-        return null;
-    }
-
-    @Override
-    protected String getDescription(MBeanOperationInfo info) {
-        String description = null;
-        return description;
-    }
-
-    @Override
-    public MBeanInfo getMBeanInfo() {
-        MBeanInfo mbinfo = super.getMBeanInfo();
-        return new MBeanInfo(mbinfo.getClassName(),
-                mbinfo.getDescription(),
-                mbinfo.getAttributes(),
-                mbinfo.getConstructors(),
-                mbinfo.getOperations(),
-                getNotificationInfo());
-    }
-
-    /**
-     * Get A simple caption to describe a wombat
-     */
-    public synchronized String getCaption() {
-        return caption;
-    }
-
-    /**
-     * Set A simple caption to describe a wombat
-     */
-    public void setCaption(String value) {
-        final String oldValue;
-        synchronized (this) {
-            oldValue = caption;
-            caption = value;
-        }
-        final AttributeChangeNotification notif =
-                new AttributeChangeNotification(objectName,
-                    getNextSeqNumber(),
-                    System.currentTimeMillis(),
-                    "Caption changed","Caption",
-                    String.class.getName(),oldValue,value);
-        broadcaster.sendNotification(notif);
-    }
-
-    /**
-     * MBeanNotification support
-     * You shouldn't update these methods
-     */
-    public void addNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws IllegalArgumentException {
-        broadcaster.addNotificationListener(listener, filter, handback);
-    }
-
-    public MBeanNotificationInfo[] getNotificationInfo() {
-        return new MBeanNotificationInfo[] {
-            new MBeanNotificationInfo(new String[] {
-                AttributeChangeNotification.ATTRIBUTE_CHANGE},
-                javax.management.AttributeChangeNotification.class.getName(),
-                "Sent when the caption changes")
-            };
-    }
-
-    public void removeNotificationListener(NotificationListener listener) throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener);
-    }
-
-    public void removeNotificationListener(NotificationListener listener, NotificationFilter filter, Object handback) throws ListenerNotFoundException {
-        broadcaster.removeNotificationListener(listener, filter, handback);
-    }
-
-    private synchronized long getNextSeqNumber() {
-        return seqNumber++;
-    }
-
-    private long seqNumber;
-
-    private final NotificationBroadcasterSupport broadcaster = new NotificationBroadcasterSupport();
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * registered in the MBean server. If the name of the MBean is not
-     * specified, the MBean can provide a name for its registration. If
-     * any exception is raised, the MBean will not be registered in the
-     * MBean server.
-     * @param server The MBean server in which the MBean will be registered.
-     * @param name The object name of the MBean. This name is null if the
-     * name parameter to one of the createMBean or registerMBean methods in
-     * the MBeanServer interface is null. In that case, this method must
-     * return a non-null ObjectName for the new MBean.
-     * @return The name under which the MBean is to be registered. This value
-     * must not be null. If the name parameter is not null, it will usually
-     * but not necessarily be the returned value.
-     * @throws Exception This exception will be caught by the MBean server and
-     * re-thrown as an MBeanRegistrationException.
-     */
-    @Override
-    public ObjectName preRegister(MBeanServer server, ObjectName name)
-            throws Exception {
-        objectName = name;
-        mbeanServer = server;
-        return super.preRegister(server, name);
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having
-     * been registered in the MBean server or after the registration has
-     * failed.
-     * @param registrationDone Indicates wether or not the MBean has been
-     * successfully registered in the MBean server. The value false means
-     * that the registration has failed.
-     */
-    @Override
-    public void postRegister(Boolean registrationDone) {
-        super.postRegister(registrationDone);
-    }
-
-    /**
-     * Allows the MBean to perform any operations it needs before being
-     * unregistered by the MBean server.
-     * @throws Exception This exception will be caught by the MBean server and
-     * re-thrown as an MBeanRegistrationException.
-     */
-    @Override
-    public void preDeregister() throws Exception {
-        super.preDeregister();
-    }
-
-    /**
-     * Allows the MBean to perform any operations needed after having been
-     * unregistered in the MBean server.
-     */
-    @Override
-    public void postDeregister() {
-        super.postDeregister();
-    }
-
-    public Set<ObjectName> listMatching(ObjectName pattern) {
-        return mbeanServer.queryNames(pattern, null);
-    }
-
-    private MBeanServer mbeanServer;
-
-    private ObjectName objectName;
-}
--- a/test/javax/management/namespace/WombatMBean.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,59 +0,0 @@
-
-/*
- * 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.Set;
-import javax.management.ObjectName;
-
-/**
- * Interface WombatMBean
- * Wombat Description
- * @author dfuchs
- */
-public interface WombatMBean
-{
-    /**
-     * This Wombat's mood on a [-100,+100] scale.
-     * -100 means that this wombat is very angry.
-     * @return The wombat's mood.
-     */
-    public int getMood();
-
-    /**
-     * Get A simple caption to describe a wombat
-     */
-    public String getCaption();
-
-    /**
-     * Set A simple caption to describe a wombat
-     */
-    public void setCaption(String value);
-
-    /**
-     * List matching MBeans in the same server.
-     * @param pattern an ObjectName pattern or null.
-     * @return A list of matching MBeans.
-     */
-    public Set<ObjectName> listMatching(ObjectName pattern);
-
-}
--- a/test/javax/management/namespace/namespace.policy	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-grant codebase "file:/-" {
-    permission java.util.PropertyPermission "jmx.wait", "read";
-    permission java.util.PropertyPermission "jmx.rmi.port", "read";
-    permission java.net.SocketPermission "*", "accept,connect,resolve";
-    permission java.security.SecurityPermission "*";
-
-    // Attribute Caption: allow get everywhere
-    // ==================
-
-    // allow getAttribute(*:*,Caption) in all MBeanServers
-    permission javax.management.MBeanPermission "#Caption", "getAttribute";
-    // allow getAttribute(*:*,Caption) in all namespaces recursively.
-    permission javax.management.namespace.JMXNamespacePermission "Caption",
-               "getAttribute";
-
-    // Attribute Mood: allow get only in MBeanServers named rmi*
-    // ===============
-
-    // allow to get attribute Mood of Wombat MBeans only in namespaces
-    // whose name match rmi*, wherever they are.
-    // for this we need two permissions:
-    permission javax.management.namespace.JMXNamespacePermission
-               "*::Mood[**//rmi*//wombat:*]",
-               "getAttribute";
-    permission javax.management.namespace.JMXNamespacePermission
-               "*::Mood[rmi*//wombat:*]",
-               "getAttribute";
-
-    // allow to get attribute mood in any MBeanServer whose name starts with
-    // rmi
-    permission javax.management.MBeanPermission "rmi*::#Mood",
-               "getAttribute";
-
-    // Attribute UUID:
-    // ===============
-
-    // allow to get attribute "UUID" everywhere.
-    permission javax.management.namespace.JMXNamespacePermission
-               "*::UUID[*//**//:*]",
-               "getAttribute";
-    permission javax.management.MBeanPermission
-               "#UUID[*//:*]",
-               "getAttribute";
-
-
-
-    // Let getMBeanInfo and queryNames through everywhere...
-    //
-    permission javax.management.namespace.JMXNamespacePermission "[]",
-               "getMBeanInfo,queryNames";
-    permission javax.management.MBeanPermission "*",
-               "getMBeanInfo,queryNames";
-
-    // special permission for all wombats:
-    //
-    permission javax.management.namespace.JMXNamespacePermission
-               "[**//*:type=Wombat,*]",
-               "getObjectInstance,isInstanceOf,queryMBeans";
-    permission javax.management.MBeanPermission "[*:type=Wombat,*]",
-               "getObjectInstance,isInstanceOf,queryMBeans";
-
-    // allow JMXNamespace::getDefaultDomain
-    permission javax.management.namespace.JMXNamespacePermission
-               "*::DefaultDomain",
-               "getAttribute";
-
-    // These permissions are required to connect visualvm.
-    //
-    permission javax.management.MBeanPermission "default::[java.lang:*]",
-               "getObjectInstance,isInstanceOf,getAttribute,getMBeanInfo,queryNames,queryMBeans";
-    permission javax.management.MBeanPermission "root::",
-               "isInstanceOf,queryNames,queryMBeans,getAttribute,getMBeanInfo,getObjectInstance,getDomains";
-    permission javax.management.namespace.JMXNamespacePermission
-               "[**//JMImplementation:type=MBeanServerDelegate]",
-               "addNotificationListener,removeNotificationListener,isInstanceOf,queryNames,queryMBeans,getAttribute,getMBeanInfo,getObjectInstance";
-    permission javax.management.MBeanPermission
-               "javax.management.MBeanServerDelegate",
-               "addNotificationListener,removeNotificationListener,isInstanceOf,queryNames,queryMBeans,getAttribute,getMBeanInfo,getObjectInstance";
-
-    // Thread monitoring
-    permission java.lang.management.ManagementPermission "monitor";
-    permission javax.management.MBeanPermission "*::sun.management.*#*[java.lang:*]", "invoke";
-};
-
-
--- a/test/javax/management/notification/SupportClearTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 6336980
- * @summary test 2 new methods: isListenedTo() and clear()
- * @author Shanliang JIANG
- * @run clean SupportClearTest
- * @run build SupportClearTest
- * @run main SupportClearTest
- */
-
-import javax.management.*;
-
-public class SupportClearTest {
-    private static boolean received = false;
-
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> test 2 new methods: isListenedTo() and clear().");
-
-        final NotificationListener listener = new NotificationListener() {
-                public void handleNotification(Notification n, Object hb) {
-                    received = true;
-                }
-            };
-
-        final NotificationBroadcasterSupport broadcaster =
-                new NotificationBroadcasterSupport();
-
-        System.out.println(">>> testing the method \"isListenedTo\"...");
-        if (broadcaster.isListenedTo()) {
-            throw new RuntimeException(
-                    "Bad implementation of the method \"isListenedTo\"!");
-        }
-
-        broadcaster.addNotificationListener(listener, null, null);
-
-        if (!broadcaster.isListenedTo()) {
-            throw new RuntimeException(
-                    "Bad implementation of the method \"isListenedTo\"!");
-        }
-
-        System.out.println(">>> testing the method \"clear\"...");
-        broadcaster.removeAllNotificationListeners();
-        if (broadcaster.isListenedTo()) {
-            throw new RuntimeException(
-                    "Bad implementation of the method \"clear\"!");
-        }
-
-        broadcaster.sendNotification(new Notification("", "", 1L));
-
-        if (received) {
-            throw new RuntimeException(
-                    "Bad implementation of the method \"clear\"!");
-        }
-
-        System.out.println(">>> PASSED!");
-    }
-}
--- a/test/javax/management/openmbean/CompositeDataToMapTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * 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 6750472 6752563
- * @summary Test CompositeDataSupport.toMap.
- * @author Eamonn McManus
- * @run main/othervm -ea CompositeDataToMapTest
- */
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
-public class CompositeDataToMapTest {
-    private static class IdentityInvocationHandler implements InvocationHandler {
-        private final Object wrapped;
-
-        public IdentityInvocationHandler(Object wrapped) {
-            this.wrapped = wrapped;
-        }
-
-        public Object invoke(Object proxy, Method m, Object[] args)
-                throws Throwable {
-            try {
-                return m.invoke(wrapped, args);
-            } catch (InvocationTargetException e) {
-                throw e.getCause();
-            }
-        }
-    }
-
-    private static <T> T wrap(T x, Class<T> intf) {
-        InvocationHandler ih = new IdentityInvocationHandler(x);
-        return intf.cast(Proxy.newProxyInstance(
-                intf.getClassLoader(), new Class<?>[] {intf}, ih));
-    }
-
-    public static void main(String[] args) throws Exception {
-        if (!CompositeDataToMapTest.class.desiredAssertionStatus())
-            throw new AssertionError("Must be run with -ea");
-
-        CompositeType emptyCT = new CompositeType(
-                "empty", "empty", new String[0], new String[0], new OpenType<?>[0]);
-        CompositeData emptyCD = new CompositeDataSupport(
-                emptyCT, Collections.<String, Object>emptyMap());
-        assert CompositeDataSupport.toMap(emptyCD).isEmpty() :
-            "Empty CD produces empty Map";
-
-        CompositeData emptyCD2 = new CompositeDataSupport(
-                emptyCT, new String[0], new Object[0]);
-        assert emptyCD.equals(emptyCD2) : "Empty CD can be constructed two ways";
-
-        CompositeType namedNumberCT = new CompositeType(
-                "NamedNumber", "NamedNumber",
-                new String[] {"name", "number"},
-                new String[] {"name", "number"},
-                new OpenType<?>[] {SimpleType.STRING, SimpleType.INTEGER});
-        Map<String, Object> namedNumberMap = new HashMap<String, Object>();
-        namedNumberMap.put("name", "Deich");
-        namedNumberMap.put("number", 10);
-        CompositeData namedNumberCD = new CompositeDataSupport(
-                namedNumberCT, namedNumberMap);
-        assert CompositeDataSupport.toMap(namedNumberCD).equals(namedNumberMap) :
-            "Map survives passage through CompositeData";
-
-        namedNumberCD = wrap(namedNumberCD, CompositeData.class);
-        assert CompositeDataSupport.toMap(namedNumberCD).equals(namedNumberMap) :
-            "Map survives passage through wrapped CompositeData";
-
-        namedNumberMap = CompositeDataSupport.toMap(namedNumberCD);
-        namedNumberMap.put("name", "Ceathar");
-        namedNumberMap.put("number", 4);
-        namedNumberCD = new CompositeDataSupport(namedNumberCT, namedNumberMap);
-        assert CompositeDataSupport.toMap(namedNumberCD).equals(namedNumberMap) :
-            "Modified Map survives passage through CompositeData";
-
-        try {
-            namedNumberMap = CompositeDataSupport.toMap(null);
-            assert false : "Null toMap arg provokes exception";
-        } catch (Exception e) {
-            assert e instanceof IllegalArgumentException :
-                "Exception for null toMap arg is IllegalArgumentException";
-        }
-    }
-}
--- a/test/javax/management/openmbean/GenericMBeanExceptionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,278 +0,0 @@
-/*
- * 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 6456269
- * @summary Test GenericMBeanException
- * @author Eamonn McManus
- */
-
-import java.beans.ConstructorProperties;
-import java.lang.management.ManagementFactory;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import javax.management.GenericMBeanException;
-import javax.management.JMX;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.MXBeanMapping;
-import javax.management.openmbean.MXBeanMappingFactory;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class GenericMBeanExceptionTest {
-    private static volatile String failure = null;
-
-    public static interface ThrowerMBean {
-        public void throwGeneric() throws GenericMBeanException;
-        public void throwGeneric(Throwable cause) throws GenericMBeanException;
-        public void throwGeneric(String errorCode) throws GenericMBeanException;
-        public void throwGeneric(CompositeData userData) throws GenericMBeanException;
-        public void throwGeneric(String errorCode, CompositeData userData)
-                throws GenericMBeanException;
-        public void throwGeneric(String errorCode, CompositeData userData, Throwable cause)
-                throws GenericMBeanException;
-    }
-
-    public static class Thrower implements ThrowerMBean {
-
-        public void throwGeneric() throws GenericMBeanException {
-            throw new GenericMBeanException("Message");
-        }
-
-        public void throwGeneric(Throwable cause) throws GenericMBeanException {
-            throw new GenericMBeanException("Message", cause);
-        }
-
-        public void throwGeneric(String errorCode) throws GenericMBeanException {
-            throw new GenericMBeanException("Message", errorCode, null);
-        }
-
-        public void throwGeneric(CompositeData userData) throws GenericMBeanException {
-            throw new GenericMBeanException("Message", null, userData);
-        }
-
-        public void throwGeneric(String errorCode, CompositeData userData)
-                throws GenericMBeanException {
-            throw new GenericMBeanException("Message", errorCode, userData);
-        }
-
-        public void throwGeneric(String errorCode, CompositeData userData,
-                                 Throwable cause) throws GenericMBeanException {
-            throw new GenericMBeanException("Message", errorCode, userData, cause);
-        }
-    }
-
-    public static class Payload {
-        private final int severity;
-        private final String subsystem;
-
-        @ConstructorProperties({"severity", "subsystem"})
-        public Payload(int severity, String subsystem) {
-            this.severity = severity;
-            this.subsystem = subsystem;
-        }
-
-        public int getSeverity() {
-            return severity;
-        }
-
-        public String getSubsystem() {
-            return subsystem;
-        }
-
-        @Override
-        public boolean equals(Object x) {
-            if (!(x instanceof Payload))
-                return false;
-            Payload p = (Payload) x;
-            return (severity == p.severity &&
-                    (subsystem == null) ?
-                        p.subsystem == null : subsystem.equals(p.subsystem));
-        }
-
-        @Override
-        public int hashCode() {
-            return severity + subsystem.hashCode();
-        }
-
-        @Override
-        public String toString() {
-            return "Payload{severity: " + severity + ", subsystem: " + subsystem + "}";
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-        ObjectName name = new ObjectName("test:type=Thrower");
-        Thrower thrower = new Thrower();
-        mbs.registerMBean(thrower, name);
-
-        if (args.length > 0) {
-            System.out.println("Attach client now, hit return to exit");
-            System.in.read();
-            return;
-        }
-
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
-        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
-                url, null, mbs);
-        cs.start();
-        JMXServiceURL addr = cs.getAddress();
-
-        JMXConnector cc = JMXConnectorFactory.connect(addr);
-        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-
-        ThrowerMBean throwerProxy = JMX.newMBeanProxy(mbsc, name, ThrowerMBean.class);
-
-        Payload payload = new Payload(5, "modular modulizer");
-        MXBeanMapping payloadMapping = MXBeanMappingFactory.DEFAULT.mappingForType(
-                Payload.class, MXBeanMappingFactory.DEFAULT);
-        CompositeData userData = (CompositeData)
-                payloadMapping.toOpenValue(payload);
-        Throwable cause = new IllegalArgumentException("Badness");
-
-        Object[][] testCases = {
-            {},
-            {"code1"},
-            {userData},
-            {"code2", userData},
-            {(String) null, userData},
-            {"code99", userData, cause},
-            {(String) null, userData, cause},
-        };
-
-        for (Object[] testCase : testCases) {
-            System.out.println("Test case: " + testCaseString(testCase));
-
-            // Find which ThrowerMBean method it corresponds to
-            Method testMethod = null;
-search:
-            for (Method m : ThrowerMBean.class.getMethods()) {
-                Class<?>[] paramTypes = m.getParameterTypes();
-                if (paramTypes.length != testCase.length)
-                    continue;
-                for (int i = 0; i < paramTypes.length; i++) {
-                    if (testCase[i] != null && !paramTypes[i].isInstance(testCase[i]))
-                        continue search;
-                }
-                testMethod = m;
-            }
-
-            if (testMethod == null) {
-                throw new Exception("TEST ERROR: no method corresponds: " +
-                        testCaseString(testCase));
-            }
-
-            try {
-                testMethod.invoke(throwerProxy, testCase);
-                fail("Did not throw exception", testCase);
-                continue;
-            } catch (InvocationTargetException e) {
-                Throwable iteCause = e.getCause();
-                if (!(iteCause instanceof GenericMBeanException)) {
-                    iteCause.printStackTrace(System.out);
-                    fail("Threw wrong exception " + iteCause, testCase);
-                    continue;
-                }
-                GenericMBeanException ge = (GenericMBeanException) iteCause;
-                if (!ge.getMessage().equals("Message"))
-                    fail("Wrong message: " + ge.getMessage(), testCase);
-
-                Class<?>[] paramTypes = testMethod.getParameterTypes();
-                for (int i = 0; i < paramTypes.length; i++) {
-                    Class<?> paramType = paramTypes[i];
-
-                    if (paramType == Throwable.class) { // cause
-                        Throwable geCause = ge.getCause();
-                        if (!(geCause instanceof IllegalArgumentException))
-                            fail("Wrong cause: " + geCause, testCase);
-                        else if (!geCause.getMessage().equals("Badness"))
-                            fail("Wrong cause message: " + geCause.getMessage(), testCase);
-                    } else if (paramType == String.class) { // errorCode
-                        String errorCode = ge.getErrorCode();
-                        String expectedErrorCode =
-                                (testCase[i] == null) ? "" : (String) testCase[i];
-                        if (!expectedErrorCode.equals(errorCode))
-                            fail("Wrong error code: " + ge.getErrorCode(), testCase);
-                    } else if (paramType == CompositeData.class) { // userData
-                        CompositeData userData2 = ge.getUserData();
-                        if (!userData.equals(userData2))
-                            fail("Wrong userData: " + userData2, testCase);
-                        Payload payload2 = (Payload) payloadMapping.fromOpenValue(userData2);
-                        if (!payload.equals(payload2))
-                            fail("Wrong payload: " + payload2, testCase);
-                    } else
-                        throw new Exception("TEST ERROR: unknown parameter type: " + paramType);
-                }
-            }
-        }
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static String testCaseString(Object[] testCase) {
-        StringBuilder sb = new StringBuilder("[");
-        String sep = "";
-        for (Object x : testCase) {
-            sb.append(sep);
-            String xs = (x instanceof CompositeData) ?
-                compositeDataString((CompositeData) x) : String.valueOf(x);
-            sb.append(xs);
-            sep = ", ";
-        }
-        sb.append("]");
-        return sb.toString();
-    }
-
-    private static String compositeDataString(CompositeData cd) {
-        StringBuilder sb = new StringBuilder("CompositeData{");
-        CompositeType ct = cd.getCompositeType();
-        String sep = "";
-        for (String key : ct.keySet()) {
-            sb.append(sep).append(key).append(": ").append(cd.get(key));
-            sep = ", ";
-        }
-        sb.append("}");
-        return sb.toString();
-    }
-
-    private static void fail(String why, Object[] testCase) {
-        fail(testCaseString(testCase) + ": " + why);
-    }
-
-    private static void fail(String why) {
-        failure = why;
-        System.out.println("FAIL: " + why);
-    }
-}
--- a/test/javax/management/query/QueryDottedAttrTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,192 +0,0 @@
-/*
- * 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 QueryDottedAttrTest
- * @bug 6602310
- * @summary Test that Query.attr can understand a.b etc.
- * @author Eamonn McManus
- */
-
-import java.beans.ConstructorProperties;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Collections;
-import java.util.Set;
-import javax.management.AttributeNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
-import javax.management.ReflectionException;
-import javax.management.StandardMBean;
-
-public class QueryDottedAttrTest {
-    public static class Complex {
-        private final double re, im;
-
-        @ConstructorProperties({"real", "imaginary"})
-        public Complex(double re, double im) {
-            this.re = re;
-            this.im = im;
-        }
-
-        public double getRe() {
-            return re;
-        }
-
-        public double getIm() {
-            return im;
-        }
-    }
-
-    public static interface Intf {
-        Complex getComplex();
-        int[] getIntArray();
-        String[] getStringArray();
-    }
-
-    public static class Impl implements Intf {
-        public Complex getComplex() {
-            return new Complex(1.0, 1.0);
-        }
-
-        public int[] getIntArray() {
-            return new int[] {1, 2, 3};
-        }
-
-        public String[] getStringArray() {
-            return new String[] {"one", "two", "three"};
-        }
-    }
-
-    public static interface TestMBean extends Intf {}
-
-    public static class Test extends Impl implements TestMBean {}
-
-    public static interface TestMXBean extends Intf {}
-
-    public static class TestMX extends Impl implements TestMXBean {}
-
-    public static class AttrWithDot extends StandardMBean {
-        public <T> AttrWithDot(Object impl, Class<T> intf) {
-            super(intf.cast(impl), intf, (intf == TestMXBean.class));
-        }
-
-        public Object getAttribute(String attribute)
-        throws AttributeNotFoundException, MBeanException, ReflectionException {
-            if (attribute.equals("Complex.re"))
-                return 2.0;
-            else
-                return super.getAttribute(attribute);
-        }
-    }
-
-    private static final boolean[] booleans = {false, true};
-
-    private static final QueryExp[] alwaysTrueQueries = {
-        Query.eq(Query.attr("IntArray.length"), Query.value(3)),
-        Query.eq(Query.attr("StringArray.length"), Query.value(3)),
-        Query.eq(Query.attr("Complex.im"), Query.value(1.0)),
-    };
-
-    private static final QueryExp[] alwaysFalseQueries = {
-        Query.eq(Query.attr("IntArray.length"), Query.value("3")),
-        Query.eq(Query.attr("IntArray.length"), Query.value(2)),
-        Query.eq(Query.attr("Complex.im"), Query.value(-1.0)),
-        Query.eq(Query.attr("Complex.xxx"), Query.value(0)),
-    };
-
-    private static final QueryExp[] attrWithDotTrueQueries = {
-        Query.eq(Query.attr("Complex.re"), Query.value(2.0)),
-    };
-
-    private static final QueryExp[] attrWithDotFalseQueries = {
-        Query.eq(Query.attr("Complex.re"), Query.value(1.0)),
-    };
-
-    private static String failure;
-
-    public static void main(String[] args) throws Exception {
-        ObjectName name = new ObjectName("a:b=c");
-        for (boolean attrWithDot : booleans) {
-            for (boolean mx : booleans) {
-                String what =
-                        (mx ? "MXBean" : "Standard MBean") +
-                        (attrWithDot ? " having attribute with dot in its name" : "");
-                System.out.println("Testing " + what);
-                Class<?> intf = mx ? TestMXBean.class : TestMBean.class;
-                Object impl = mx ? new TestMX() : new Test();
-                if (attrWithDot)
-                    impl = new AttrWithDot(impl, intf);
-                MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-                mbs.registerMBean(impl, name);
-                boolean ismx = "true".equals(
-                        mbs.getMBeanInfo(name).getDescriptor().getFieldValue("mxbean"));
-                if (mx != ismx)
-                    fail("MBean should " + (mx ? "" : "not ") + "be MXBean");
-                test(mbs, name, alwaysTrueQueries, true);
-                test(mbs, name, alwaysFalseQueries, false);
-                test(mbs, name, attrWithDotTrueQueries, attrWithDot);
-                test(mbs, name, attrWithDotFalseQueries, !attrWithDot);
-            }
-        }
-        if (failure != null)
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static void test(
-            MBeanServer mbs, ObjectName name, QueryExp[] queries, boolean expect)
-            throws Exception {
-        for (QueryExp query : queries) {
-            // Serialize and deserialize the query to ensure that its
-            // serialization is correct
-            ByteArrayOutputStream bout = new ByteArrayOutputStream();
-            ObjectOutputStream oout = new ObjectOutputStream(bout);
-            oout.writeObject(query);
-            oout.close();
-            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
-            ObjectInputStream oin = new ObjectInputStream(bin);
-            query = (QueryExp) oin.readObject();
-            Set<ObjectName> names = mbs.queryNames(null, query);
-            if (names.isEmpty()) {
-                if (expect)
-                    fail("Query is false but should be true: " + query);
-            } else if (names.equals(Collections.singleton(name))) {
-                if (!expect)
-                    fail("Query is true but should be false: " + query);
-            } else {
-                fail("Query returned unexpected set: " + names);
-            }
-        }
-    }
-
-    private static void fail(String msg) {
-        failure = msg;
-        System.out.println("..." + msg);
-    }
-}
--- a/test/javax/management/query/QueryExpStringTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/query/QueryExpStringTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -31,10 +31,6 @@
  * @run main QueryExpStringTest
  */
 
-// This test is mostly obsolete, since we now have Query.fromString.
-// The test includes its own parser, from which Query.fromString was derived.
-// The parsers are not identical and the one here is no longer maintained.
-
 import java.util.*;
 import javax.management.*;
 
--- a/test/javax/management/query/QueryNotifFilterTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,347 +0,0 @@
-/*
- * 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.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along 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 QueryNotifFilterTest
- * @bug 6610917
- * @summary Test the QueryNotificationFilter class
- * @author Eamonn McManus
- */
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.management.Attribute;
-import javax.management.AttributeChangeNotification;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryEval;
-import javax.management.QueryExp;
-import javax.management.QueryNotificationFilter;
-
-public class QueryNotifFilterTest {
-    private static class Case {
-        final Notification notif;
-        final QueryExp query;
-        final boolean expect;
-        final Class<? extends Notification> notifClass;
-        Case(Notification notif, String query, boolean expect) {
-            this(notif, query, notif.getClass(), expect);
-        }
-        Case(Notification notif, String query,
-                Class<? extends Notification> notifClass, boolean expect) {
-            this(notif, Query.fromString(query), notifClass, expect);
-        }
-        Case(Notification notif, QueryExp query, boolean expect) {
-            this(notif, query, notif.getClass(), expect);
-        }
-        Case(Notification notif, QueryExp query,
-                Class<? extends Notification> notifClass, boolean expect) {
-            this.notif = notif;
-            this.query = query;
-            this.expect = expect;
-            this.notifClass = notifClass;
-        }
-    }
-
-    /* In principle users can create their own implementations of QueryExp
-     * and use them with QueryNotificationFilter.  If they do so, then
-     * they can call any MBeanServer method.  Not all of those methods
-     * will work with the special MBeanServer we concoct to analyze a
-     * Notification, but some will, including some that are not called
-     * by the standard queries.  So we check each of those cases too.
-     */
-    private static class ExoticCase {
-        final Notification trueNotif;
-        final Notification falseNotif;
-        final QueryExp query;
-        ExoticCase(Notification trueNotif, Notification falseNotif, QueryExp query) {
-            this.trueNotif = trueNotif;
-            this.falseNotif = falseNotif;
-            this.query = query;
-        }
-    }
-
-    private static abstract class ExoticQuery
-            extends QueryEval implements QueryExp {
-        private final String queryString;
-        ExoticQuery(String queryString) {
-            this.queryString = queryString;
-        }
-        abstract boolean apply(MBeanServer mbs, ObjectName name) throws Exception;
-        //@Override - doesn't override in JDK5
-        public boolean apply(ObjectName name) {
-            try {
-                return apply(getMBeanServer(), name);
-            } catch (Exception e) {
-                e.printStackTrace(System.out);
-                return false;
-            }
-        }
-        @Override
-        public String toString() {
-            return queryString;
-        }
-    }
-
-    private static ObjectName makeObjectName(String s) {
-        try {
-            return new ObjectName(s);
-        } catch (MalformedObjectNameException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    public static class CustomNotification extends Notification {
-        public CustomNotification(String type, Object source, long seqNo) {
-            super(type, source, seqNo);
-        }
-
-        public String getName() {
-            return "claude";
-        }
-
-        public boolean isInteresting() {
-            return true;
-        }
-    }
-
-    private static final Notification simpleNotif =
-            new Notification("mytype", "source", 0L);
-    private static final Notification attrChangeNotif =
-            new AttributeChangeNotification(
-                    "x", 0L, 0L, "msg", "AttrName", "int", 2, 3);
-    private static final ObjectName testObjectName = makeObjectName("a:b=c");
-    private static final Notification sourcedNotif =
-            new Notification("mytype", testObjectName, 0L);
-    private static final Notification customNotif =
-            new CustomNotification("mytype", testObjectName, 0L);
-
-    private static final Case[] testCases = {
-        new Case(simpleNotif, "Type = 'mytype'", true),
-        new Case(simpleNotif, "Type = 'mytype'",
-                Notification.class, true),
-        new Case(simpleNotif, "Type = 'mytype'",
-                AttributeChangeNotification.class, false),
-        new Case(simpleNotif, "Type != 'mytype'", false),
-        new Case(simpleNotif, "Type = 'somethingelse'", false),
-        new Case(attrChangeNotif, "AttributeName = 'AttrName'", true),
-        new Case(attrChangeNotif,
-                "instanceof 'javax.management.AttributeChangeNotification'",
-                true),
-        new Case(attrChangeNotif,
-                "instanceof 'javax.management.Notification'",
-                true),
-        new Case(attrChangeNotif,
-                "instanceof 'javax.management.relation.MBeanServerNotification'",
-                false),
-        new Case(attrChangeNotif,
-                "class = 'javax.management.AttributeChangeNotification'",
-                true),
-        new Case(attrChangeNotif,
-                "javax.management.AttributeChangeNotification#AttributeName = 'AttrName'",
-                true),
-        new Case(sourcedNotif,
-                testObjectName,
-                true),
-        new Case(sourcedNotif,
-                makeObjectName("a*:b=*"),
-                true),
-        new Case(sourcedNotif,
-                makeObjectName("a*:c=*"),
-                false),
-        new Case(customNotif, "Name = 'claude'", true),
-        new Case(customNotif, "Name = 'tiddly'", false),
-        new Case(customNotif, "Interesting = true", true),
-        new Case(customNotif, "Interesting = false", false),
-    };
-
-    private static final ExoticCase[] exoticTestCases = {
-        new ExoticCase(
-                simpleNotif, new Notification("notmytype", "source", 0L),
-                new ExoticQuery("getAttributes") {
-                    boolean apply(MBeanServer mbs, ObjectName name)
-                            throws Exception {
-                        List<Attribute> attrs = mbs.getAttributes(
-                                name, new String[] {"Type", "Source"}).asList();
-                        return (attrs.get(0).equals(new Attribute("Type", "mytype")) &&
-                                attrs.get(1).equals(new Attribute("Source", "source")));
-                    }
-                }),
-        new ExoticCase(
-                new Notification("mytype", "source", 0L) {},
-                simpleNotif,
-                new ExoticQuery("getClassLoaderFor") {
-                    boolean apply(MBeanServer mbs, ObjectName name)
-                            throws Exception {
-                        return (mbs.getClassLoaderFor(name) ==
-                                this.getClass().getClassLoader());
-                    }
-                }),
-        new ExoticCase(
-                sourcedNotif, simpleNotif,
-                new ExoticQuery("getDomains") {
-                    boolean apply(MBeanServer mbs, ObjectName name)
-                            throws Exception {
-                        return Arrays.equals(mbs.getDomains(),
-                                new String[] {testObjectName.getDomain()});
-                    }
-                }),
-        new ExoticCase(
-                simpleNotif, attrChangeNotif,
-                new ExoticQuery("getMBeanInfo") {
-                    boolean apply(MBeanServer mbs, ObjectName name)
-                            throws Exception {
-                        MBeanInfo mbi = mbs.getMBeanInfo(name);
-                        // If we ever add a constructor to Notification then
-                        // we will have to change the 4 below.
-                        if (mbi.getOperations().length > 0 ||
-                                mbi.getConstructors().length != 4 ||
-                                mbi.getNotifications().length > 0)
-                            return false;
-                        Set<String> expect = new HashSet<String>(
-                            Arrays.asList(
-                                "Class", "Message", "SequenceNumber", "Source",
-                                "TimeStamp", "Type", "UserData"));
-                        Set<String> actual = new HashSet<String>();
-                        for (MBeanAttributeInfo mbai : mbi.getAttributes())
-                            actual.add(mbai.getName());
-                        return actual.equals(expect);
-                    }
-                }),
-        new ExoticCase(
-                simpleNotif, attrChangeNotif,
-                new ExoticQuery("getObjectInstance") {
-                    boolean apply(MBeanServer mbs, ObjectName name)
-                            throws Exception {
-                        ObjectInstance oi = mbs.getObjectInstance(name);
-                        return oi.getClassName().equals(Notification.class.getName());
-                    }
-                }),
-        new ExoticCase(
-                sourcedNotif, simpleNotif,
-                new ExoticQuery("queryNames") {
-                    boolean apply(MBeanServer mbs, ObjectName name)
-                            throws Exception {
-                        Set<ObjectName> names = mbs.queryNames(null,
-                                Query.eq(Query.attr("Type"), Query.value("mytype")));
-                        return names.equals(Collections.singleton(testObjectName));
-                    }
-                }),
-        new ExoticCase(
-                sourcedNotif, simpleNotif,
-                new ExoticQuery("queryMBeans") {
-                    boolean apply(MBeanServer mbs, ObjectName name)
-                            throws Exception {
-                        Set<ObjectInstance> insts = mbs.queryMBeans(null,
-                                Query.eq(Query.attr("Type"), Query.value("mytype")));
-                        if (insts.size() != 1)
-                            return false;
-                        ObjectInstance inst = insts.iterator().next();
-                        return (inst.getObjectName().equals(testObjectName) &&
-                                inst.getClassName().equals(Notification.class.getName()));
-                    }
-                }),
-    };
-
-    private static enum Test {
-        QUERY_EXP("query"), STRING("string"), STRING_PLUS_CLASS("string with class");
-        private final String name;
-        Test(String name) {
-            this.name = name;
-        }
-        @Override
-        public String toString() {
-            return name;
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        boolean allok = true;
-        for (Case testCase : testCases) {
-            for (Test test : Test.values()) {
-                QueryNotificationFilter nf;
-                String queryString;
-                switch (test) {
-                case QUERY_EXP: {
-                    QueryExp inst = Query.isInstanceOf(
-                            Query.value(testCase.notifClass.getName()));
-                    QueryExp and = Query.and(inst, testCase.query);
-                    queryString = Query.toString(and);
-                    nf = new QueryNotificationFilter(and);
-                    break;
-                }
-                case STRING: {
-                    String s = "instanceof '" + testCase.notifClass.getName() + "'";
-                    queryString = s + " and " + Query.toString(testCase.query);
-                    nf = new QueryNotificationFilter(queryString);
-                    break;
-                }
-                case STRING_PLUS_CLASS:
-                    queryString = null;
-                    nf = new QueryNotificationFilter(
-                            testCase.notifClass, Query.toString(testCase.query));
-                    break;
-                default:
-                    throw new AssertionError();
-                }
-                boolean accept = nf.isNotificationEnabled(testCase.notif);
-                if (queryString != null) {
-                    queryString = Query.toString(Query.fromString(queryString));
-                    if (!queryString.equals(Query.toString(nf.getQuery()))) {
-                        System.out.println("FAIL: query string mismatch: expected " +
-                                "\"" + queryString + "\", got \"" +
-                                Query.toString(nf.getQuery()));
-                        allok = false;
-                    }
-                }
-                boolean ok = (accept == testCase.expect);
-                System.out.println((ok ? "pass" : "FAIL") + ": " +
-                        testCase.query + " (" + test + ")");
-                allok &= ok;
-            }
-        }
-        for (ExoticCase testCase : exoticTestCases) {
-            NotificationFilter nf = new QueryNotificationFilter(testCase.query);
-            for (boolean expect : new boolean[] {true, false}) {
-                Notification n = expect ? testCase.trueNotif : testCase.falseNotif;
-                boolean accept = nf.isNotificationEnabled(n);
-                boolean ok = (accept == expect);
-                System.out.println((ok ? "pass" : "FAIL") + ": " +
-                        testCase.query + ": " + n);
-                allok &= ok;
-            }
-        }
-        if (!allok)
-            throw new Exception("TEST FAILED");
-    }
-}
--- a/test/javax/management/query/QueryParseTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,781 +0,0 @@
-/*
- * 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 QueryParseTest
- * @bug 6602310 6604768
- * @summary Test Query.fromString and Query.toString.
- * @author Eamonn McManus
- */
-
-import java.util.Collections;
-import java.util.Set;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.management.Query;
-import javax.management.QueryExp;
-
-public class QueryParseTest {
-    // In this table, each string constant corresponds to a test case.
-    // The objects following the string up to the next string are MBeans.
-    // Each MBean must implement ExpectedValue to return true or false
-    // according as it should return that value for the query parsed
-    // from the given string.  The test will parse the string into a
-    // a query and verify that the MBeans return the expected value
-    // for that query.  Then it will convert the query back into a string
-    // and into a second query, and check that the MBeans return the
-    // expected value for that query too.  The reason we need to do all
-    // this is that the spec talks about "equivalent queries", and gives
-    // the implementation wide scope to rearrange queries.  So we cannot
-    // just compare string values.
-    //
-    // We could also write an implementation-dependent test that knew what
-    // the strings look like, and that would have to be changed if the
-    // implementation changed.  But the approach here is cleaner.
-    //
-    // To simplify the creation of MBeans, most use the expectTrue or
-    // expectFalse methods.  The parameters of these methods end up in
-    // attributes called "A", "B", "C", etc.
-    private static final Object[] queryTests = {
-        // RELATIONS
-
-        "A < B",
-        expectTrue(1, 2), expectTrue(1.0, 2.0), expectTrue("one", "two"),
-        expectTrue(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY),
-        expectFalse(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY),
-        expectFalse(1, 1), expectFalse(1.0, 1.0), expectFalse("one", "one"),
-        expectFalse(2, 1), expectFalse(2.0, 1.0), expectFalse("two", "one"),
-        expectFalse(Double.NaN, Double.NaN),
-
-        "One = two",
-        expectTrueOneTwo(1, 1), expectTrueOneTwo(1.0, 1.0),
-        expectFalseOneTwo(1, 2), expectFalseOneTwo(2, 1),
-
-        "A <= B",
-        expectTrue(1, 1), expectTrue(1, 2), expectTrue("one", "one"),
-        expectTrue("one", "two"),
-        expectFalse(2, 1), expectFalse("two", "one"),
-        expectFalse(Double.NaN, Double.NaN),
-
-        "A >= B",
-        expectTrue(1, 1), expectTrue(2, 1), expectTrue("two", "one"),
-        expectFalse(1, 2), expectFalse("one", "two"),
-
-        "A > B",
-        expectTrue(2, 1), expectTrue("two", "one"),
-        expectFalse(2, 2), expectFalse(1, 2), expectFalse(1.0, 2.0),
-        expectFalse("one", "two"),
-
-        "A <> B",
-        expectTrue(1, 2), expectTrue("foo", "bar"),
-        expectFalse(1, 1), expectFalse("foo", "foo"),
-
-        "A != B",
-        expectTrue(1, 2), expectTrue("foo", "bar"),
-        expectFalse(1, 1), expectFalse("foo", "foo"),
-
-        // PARENTHESES
-
-        "(((A))) = (B)",
-        expectTrue(1, 1), expectFalse(1, 2),
-
-        "(A = B)",
-        expectTrue(1, 1), expectFalse(1, 2),
-
-        "(((A = (B))))",
-        expectTrue(1, 1), expectFalse(1, 2),
-
-        // INTEGER LITERALS
-
-        "A = 1234567890123456789",
-        expectTrue(1234567890123456789L), expectFalse(123456789L),
-
-        "A = +1234567890123456789",
-        expectTrue(1234567890123456789L), expectFalse(123456789L),
-
-        "A = -1234567890123456789",
-        expectTrue(-1234567890123456789L), expectFalse(-123456789L),
-
-
-        "A = + 1234567890123456789",
-        expectTrue(1234567890123456789L), expectFalse(123456789L),
-
-        "A = - 1234567890123456789",
-        expectTrue(-1234567890123456789L), expectFalse(-123456789L),
-
-        "A = " + Long.MAX_VALUE,
-        expectTrue(Long.MAX_VALUE), expectFalse(Long.MIN_VALUE),
-
-        "A = " + Long.MIN_VALUE,
-        expectTrue(Long.MIN_VALUE), expectFalse(Long.MAX_VALUE),
-
-        // DOUBLE LITERALS
-
-        "A = 0.0",
-        expectTrue(0.0), expectFalse(1.0),
-
-        "A = 0.0e23",
-        expectTrue(0.0), expectFalse(1.0),
-
-        "A = 1.2e3",
-        expectTrue(1.2e3), expectFalse(1.2),
-
-        "A = +1.2",
-        expectTrue(1.2), expectFalse(-1.2),
-
-        "A = 1.2e+3",
-        expectTrue(1.2e3), expectFalse(1.2),
-
-        "A = 1.2e-3",
-        expectTrue(1.2e-3), expectFalse(1.2),
-
-        "A = 1.2E3",
-        expectTrue(1.2e3), expectFalse(1.2),
-
-        "A = -1.2e3",
-        expectTrue(-1.2e3), expectFalse(1.2),
-
-        "A = " + Double.MAX_VALUE,
-        expectTrue(Double.MAX_VALUE), expectFalse(Double.MIN_VALUE),
-
-        "A = " + -Double.MAX_VALUE,
-        expectTrue(-Double.MAX_VALUE), expectFalse(-Double.MIN_VALUE),
-
-        "A = " + Double.MIN_VALUE,
-        expectTrue(Double.MIN_VALUE), expectFalse(Double.MAX_VALUE),
-
-        "A = " + -Double.MIN_VALUE,
-        expectTrue(-Double.MIN_VALUE), expectFalse(-Double.MAX_VALUE),
-
-        Query.toString(  // A = Infinity   ->   A = (1.0/0.0)
-                Query.eq(Query.attr("A"), Query.value(Double.POSITIVE_INFINITY))),
-        expectTrue(Double.POSITIVE_INFINITY),
-        expectFalse(0.0), expectFalse(Double.NEGATIVE_INFINITY),
-
-        Query.toString(  // A = -Infinity   ->   A = (-1.0/0.0)
-                Query.eq(Query.attr("A"), Query.value(Double.NEGATIVE_INFINITY))),
-        expectTrue(Double.NEGATIVE_INFINITY),
-        expectFalse(0.0), expectFalse(Double.POSITIVE_INFINITY),
-
-        Query.toString(  // A < NaN   ->   A < (0.0/0.0)
-                Query.lt(Query.attr("A"), Query.value(Double.NaN))),
-        expectFalse(0.0), expectFalse(Double.NEGATIVE_INFINITY),
-        expectFalse(Double.POSITIVE_INFINITY), expectFalse(Double.NaN),
-
-        Query.toString(  // A >= NaN   ->   A < (0.0/0.0)
-                Query.geq(Query.attr("A"), Query.value(Double.NaN))),
-        expectFalse(0.0), expectFalse(Double.NEGATIVE_INFINITY),
-        expectFalse(Double.POSITIVE_INFINITY), expectFalse(Double.NaN),
-
-        // STRING LITERALS
-
-        "A = 'blim'",
-        expectTrue("blim"), expectFalse("blam"),
-
-        "A = 'can''t'",
-        expectTrue("can't"), expectFalse("cant"), expectFalse("can''t"),
-
-        "A = '''blim'''",
-        expectTrue("'blim'"), expectFalse("'blam'"),
-
-        "A = ''",
-        expectTrue(""), expectFalse((Object) null),
-
-        // BOOLEAN LITERALS
-
-        "A = true",
-        expectTrue(true), expectFalse(false), expectFalse((Object) null),
-
-        "A = TRUE",
-        expectTrue(true), expectFalse(false),
-
-        "A = TrUe",
-        expectTrue(true), expectFalse(false),
-
-        "A = false",
-        expectTrue(false), expectFalse(true),
-
-        "A = fAlSe",
-        expectTrue(false), expectFalse(true),
-
-        "A = \"true\"",   // An attribute called "true"
-        expectFalse(true), expectFalse(false), expectFalse("\"true\""),
-        newTester(new String[] {"A", "true"}, new Object[] {2.2, 2.2}, true),
-        newTester(new String[] {"A", "true"}, new Object[] {2.2, 2.3}, false),
-
-        "A = \"False\"",
-        expectFalse(true), expectFalse(false), expectFalse("\"False\""),
-        newTester(new String[] {"A", "False"}, new Object[] {2.2, 2.2}, true),
-        newTester(new String[] {"A", "False"}, new Object[] {2.2, 2.3}, false),
-
-        // ARITHMETIC
-
-        "A + B = 10",
-        expectTrue(4, 6), expectFalse(3, 8),
-
-        "A + B = 'blim'",
-        expectTrue("bl", "im"), expectFalse("bl", "am"),
-
-        "A - B = 10",
-        expectTrue(16, 6), expectFalse(16, 3),
-
-        "A * B = 10",
-        expectTrue(2, 5), expectFalse(3, 3),
-
-        "A / B = 10",
-        expectTrue(70, 7), expectTrue(70.0, 7), expectFalse(70.01, 7),
-
-        "A + B + C = 10",
-        expectTrue(2, 3, 5), expectFalse(2, 4, 8),
-
-        "A+B+C=10",
-        expectTrue(2, 3, 5), expectFalse(2, 4, 8),
-
-        "A + B + C + D = 10",
-        expectTrue(1, 2, 3, 4), expectFalse(2, 3, 4, 5),
-
-        "A + (B + C) = 10",
-        expectTrue(2, 3, 5), expectFalse(2, 4, 8),
-
-        // It is not correct to rearrange A + (B + C) as A + B + C
-        // (which means (A + B) + C), because of overflow.
-        // In particular Query.toString must not do this.
-        "A + (B + C) = " + Double.MAX_VALUE,  // ensure no false associativity
-        expectTrue(Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE),
-        expectFalse(-Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE),
-
-        "A * (B * C) < " + Double.MAX_VALUE,  // same test for multiplication
-        expectTrue(Double.MAX_VALUE, Double.MAX_VALUE, Double.MIN_VALUE),
-        expectFalse(Double.MIN_VALUE, Double.MAX_VALUE, Double.MAX_VALUE),
-
-        "A * B + C = 10",
-        expectTrue(3, 3, 1), expectTrue(2, 4, 2), expectFalse(1, 2, 3),
-
-        "A*B+C=10",
-        expectTrue(3, 3, 1), expectTrue(2, 4, 2), expectFalse(1, 2, 3),
-
-        "(A * B) + C = 10",
-        expectTrue(3, 3, 1), expectTrue(2, 4, 2), expectFalse(1, 2, 3),
-
-        "A + B * C = 10",
-        expectTrue(1, 3, 3), expectTrue(2, 2, 4), expectFalse(1, 2, 3),
-
-        "A - B * C = 10",
-        expectTrue(16, 2, 3), expectFalse(15, 2, 2),
-
-        "A + B / C = 10",
-        expectTrue(5, 15, 3), expectFalse(5, 16, 4),
-
-        "A - B / C = 10",
-        expectTrue(16, 12, 2), expectFalse(15, 10, 3),
-
-        "A * (B + C) = 10",
-        expectTrue(2, 2, 3), expectFalse(1, 2, 3),
-
-        "A / (B + C) = 10",
-        expectTrue(70, 4, 3), expectFalse(70, 3, 5),
-
-        "A * (B - C) = 10",
-        expectTrue(2, 8, 3), expectFalse(2, 3, 8),
-
-        "A / (B - C) = 10",
-        expectTrue(70, 11, 4), expectFalse(70, 4, 11),
-
-        "A / B / C = 10",
-        expectTrue(140, 2, 7), expectFalse(100, 5, 5),
-
-        "A / (B / C) = 10",
-        expectTrue(70, 14, 2), expectFalse(70, 10, 7),
-
-        // LOGIC
-
-        "A = B or C = D",
-        expectTrue(1, 1, 2, 3), expectTrue(1, 2, 3, 3), expectTrue(1, 1, 2, 2),
-        expectFalse(1, 2, 3, 4), expectFalse("!", "!!", "?", "??"),
-
-        "A = B and C = D",
-        expectTrue(1, 1, 2, 2),
-        expectFalse(1, 1, 2, 3), expectFalse(1, 2, 3, 3),
-
-        "A = 1 and B = 2 and C = 3",
-        expectTrue(1, 2, 3), expectFalse(1, 2, 4),
-
-        "A = 1 or B = 2 or C = 3",
-        expectTrue(1, 2, 3), expectTrue(1, 0, 0), expectTrue(0, 0, 3),
-        expectFalse(2, 3, 4),
-
-        // grouped as (a and b) or (c and d)
-        "A = 1 AND B = 2 OR C = 3 AND D = 4",
-        expectTrue(1, 2, 3, 4), expectTrue(1, 2, 1, 2), expectTrue(3, 4, 3, 4),
-        expectFalse(3, 4, 1, 2), expectFalse(1, 1, 1, 1),
-
-        "(A = 1 AND B = 2) OR (C = 3 AND D = 4)",
-        expectTrue(1, 2, 3, 4), expectTrue(1, 2, 1, 2), expectTrue(3, 4, 3, 4),
-        expectFalse(3, 4, 1, 2), expectFalse(1, 1, 1, 1),
-
-        "(A = 1 or B = 2) AND (C = 3 or C = 4)",
-        expectTrue(1, 1, 3, 3), expectTrue(2, 2, 4, 4), expectTrue(1, 2, 3, 4),
-        expectFalse(1, 2, 1, 2), expectFalse(3, 4, 3, 4),
-
-        // LIKE
-
-        "A like 'b*m'",
-        expectTrue("blim"), expectTrue("bm"),
-        expectFalse(""), expectFalse("blimmo"), expectFalse("mmm"),
-
-        "A not like 'b*m'",
-        expectFalse("blim"), expectFalse("bm"),
-        expectTrue(""), expectTrue("blimmo"), expectTrue("mmm"),
-
-        "A like 'b?m'",
-        expectTrue("bim"), expectFalse("blim"),
-
-        "A like '*can''t*'",
-        expectTrue("can't"),
-        expectTrue("I'm sorry Dave, I'm afraid I can't do that"),
-        expectFalse("cant"), expectFalse("can''t"),
-
-        "A like '\\**\\*'",
-        expectTrue("*blim*"), expectTrue("**"),
-        expectFalse("blim"), expectFalse("*asdf"), expectFalse("asdf*"),
-
-        "A LIKE '%*_?'",
-        expectTrue("%blim_?"), expectTrue("%_?"), expectTrue("%blim_!"),
-        expectFalse("blim"), expectFalse("blim_"),
-        expectFalse("_%"), expectFalse("??"), expectFalse(""), expectFalse("?"),
-
-        Query.toString(
-                Query.initialSubString(Query.attr("A"), Query.value("*?%_"))),
-        expectTrue("*?%_tiddly"), expectTrue("*?%_"),
-        expectFalse("?%_tiddly"), expectFalse("*!%_"), expectFalse("*??_"),
-        expectFalse("*?%!"), expectFalse("*?%!tiddly"),
-
-        Query.toString(
-                Query.finalSubString(Query.attr("A"), Query.value("*?%_"))),
-        expectTrue("tiddly*?%_"), expectTrue("*?%_"),
-        expectFalse("tiddly?%_"), expectFalse("*!%_"), expectFalse("*??_"),
-        expectFalse("*?%!"), expectFalse("tiddly*?%!"),
-
-        // BETWEEN
-
-        "A between B and C",
-        expectTrue(1, 1, 2), expectTrue(2, 1, 2), expectTrue(2, 1, 3),
-        expectFalse(3, 1, 2), expectFalse(0, 1, 2), expectFalse(2, 3, 1),
-        expectTrue(1.0, 0.0, 2.0), expectFalse(2.0, 0.0, 1.0),
-        expectTrue(0.0, 0.0, 0.0), expectTrue(1.0, 0.0, 1.0),
-        expectTrue(1.0, 0.0, Double.POSITIVE_INFINITY),
-        expectFalse(1.0, Double.NEGATIVE_INFINITY, 0.0),
-        expectFalse(false, false, true), expectFalse(true, false, true),
-        expectTrue("jim", "fred", "sheila"), expectFalse("fred", "jim", "sheila"),
-
-        "A between B and C and 1+2=3",
-        expectTrue(2, 1, 3), expectFalse(2, 3, 1),
-
-        "A not between B and C",
-        expectTrue(1, 2, 3), expectFalse(2, 1, 3),
-
-        // IN
-
-        "A in (1, 2, 3)",
-        expectTrue(1), expectTrue(2), expectTrue(3),
-        expectFalse(0), expectFalse(4),
-
-        "A in (1)",
-        expectTrue(1), expectFalse(0),
-
-        "A in (1.2, 3.4)",
-        expectTrue(1.2), expectTrue(3.4), expectFalse(0.0),
-
-        "A in ('foo', 'bar')",
-        expectTrue("foo"), expectTrue("bar"), expectFalse("baz"),
-
-        "A in ('foo', 'bar') and 'bl'+'im'='blim'",
-        expectTrue("foo"), expectTrue("bar"), expectFalse("baz"),
-
-        "A in (B, C, D)",  // requires fix for CR 6604768
-        expectTrue(1, 1, 2, 3), expectFalse(1, 2, 3, 4),
-
-        "A not in (B, C, D)",
-        expectTrue(1, 2, 3, 4), expectFalse(1, 1, 2, 3),
-
-        // QUOTING
-
-        "\"LIKE\" = 1 and \"NOT\" = 2 and \"INSTANCEOF\" = 3 and " +
-                "\"TRUE\" = 4 and \"FALSE\" = 5",
-        newTester(
-                new String[] {"LIKE", "NOT", "INSTANCEOF", "TRUE", "FALSE"},
-                new Object[] {1, 2, 3, 4, 5},
-                true),
-        newTester(
-                new String[] {"LIKE", "NOT", "INSTANCEOF", "TRUE", "FALSE"},
-                new Object[] {5, 4, 3, 2, 1},
-                false),
-
-        "\"\"\"woo\"\"\" = 5",
-        newTester(new String[] {"\"woo\""}, new Object[] {5}, true),
-        newTester(new String[] {"\"woo\""}, new Object[] {4}, false),
-        expectFalse(),
-
-        // INSTANCEOF
-
-        "instanceof '" + Tester.class.getName() + "'",
-        expectTrue(),
-
-        "instanceof '" + String.class.getName() + "'",
-        expectFalse(),
-
-        // LIKE OBJECTNAME
-
-        // The test MBean is registered as a:b=c
-        "like 'a:b=c'", expectTrue(),
-        "like 'a:*'", expectTrue(),
-        "like '*:b=c'", expectTrue(),
-        "like 'a:b=*'", expectTrue(),
-        "like 'a:b=?'", expectTrue(),
-        "like 'd:b=c'", expectFalse(),
-        "like 'a:b=??*'", expectFalse(),
-        "like 'a:b=\"can''t\"'", expectFalse(),
-
-        // QUALIFIED ATTRIBUTE
-
-        Tester.class.getName() + "#A = 5",
-        expectTrue(5), expectFalse(4),
-
-        Tester.class.getName() + " # A = 5",
-        expectTrue(5), expectFalse(4),
-
-        Tester.class.getSuperclass().getName() + "#A = 5",
-        expectFalse(5),
-
-        DynamicMBean.class.getName() + "#A = 5",
-        expectFalse(5),
-
-        Tester.class.getName() + "#A = 5",
-        new Tester(new String[] {"A"}, new Object[] {5}, false) {},
-        // note the little {} at the end which means this is a subclass
-        // and therefore QualifiedAttributeValue should return false.
-
-        MBeanServerDelegate.class.getName() + "#SpecificationName LIKE '*'",
-        new Wrapped(new MBeanServerDelegate(), true),
-        new Tester(new String[] {"SpecificationName"}, new Object[] {"JMX"}, false),
-
-        // DOTTED ATTRIBUTE
-
-        "A.canonicalName = '" +
-                MBeanServerDelegate.DELEGATE_NAME.getCanonicalName() + "'",
-        expectTrue(MBeanServerDelegate.DELEGATE_NAME),
-        expectFalse(ObjectName.WILDCARD),
-
-        "A.class.name = 'java.lang.String'",
-        expectTrue("blim"), expectFalse(95), expectFalse((Object) null),
-
-        "A.canonicalName like 'JMImpl*:*'",
-        expectTrue(MBeanServerDelegate.DELEGATE_NAME),
-        expectFalse(ObjectName.WILDCARD),
-
-        "A.true = 'blim'",
-        new Tester(new String[] {"A.true"}, new Object[] {"blim"}, true),
-        new Tester(new String[] {"A.true"}, new Object[] {"blam"}, false),
-
-        "\"A.true\" = 'blim'",
-        new Tester(new String[] {"A.true"}, new Object[] {"blim"}, true),
-        new Tester(new String[] {"A.true"}, new Object[] {"blam"}, false),
-
-        MBeanServerDelegate.class.getName() +
-                "#SpecificationName.class.name = 'java.lang.String'",
-        new Wrapped(new MBeanServerDelegate(), true),
-        new Tester(new String[] {"SpecificationName"}, new Object[] {"JMX"}, false),
-
-        MBeanServerDelegate.class.getName() +
-                " # SpecificationName.class.name = 'java.lang.String'",
-        new Wrapped(new MBeanServerDelegate(), true),
-        new Tester(new String[] {"SpecificationName"}, new Object[] {"JMX"}, false),
-
-        // CLASS
-
-        "class = '" + Tester.class.getName() + "'",
-        expectTrue(),
-        new Wrapped(new MBeanServerDelegate(), false),
-
-        "Class = '" + Tester.class.getName() + "'",
-        expectTrue(),
-        new Wrapped(new MBeanServerDelegate(), false),
-    };
-
-    private static final String[] incorrectQueries = {
-        "", " ", "25", "()", "(a = b", "a = b)", "a.3 = 5",
-        "a = " + Long.MAX_VALUE + "0",
-        "a = " + Double.MAX_VALUE + "0",
-        "a = " + Double.MIN_VALUE + "0",
-        "a = 12a5", "a = 12e5e5", "a = 12.23.34",
-        "a = 'can't'", "a = 'unterminated", "a = 'asdf''",
-        "a = \"oops", "a = \"oops\"\"",
-        "a like 5", "true or false",
-        "a ! b", "? = 3", "a = @", "a##b",
-        "a between b , c", "a between and c",
-        "a in b, c", "a in 23", "a in (2, 3", "a in (2, 3x)",
-        "a like \"foo\"", "a like b", "a like 23",
-        "like \"foo\"", "like b", "like 23", "like 'a:b'",
-        "5 like 'a'", "'a' like '*'",
-        "a not= b", "a not = b", "a not b", "a not b c",
-        "a = +b", "a = +'b'", "a = +true", "a = -b", "a = -'b'",
-        "a#5 = b", "a#'b' = c",
-        "a instanceof b", "a instanceof 17", "a instanceof",
-        // "a like 'oops\\'", "a like '[oops'",
-        // We don't check the above because Query.match doesn't.  If LIKE
-        // rejected bad patterns then there would be some QueryExp values
-        // that could not be converted to a string and back.
-
-        // Check that -Long.MIN_VALUE is an illegal constant.  This is one more
-        // than Long.MAX_VALUE and, like the Java language, we only allow it
-        // if it is the operand of unary minus.
-        "a = " + Long.toString(Long.MIN_VALUE).substring(1),
-    };
-
-    public static void main(String[] args) throws Exception {
-        int nexti;
-        String failed = null;
-
-        System.out.println("TESTING CORRECT QUERY STRINGS");
-        for (int i = 0; i < queryTests.length; i = nexti) {
-            for (nexti = i + 1; nexti < queryTests.length; nexti++) {
-                if (queryTests[nexti] instanceof String)
-                    break;
-            }
-            if (!(queryTests[i] instanceof String))
-                throw new Exception("Test bug: should be string: " + queryTests[i]);
-
-            String qs = (String) queryTests[i];
-            System.out.println("Test: " + qs);
-
-            QueryExp qe = Query.fromString(qs);
-            String qes = Query.toString(qe);
-            System.out.println("...parses to: " + qes);
-            final QueryExp[] queries;
-            if (qes.equals(qs))
-                queries = new QueryExp[] {qe};
-            else {
-                QueryExp qe2 = Query.fromString(qes);
-                String qes2 = Query.toString(qe2);
-                System.out.println("...which parses to: " + qes2);
-                if (qes.equals(qes2))
-                    queries = new QueryExp[] {qe};
-                else
-                    queries = new QueryExp[] {qe, qe2};
-            }
-
-            for (int j = i + 1; j < nexti; j++) {
-                Object mbean;
-                if (queryTests[j] instanceof Wrapped)
-                    mbean = ((Wrapped) queryTests[j]).mbean();
-                else
-                    mbean = queryTests[j];
-                boolean expect = ((ExpectedValue) queryTests[j]).expectedValue();
-                for (QueryExp qet : queries) {
-                    boolean actual = runQuery(qet, mbean);
-                    boolean ok = (expect == actual);
-                    System.out.println(
-                            "..." + mbean + " -> " + actual +
-                            (ok ? " (OK)" : " ####INCORRECT####"));
-                    if (!ok)
-                        failed = qs;
-                }
-            }
-        }
-
-        System.out.println();
-        System.out.println("TESTING INCORRECT QUERY STRINGS");
-        for (String s : incorrectQueries) {
-            try {
-                QueryExp qe = Query.fromString(s);
-                System.out.println("###DID NOT GET ERROR:### \"" + s + "\"");
-                failed = s;
-            } catch (IllegalArgumentException e) {
-                String es = (e.getClass() == IllegalArgumentException.class) ?
-                    e.getMessage() : e.toString();
-                System.out.println("OK: exception for \"" + s + "\": " + es);
-            }
-        }
-
-        if (failed == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: Last failure: " + failed);
-    }
-
-    private static boolean runQuery(QueryExp qe, Object mbean)
-    throws Exception {
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        ObjectName name = new ObjectName("a:b=c");
-        mbs.registerMBean(mbean, name);
-        Set<ObjectName> names = mbs.queryNames(new ObjectName("a:*"), qe);
-        if (names.isEmpty())
-            return false;
-        if (names.equals(Collections.singleton(name)))
-            return true;
-        throw new Exception("Unexpected query result set: " + names);
-    }
-
-    private static interface ExpectedValue {
-        public boolean expectedValue();
-    }
-
-    private static class Wrapped implements ExpectedValue {
-        private final Object mbean;
-        private final boolean expect;
-
-        Wrapped(Object mbean, boolean expect) {
-            this.mbean = mbean;
-            this.expect = expect;
-        }
-
-        Object mbean() {
-            return mbean;
-        }
-
-        public boolean expectedValue() {
-            return expect;
-        }
-    }
-
-    private static class Tester implements DynamicMBean, ExpectedValue {
-        private final AttributeList attributes;
-        private final boolean expectedValue;
-
-        Tester(AttributeList attributes, boolean expectedValue) {
-            this.attributes = attributes;
-            this.expectedValue = expectedValue;
-        }
-
-        Tester(String[] names, Object[] values, boolean expectedValue) {
-            this(makeAttributeList(names, values), expectedValue);
-        }
-
-        private static AttributeList makeAttributeList(
-                String[] names, Object[] values) {
-            if (names.length != values.length)
-                throw new Error("Test bug: names and values different length");
-            AttributeList list = new AttributeList();
-            for (int i = 0; i < names.length; i++)
-                list.add(new Attribute(names[i], values[i]));
-            return list;
-        }
-
-        public Object getAttribute(String attribute)
-        throws AttributeNotFoundException {
-            for (Attribute a : attributes.asList()) {
-                if (a.getName().equals(attribute))
-                    return a.getValue();
-            }
-            throw new AttributeNotFoundException(attribute);
-        }
-
-        public void setAttribute(Attribute attribute) {
-            throw new UnsupportedOperationException();
-        }
-
-        public AttributeList getAttributes(String[] attributes) {
-            AttributeList list = new AttributeList();
-            for (String attribute : attributes) {
-                try {
-                    list.add(new Attribute(attribute, getAttribute(attribute)));
-                } catch (AttributeNotFoundException e) {
-                    // OK: ignore, per semantics of getAttributes
-                }
-            }
-            return list;
-        }
-
-        public AttributeList setAttributes(AttributeList attributes) {
-            throw new UnsupportedOperationException();
-        }
-
-        public Object invoke(String actionName, Object[] params, String[] signature) {
-            throw new UnsupportedOperationException();
-        }
-
-        public MBeanInfo getMBeanInfo() {
-            MBeanAttributeInfo mbais[] = new MBeanAttributeInfo[attributes.size()];
-            for (int i = 0; i < mbais.length; i++) {
-                Attribute attr = attributes.asList().get(i);
-                String name = attr.getName();
-                Object value = attr.getValue();
-                String type =
-                        ((value == null) ? new Object() : value).getClass().getName();
-                mbais[i] = new MBeanAttributeInfo(
-                        name, type, name, true, false, false);
-            }
-            return new MBeanInfo(
-                    getClass().getName(), "descr", mbais, null, null, null);
-        }
-
-        public boolean expectedValue() {
-            return expectedValue;
-        }
-
-        @Override
-        public String toString() {
-            return attributes.toString();
-        }
-    }
-
-    // Method rather than field, to avoid circular init dependencies
-    private static String[] abcd() {
-        return new String[] {"A", "B", "C", "D"};
-    }
-
-    private static String[] onetwo() {
-        return new String[] {"One", "two"};
-    }
-
-    private static Object expectTrue(Object... attrs) {
-        return newTester(abcd(), attrs, true);
-    }
-
-    private static Object expectFalse(Object... attrs) {
-        return newTester(abcd(), attrs, false);
-    }
-
-    private static Object expectTrueOneTwo(Object... attrs) {
-        return newTester(onetwo(), attrs, true);
-    }
-
-    private static Object expectFalseOneTwo(Object... attrs) {
-        return newTester(onetwo(), attrs, false);
-    }
-
-    private static Object newTester(String[] names, Object[] attrs, boolean expect) {
-        AttributeList list = new AttributeList();
-        for (int i = 0; i < attrs.length; i++)
-            list.add(new Attribute(names[i], attrs[i]));
-        return new Tester(list, expect);
-    }
-}
--- a/test/javax/management/remote/mandatory/connection/CloseServerTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/connection/CloseServerTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003 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
@@ -31,16 +31,11 @@
  * @run main CloseServerTest
  */
 
-import com.sun.jmx.remote.util.EnvHelp;
 import java.net.MalformedURLException;
+import java.io.IOException;
 
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
 import javax.management.*;
 import javax.management.remote.*;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class CloseServerTest {
     private static final String[] protocols = {"rmi", "iiop", "jmxmp"};
@@ -136,54 +131,40 @@
 
             server.stop();
 
-            List<Map<String, String>> envs = Arrays.asList(
-                    Collections.singletonMap(
-                        RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false"),
-                    Collections.singletonMap(
-                        RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "true"));
-
-            for (Map<String, String> env : envs) {
-                    System.out.println(
-                            ">>>>>>>> " + RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE +
-                            " = " + env.get(RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE));
+            // with a client listener, but close the server first
+            System.out.println(">>> Open, start a server, create a client, add a listener, close the server then the client.");
+            server = JMXConnectorServerFactory.newJMXConnectorServer(u, null, mbs);
+            server.start();
 
-                // with a client listener, but close the server first
-                System.out.println(">>> Open, start a server, create a client, " +
-                        "add a listener, close the server then the client.");
-                server = JMXConnectorServerFactory.newJMXConnectorServer(u, env, mbs);
-                server.start();
+            addr = server.getAddress();
+            client = JMXConnectorFactory.newJMXConnector(addr, null);
+            client.connect(null);
 
-                addr = server.getAddress();
-                client = JMXConnectorFactory.newJMXConnector(addr, null);
-                client.connect(null);
+            mserver = client.getMBeanServerConnection();
+            mserver.addNotificationListener(delegateName, dummyListener, null, null);
 
-                mserver = client.getMBeanServerConnection();
-                mserver.addNotificationListener(delegateName, dummyListener, null, null);
+            server.stop();
 
-                server.stop();
-
-                try {
-                    client.close();
-                } catch (Exception e) {
-                    // ok, it is because the server has been closed.
-                }
+            try {
+                client.close();
+            } catch (Exception e) {
+                // ok, it is because the server has been closed.
+            }
 
-                // with a client listener, but close the client first
-                System.out.println(">>> Open, start a server, create a client, " +
-                        "add a listener, close the client then the server.");
-                server = JMXConnectorServerFactory.newJMXConnectorServer(u, env, mbs);
-                server.start();
+            // with a client listener, but close the client first
+            System.out.println(">>> Open, start a server, create a client, add a listener, close the client then the server.");
+            server = JMXConnectorServerFactory.newJMXConnectorServer(u, null, mbs);
+            server.start();
 
-                addr = server.getAddress();
-                client = JMXConnectorFactory.newJMXConnector(addr, null);
-                client.connect(null);
+            addr = server.getAddress();
+            client = JMXConnectorFactory.newJMXConnector(addr, null);
+            client.connect(null);
 
-                mserver = client.getMBeanServerConnection();
-                mserver.addNotificationListener(delegateName, dummyListener, null, null);
+            mserver = client.getMBeanServerConnection();
+            mserver.addNotificationListener(delegateName, dummyListener, null, null);
 
-                client.close();
-                server.stop();
-            }
+            client.close();
+            server.stop();
         } catch (MalformedURLException e) {
             System.out.println(">>> Skipping unsupported URL " + u);
             return true;
--- a/test/javax/management/remote/mandatory/connection/DeadLockTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/connection/DeadLockTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2004 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,6 @@
 
 import javax.management.*;
 import javax.management.remote.*;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class DeadLockTest {
     private static final String[] protocols = {"rmi", "iiop", "jmxmp"};
@@ -73,9 +72,6 @@
         // disable the client ping
         env.put("jmx.remote.x.client.connection.check.period", "0");
 
-        // ensure we are not internally using the Event Service on the server
-        env.put(RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false");
-
         try {
             u = new JMXServiceURL(proto, null, 0);
             server = JMXConnectorServerFactory.newJMXConnectorServer(u, env, mbs);
--- a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-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
@@ -50,8 +50,6 @@
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 import com.sun.jmx.remote.util.EnvHelp;
-import java.util.Collections;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class IdleTimeoutTest {
     public static void main(String[] args) throws Exception {
@@ -90,13 +88,8 @@
 
     private static long getIdleTimeout(MBeanServer mbs, JMXServiceURL url)
         throws Exception {
-        // If the connector server is using the Event Service, then connections
-        // never time out.  This is by design.
-        Map<String, String> env =
-            Collections.singletonMap(
-                RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false");
         JMXConnectorServer server =
-            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
+            JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
         server.start();
         try {
             url = server.getAddress();
@@ -171,7 +164,6 @@
 
         Map idleMap = new HashMap();
         idleMap.put(EnvHelp.SERVER_CONNECTION_TIMEOUT, new Long(timeout));
-        idleMap.put(RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false");
         JMXConnectorServer server =
             JMXConnectorServerFactory.newJMXConnectorServer(url,idleMap,mbs);
 
--- a/test/javax/management/remote/mandatory/connection/RMIExitTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/connection/RMIExitTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -35,8 +35,6 @@
 import java.net.MalformedURLException;
 import java.io.IOException;
 
-import java.util.Collections;
-import java.util.Map;
 import javax.management.MBeanServerFactory;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
@@ -49,7 +47,6 @@
 import javax.management.remote.JMXConnector;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 /**
  * VM shutdown hook. Test that the hook is called less than 5 secs
@@ -85,15 +82,12 @@
     public static void main(String[] args) {
         System.out.println("Start test");
         Runtime.getRuntime().addShutdownHook(new TimeChecker());
-        test(false);
-        test(true);
+        test();
         exitStartTime = System.currentTimeMillis();
         System.out.println("End test");
     }
 
-    private static void test(boolean eventService) {
-        System.out.println(
-                "---testing with" + (eventService ? "" : "out") + " Event Service");
+    private static void test() {
         try {
             JMXServiceURL u = new JMXServiceURL("rmi", null, 0);
             JMXConnectorServer server;
@@ -112,11 +106,8 @@
                         }
                     };
 
-            Map<String, String> env = Collections.singletonMap(
-                    RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                    Boolean.toString(eventService));
             server = JMXConnectorServerFactory.newJMXConnectorServer(u,
-                                                                     env,
+                                                                     null,
                                                                      mbs);
             server.start();
 
--- a/test/javax/management/remote/mandatory/connection/ReconnectTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/connection/ReconnectTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-2004 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,10 +33,10 @@
 
 import java.util.*;
 import java.net.MalformedURLException;
+import java.io.IOException;
 
 import javax.management.*;
 import javax.management.remote.*;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class ReconnectTest {
     private static final String[] protocols = {"rmi", "iiop", "jmxmp"};
@@ -48,7 +48,6 @@
         String timeout = "1000";
         env.put("jmx.remote.x.server.connection.timeout", timeout);
         env.put("jmx.remote.x.client.connection.check.period", timeout);
-        env.put(RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false");
     }
 
     public static void main(String[] args) throws Exception {
--- a/test/javax/management/remote/mandatory/connectorServer/CloseConnectionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,217 +0,0 @@
-/*
- * Copyright 2003-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 6332907
- * @summary test the ability for connector server to close individual connections
- * @author Shanliang JIANG
- * @run clean CloseConnectionTest
- * @run build CloseConnectionTest
- * @run main CloseConnectionTest
- */
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import javax.management.MBeanServerFactory;
-
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.remote.JMXConnectionNotification;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-
-public class CloseConnectionTest {
-
-    public static void main(String[] args) throws Exception {
-        System.out.println(">>> Test the ability for connector server to close " +
-                "individual connections.");
-
-        final String[] protos = new String[]{"rmi", "iiop", "jmxmp"};
-        for (String p : protos) {
-            System.out.println("\n>>> Testing the protocol " + p);
-            JMXServiceURL addr = new JMXServiceURL(p, null, 0);
-            System.out.println(">>> Creating a JMXConnectorServer on " + addr);
-            JMXConnectorServer server = null;
-            try {
-                server = JMXConnectorServerFactory.newJMXConnectorServer(addr,
-                        null,
-                        MBeanServerFactory.createMBeanServer());
-            } catch (Exception e) {
-                System.out.println(">>> Skip the protocol: " + p);
-                continue;
-            }
-
-            test1(server);
-            test2(server);
-
-            server.stop();
-        }
-
-        System.out.println(">>> Bye bye!");
-    }
-
-    private static void test1(JMXConnectorServer server) throws Exception {
-        try {
-            server.closeConnection("toto");
-            // not started, known id
-            throw new RuntimeException("An IllegalArgumentException is not thrown.");
-        } catch (IllegalStateException e) {
-            System.out.println(">>> Test1: Got expected IllegalStateException: " + e);
-        }
-
-        server.start();
-        System.out.println(">>>Test1 Started the server on " + server.getAddress());
-
-        try {
-            server.closeConnection("toto");
-            throw new RuntimeException("An IllegalArgumentException is not thrown.");
-        } catch (IllegalArgumentException e) {
-            System.out.println(">> Test1: Got expected IllegalArgumentException: " + e);
-        }
-
-        MyListener listener = new MyListener();
-        server.addNotificationListener(listener, null, null);
-
-        System.out.println(">>> Test1: Connecting a client to the server ...");
-        final JMXConnector conn = JMXConnectorFactory.connect(server.getAddress());
-        conn.getMBeanServerConnection().getDefaultDomain();
-        final String id1 = conn.getConnectionId();
-
-        listener.wait(JMXConnectionNotification.OPENED, timeout);
-
-        System.out.println(">>> Test1: Closing the connection: " + conn.getConnectionId());
-        server.closeConnection(id1);
-        listener.wait(JMXConnectionNotification.CLOSED, timeout);
-
-        System.out.println(">>> Test1: Using again the connector whose connection " +
-                "should be closed by the server, it should reconnect " +
-                "automatically to the server and get a new connection id.");
-        conn.getMBeanServerConnection().getDefaultDomain();
-        final String id2 = conn.getConnectionId();
-        listener.wait(JMXConnectionNotification.OPENED, timeout);
-
-        if (id1.equals(id2)) {
-            throw new RuntimeException("Failed, the first client connection is not closed.");
-        }
-
-        System.out.println(">>> Test1: Greate, we get a new connection id " + id2 +
-                ", the first one is closed as expected.");
-
-        System.out.println(">>> Test1: Closing the client.");
-        conn.close();
-        System.out.println(">>> Test1: Stopping the server.");
-        server.removeNotificationListener(listener);
-    }
-
-    private static void test2(JMXConnectorServer server) throws Exception {
-        System.out.println(">>> Test2 close a connection before " +
-                "the client can use it...");
-        final Killer killer = new Killer(server);
-        server.addNotificationListener(killer, null, null);
-
-        System.out.println(">>> Test2 Connecting a client to the server ...");
-        final JMXConnector conn;
-        try {
-            conn = JMXConnectorFactory.connect(server.getAddress());
-            throw new RuntimeException(">>> Failed, do not receive an " +
-                    "IOException telling the connection is refused.");
-        } catch (IOException ioe) {
-            System.out.println(">>> Test2 got expected IOException: "+ioe);
-        }
-    }
-
-    private static class MyListener implements NotificationListener {
-        public void handleNotification(Notification n, Object hb) {
-            if (n instanceof JMXConnectionNotification) {
-                synchronized (received) {
-                    received.add((JMXConnectionNotification) n);
-                    received.notify();
-                }
-            }
-        }
-
-        public JMXConnectionNotification wait(String type, long timeout)
-                throws Exception {
-            JMXConnectionNotification waited = null;
-            long toWait = timeout;
-            long deadline = System.currentTimeMillis() + timeout;
-            synchronized (received) {
-                while (waited == null && toWait > 0) {
-                    received.wait(toWait);
-                    for (JMXConnectionNotification n : received) {
-                        if (type.equals(n.getType())) {
-                            waited = n;
-                            break;
-                        }
-                    }
-                    received.clear();
-                    toWait = deadline - System.currentTimeMillis();
-                }
-            }
-
-            if (waited == null) {
-                throw new RuntimeException("Do not receive expected notification " + type);
-            } else {
-                System.out.println(">>> Received expected notif: "+type+
-                        " "+waited.getConnectionId());
-            }
-
-            return waited;
-        }
-
-        final List<JMXConnectionNotification> received =
-                new ArrayList<JMXConnectionNotification>();
-    }
-
-    private static class Killer implements NotificationListener {
-        public Killer(JMXConnectorServer server) {
-            this.server = server;
-        }
-        public void handleNotification(Notification n, Object hb) {
-            if (n instanceof JMXConnectionNotification) {
-                if (JMXConnectionNotification.OPENED.equals(n.getType())) {
-                    final JMXConnectionNotification cn =
-                            (JMXConnectionNotification)n;
-                    try {
-                        System.out.println(">>> Killer: close the connection "+
-                                cn.getConnectionId());
-                        server.closeConnection(cn.getConnectionId());
-                    } catch (Exception e) {
-                        // impossible?
-                        e.printStackTrace();
-                        System.exit(1);
-                    }
-                }
-            }
-        }
-
-        private final JMXConnectorServer server;
-    }
-
-    private static final long timeout = 6000;
-}
--- a/test/javax/management/remote/mandatory/connectorServer/ForwarderChainTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,279 +0,0 @@
-/*
- * 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.NoSuchElementException;
-import java.util.Random;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerFactory;
-import javax.management.remote.IdentityMBeanServerForwarder;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.MBeanServerForwarder;
-
-/*
- * @test
- * @bug 6218920
- * @summary Tests manipulation of MBeanServerForwarder chains.
- * @author Eamonn McManus
- */
-import javax.management.remote.rmi.RMIConnectorServer;
-
-public class ForwarderChainTest {
-    private static final TestMBeanServerForwarder[] forwarders =
-            new TestMBeanServerForwarder[10];
-    static {
-        for (int i = 0; i < forwarders.length; i++)
-            forwarders[i] = new TestMBeanServerForwarder(i);
-    }
-
-    private static class TestMBeanServerForwarder
-            extends IdentityMBeanServerForwarder {
-        private final int index;
-        volatile int defaultDomainCount;
-
-        TestMBeanServerForwarder(int index) {
-            this.index = index;
-        }
-
-        @Override
-        public String getDefaultDomain() {
-            defaultDomainCount++;
-            return super.getDefaultDomain();
-        }
-
-        @Override
-        public String toString() {
-            return "forwarders[" + index + "]";
-        }
-    }
-
-    private static String failure;
-
-    public static void main(String[] args) throws Exception {
-
-        System.out.println("===Test with newly created, unattached server===");
-
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
-        JMXConnectorServer cs = new RMIConnectorServer(url, null);
-        test(cs, null);
-
-        System.out.println("===Test with server attached to MBS===");
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        cs = new RMIConnectorServer(url, null, mbs);
-        test(cs, mbs);
-
-        System.out.println("===Remove any leftover forwarders===");
-        MBeanServerForwarder systemMBSF = cs.getSystemMBeanServerForwarder();
-        // Real code would just do systemMBSF.setMBeanServer(mbs).
-        while (true) {
-            MBeanServer xmbs = systemMBSF.getMBeanServer();
-            if (!(xmbs instanceof MBeanServerForwarder))
-                break;
-            cs.removeMBeanServerForwarder((MBeanServerForwarder) xmbs);
-        }
-        expectChain(cs, "U", mbs);
-
-        System.out.println("===Ensure forwarders are called===");
-        cs.setMBeanServerForwarder(forwarders[0]);
-        systemMBSF.setMBeanServer(forwarders[1]);
-        forwarders[1].setMBeanServer(forwarders[0]);
-        expectChain(cs, "1U0", mbs);
-        cs.start();
-        if (forwarders[0].defaultDomainCount != 0 ||
-                forwarders[1].defaultDomainCount != 0) {
-            fail("defaultDomainCount not zero");
-        }
-        JMXServiceURL addr = cs.getAddress();
-        JMXConnector cc = JMXConnectorFactory.connect(addr);
-        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-        mbsc.getDefaultDomain();
-        cc.close();
-        cs.stop();
-        for (boolean system : new boolean[] {false, true}) {
-            TestMBeanServerForwarder mbsf = system ? forwarders[1] : forwarders[0];
-            if (mbsf.defaultDomainCount != 1) {
-                fail((system ? "System" : "User") + " forwarder called " +
-                        mbsf.defaultDomainCount + " times");
-            }
-        }
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception("TEST FAILED: " + failure);
-    }
-
-    private static void test(JMXConnectorServer cs, MBeanServer end) {
-        // A newly-created connector server might have system forwarders,
-        // so get rid of those.
-        MBeanServerForwarder systemMBSF = cs.getSystemMBeanServerForwarder();
-        systemMBSF.setMBeanServer(cs.getMBeanServer());
-
-        expectChain(cs, "U", end);
-
-        System.out.println("Add a user forwarder");
-        cs.setMBeanServerForwarder(forwarders[0]);
-        expectChain(cs, "U0", end);
-
-        System.out.println("Add another user forwarder");
-        cs.setMBeanServerForwarder(forwarders[1]);
-        expectChain(cs, "U10", end);
-
-        System.out.println("Add a system forwarder");
-        forwarders[2].setMBeanServer(systemMBSF.getMBeanServer());
-        systemMBSF.setMBeanServer(forwarders[2]);
-        expectChain(cs, "2U10", end);
-
-        System.out.println("Add another user forwarder");
-        cs.setMBeanServerForwarder(forwarders[3]);
-        expectChain(cs, "2U310", end);
-
-        System.out.println("Add another system forwarder");
-        forwarders[4].setMBeanServer(systemMBSF.getMBeanServer());
-        systemMBSF.setMBeanServer(forwarders[4]);
-        expectChain(cs, "42U310", end);
-
-        System.out.println("Remove the first user forwarder");
-        cs.removeMBeanServerForwarder(forwarders[3]);
-        expectChain(cs, "42U10", end);
-
-        System.out.println("Remove the last user forwarder");
-        cs.removeMBeanServerForwarder(forwarders[0]);
-        expectChain(cs, "42U1", end);
-
-        System.out.println("Remove the first system forwarder");
-        cs.removeMBeanServerForwarder(forwarders[4]);
-        expectChain(cs, "2U1", end);
-
-        System.out.println("Remove the last system forwarder");
-        cs.removeMBeanServerForwarder(forwarders[2]);
-        expectChain(cs, "U1", end);
-
-        System.out.println("Remove the last forwarder");
-        cs.removeMBeanServerForwarder(forwarders[1]);
-        expectChain(cs, "U", end);
-
-        System.out.println("---Doing random manipulations---");
-        // In this loop we pick one of the forwarders at random each time.
-        // If it is already in the chain, then we remove it.  If it is not
-        // in the chain, then we do one of three things: try to remove it
-        // (expecting an exception); add it to the user chain; or add it
-        // to the system chain.
-        // A subtle point is that if there is no MBeanServer then
-        // cs.setMBeanServerForwarder(mbsf) does not change mbsf.getMBeanServer().
-        // Since we're recycling a random forwarder[i], we explicitly
-        // call mbsf.setMBeanServer(null) in this case.
-        String chain = "U";
-        Random r = new Random();
-        for (int i = 0; i < 50; i++) {
-            int fwdi = r.nextInt(10);
-            MBeanServerForwarder mbsf = forwarders[fwdi];
-            char c = (char) ('0' + fwdi);
-            int ci = chain.indexOf(c);
-            if (ci >= 0) {
-                System.out.println("Remove " + c);
-                cs.removeMBeanServerForwarder(mbsf);
-                chain = chain.substring(0, ci) + chain.substring(ci + 1);
-            } else {
-                switch (r.nextInt(3)) {
-                    case 0: { // try to remove it
-                        try {
-                            System.out.println("Try to remove absent " + c);
-                            cs.removeMBeanServerForwarder(mbsf);
-                            fail("Remove succeeded but should not have");
-                            return;
-                        } catch (NoSuchElementException e) {
-                        }
-                        break;
-                    }
-                    case 1: { // add it to the user chain
-                        System.out.println("Add " + c + " to user chain");
-                        if (cs.getMBeanServer() == null)
-                            mbsf.setMBeanServer(null);
-                        cs.setMBeanServerForwarder(mbsf);
-                        int postu = chain.indexOf('U') + 1;
-                        chain = chain.substring(0, postu) + c +
-                                chain.substring(postu);
-                        break;
-                    }
-                    case 2: { // add it to the system chain
-                        System.out.println("Add " + c + " to system chain");
-                        mbsf.setMBeanServer(systemMBSF.getMBeanServer());
-                        systemMBSF.setMBeanServer(mbsf);
-                        chain = c + chain;
-                        break;
-                    }
-                }
-            }
-            expectChain(cs, chain, end);
-        }
-    }
-
-    /*
-     * Check that the forwarder chain has the expected contents.  The forwarders
-     * are encoded as a string.  For example, "12U34" means that the system
-     * chain contains forwarders[1] followed by forwarders[2], and the user
-     * chain contains forwarders[3] followed by forwarders[4].  Since the
-     * user chain is attached to the end of the system chain, another way to
-     * look at this is that the U marks the transition from one to the other.
-     *
-     * After traversing the chains, we should be pointing at "end".
-     */
-    private static void expectChain(
-            JMXConnectorServer cs, String chain, MBeanServer end) {
-        System.out.println("...expected chain: " + chain);
-        MBeanServer curr = cs.getSystemMBeanServerForwarder().getMBeanServer();
-        int i = 0;
-        while (i < chain.length()) {
-            char c = chain.charAt(i);
-            if (c == 'U') {
-                if (cs.getMBeanServer() != curr) {
-                    fail("User chain should have started here: " + curr);
-                    return;
-                }
-            } else {
-                int fwdi = c - '0';
-                MBeanServerForwarder forwarder = forwarders[fwdi];
-                if (curr != forwarder) {
-                    fail("Expected forwarder " + c + " here: " + curr);
-                    return;
-                }
-                curr = ((MBeanServerForwarder) curr).getMBeanServer();
-            }
-            i++;
-        }
-        if (curr != end) {
-            fail("End of chain is " + curr + ", should be " + end);
-            return;
-        }
-        System.out.println("...OK");
-    }
-
-    private static void fail(String msg) {
-        System.out.println("FAILED: " + msg);
-        failure = msg;
-    }
-}
--- a/test/javax/management/remote/mandatory/connectorServer/StandardForwardersTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,193 +0,0 @@
-/*
- * 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.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.management.ClientContext;
-import javax.management.MBeanServer;
-import javax.management.event.EventClientDelegate;
-import javax.management.remote.JMXConnectorServer;
-
-/*
- * @test
- * @bug 6663757
- * @summary Tests standard MBeanServerForwarders introduced by connector server
- * options.
- * @author Eamonn McManus
- */
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.MBeanServerForwarder;
-
-public class StandardForwardersTest {
-    private static String failure;
-
-    private static class Forwarder {
-        private final String attribute;
-        private final boolean defaultEnabled;
-        private final Class<?> expectedClass;
-
-        public Forwarder(String attribute, boolean defaultEnabled,
-                         Class<?> expectedClass) {
-            this.attribute = attribute;
-            this.defaultEnabled = defaultEnabled;
-            this.expectedClass = expectedClass;
-        }
-    }
-
-    private static enum Status {DISABLED, ENABLED, DEFAULT}
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-
-        MBeanServerForwarder ctxFwd = ClientContext.newContextForwarder(mbs, null);
-        Forwarder ctx = new Forwarder(
-                JMXConnectorServer.CONTEXT_FORWARDER, true, ctxFwd.getClass());
-
-        MBeanServerForwarder locFwd =
-                ClientContext.newLocalizeMBeanInfoForwarder(mbs);
-        Forwarder loc = new Forwarder(
-                JMXConnectorServer.LOCALIZE_MBEAN_INFO_FORWARDER, false,
-                locFwd.getClass());
-
-        MBeanServerForwarder ecdFwd =
-                EventClientDelegate.newForwarder(mbs, null);
-        Forwarder ecd = new Forwarder(
-                JMXConnectorServer.EVENT_CLIENT_DELEGATE_FORWARDER, true,
-                ecdFwd.getClass());
-
-        Forwarder[] forwarders = {ctx, loc, ecd};
-
-        // Now go through every combination of forwarders.  Each forwarder
-        // may be explicitly enabled, explicitly disabled, or left to its
-        // default value.
-        int nStatus = Status.values().length;
-        int limit = (int) Math.pow(nStatus, forwarders.length);
-        for (int i = 0; i < limit; i++) {
-            Status[] status = new Status[forwarders.length];
-            int ii = i;
-            for (int j = 0; j < status.length; j++) {
-                status[j] = Status.values()[ii % nStatus];
-                ii /= nStatus;
-            }
-            Map<String, String> env = new HashMap<String, String>();
-            String test = "";
-            for (int j = 0; j < status.length; j++) {
-                if (!test.equals(""))
-                    test += "; ";
-                test += forwarders[j].attribute;
-                switch (status[j]) {
-                case DISABLED:
-                    test += "=false";
-                    env.put(forwarders[j].attribute, "false");
-                    break;
-                case ENABLED:
-                    test += "=true";
-                    env.put(forwarders[j].attribute, "true");
-                    break;
-                case DEFAULT:
-                    test += "=default(" + forwarders[j].defaultEnabled + ")";
-                    break;
-                }
-            }
-            boolean consistent = isConsistent(env);
-            test += "; (" + (consistent ? "" : "in") + "consistent)";
-            System.out.println(test);
-            JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
-            try {
-                JMXConnectorServer cs =
-                    JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
-                if (!consistent) {
-                    fail("Inconsistent attributes should have been rejected " +
-                            "but were not");
-                }
-                checkForwarders(cs, forwarders, status);
-            } catch (IllegalArgumentException e) {
-                if (consistent) {
-                    fail("Consistent attributes provoked IllegalArgumentException");
-                    e.printStackTrace(System.out);
-                }
-            }
-        }
-
-        if (failure == null)
-            System.out.println("TEST PASSED");
-        else
-            throw new Exception(failure);
-    }
-
-    // Check that the classes of the forwarders in the system chain correspond
-    // to what we expect given the options we have passed.  This check is a bit
-    // superficial in the sense that a forwarder might be for example a
-    // SingleMBeanForwarderHandler but that doesn't prove that it is the
-    // right Single MBean.  Nevertheless the test should expose any severe
-    // wrongness.
-    //
-    // The check here makes some assumptions that could become untrue in the
-    // future. First, it assumes that the forwarders that are added have
-    // exactly the classes that are in the Forwarder[] array. So for example
-    // the forwarder for CONTEXT_FORWARDER must be of the same class as an
-    // explicit call to ClientContext.newContextForwarder. The spec doesn't
-    // require that - it only requires that the forwarder have the same
-    // behaviour. The second assumption is that the connector server doesn't
-    // add any forwarders of its own into the system chain, and again the spec
-    // doesn't disallow that.
-    private static void checkForwarders(
-            JMXConnectorServer cs, Forwarder[] forwarders, Status[] status) {
-        List<Class<?>> expectedClasses = new ArrayList<Class<?>>();
-        for (int i = 0; i < forwarders.length; i++) {
-            if (status[i] == Status.ENABLED ||
-                    (status[i] == Status.DEFAULT && forwarders[i].defaultEnabled))
-                expectedClasses.add(forwarders[i].expectedClass);
-        }
-        MBeanServer stop = cs.getMBeanServer();
-        List<Class<?>> foundClasses = new ArrayList<Class<?>>();
-        for (MBeanServer mbs = cs.getSystemMBeanServerForwarder().getMBeanServer();
-             mbs != stop;
-             mbs = ((MBeanServerForwarder) mbs).getMBeanServer()) {
-            foundClasses.add(mbs.getClass());
-        }
-        if (!expectedClasses.equals(foundClasses)) {
-            fail("Incorrect forwarder chain: expected " + expectedClasses +
-                    "; found " + foundClasses);
-        }
-    }
-
-    // env is consistent if either (a) localizer is not enabled or (b)
-    // localizer is enabled and context is enabled.
-    private static boolean isConsistent(Map<String, String> env) {
-        String ctxS = env.get(JMXConnectorServer.CONTEXT_FORWARDER);
-        boolean ctx = (ctxS == null) ? true : Boolean.parseBoolean(ctxS);
-        String locS = env.get(JMXConnectorServer.LOCALIZE_MBEAN_INFO_FORWARDER);
-        boolean loc = (locS == null) ? false : Boolean.parseBoolean(locS);
-        return !loc || ctx;
-    }
-
-    private static void fail(String why) {
-        System.out.println("FAILED: " + why);
-        failure = why;
-    }
-}
--- a/test/javax/management/remote/mandatory/loading/MissingClassTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/loading/MissingClassTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -124,16 +124,7 @@
     }
 
     private static boolean test(String proto) throws Exception {
-        boolean ok = true;
-        for (boolean eventService : new boolean[] {false, true})
-            ok &= test(proto, eventService);
-        return ok;
-    }
-
-    private static boolean test(String proto, boolean eventService)
-            throws Exception {
-        System.out.println("Testing for proto " + proto + " with" +
-                (eventService ? "" : "out") + " Event Service");
+        System.out.println("Testing for proto " + proto);
 
         boolean ok = true;
 
@@ -145,8 +136,6 @@
         Map serverMap = new HashMap();
         serverMap.put(JMXConnectorServerFactory.DEFAULT_CLASS_LOADER,
                       serverLoader);
-        serverMap.put(RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                Boolean.toString(eventService));
 
         // make sure no auto-close at server side
         serverMap.put("jmx.remote.x.server.connection.timeout", "888888888");
--- a/test/javax/management/remote/mandatory/notif/AddRemoveTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/AddRemoveTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003 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
@@ -33,12 +33,10 @@
  */
 
 import java.net.MalformedURLException;
+import java.io.IOException;
 
-import java.util.Collections;
-import java.util.Map;
 import javax.management.*;
 import javax.management.remote.*;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class AddRemoveTest {
     private static final String[] protocols = {"rmi", "iiop", "jmxmp"};
@@ -71,16 +69,9 @@
         }
     }
 
-    private static boolean test(String proto) throws Exception {
-        boolean ok = test(proto, false);
-        ok &= test(proto, true);
-        return ok;
-    }
-
-    private static boolean test(String proto, boolean eventService)
+    private static boolean test(String proto)
             throws Exception {
-        System.out.println(">>> Test for protocol " + proto + " with" +
-                (eventService ? "" : "out") + " event service");
+        System.out.println(">>> Test for protocol " + proto);
         JMXServiceURL u = new JMXServiceURL(proto, null, 0);
         JMXConnectorServer server;
         JMXServiceURL addr;
@@ -98,10 +89,7 @@
 
         try {
             // with a client listener, but close the server first
-            Map<String, String> env = Collections.singletonMap(
-                    RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                    Boolean.toString(eventService));
-            server = JMXConnectorServerFactory.newJMXConnectorServer(u, env, mbs);
+            server = JMXConnectorServerFactory.newJMXConnectorServer(u, null, mbs);
             server.start();
 
             addr = server.getAddress();
--- a/test/javax/management/remote/mandatory/notif/DiffHBTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/DiffHBTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -32,11 +32,8 @@
  */
 
 
-import java.util.Collections;
-import java.util.Map;
 import javax.management.*;
 import javax.management.remote.*;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 /**
  * This test registeres an unique listener with two different handbacks,
@@ -80,33 +77,14 @@
     }
 
     private static String test(String proto) throws Exception {
-        String ret = null;
-        for (boolean eventService : new boolean[] {false, true}) {
-            String s = test(proto, eventService);
-            if (s != null) {
-                if (ret == null)
-                    ret = s;
-                else
-                    ret = ret + "; " + s;
-            }
-        }
-        return ret;
-    }
-
-    private static String test(String proto, boolean eventService)
-            throws Exception {
-        System.out.println(">>> Test for protocol " + proto + " with" +
-                (eventService ? "" : "out") + " event service");
+        System.out.println(">>> Test for protocol " + proto);
         JMXServiceURL u = new JMXServiceURL(proto, null, 0);
         JMXConnectorServer server;
         JMXConnector client;
 
         try {
-            Map<String, String> env = Collections.singletonMap(
-                    RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                    Boolean.toString(eventService));
             server =
-                    JMXConnectorServerFactory.newJMXConnectorServer(u, env, mbs);
+                    JMXConnectorServerFactory.newJMXConnectorServer(u, null, mbs);
             server.start();
             JMXServiceURL addr = server.getAddress();
             client = JMXConnectorFactory.connect(addr, null);
--- a/test/javax/management/remote/mandatory/notif/EmptyDomainNotificationTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/EmptyDomainNotificationTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2005 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,12 +29,11 @@
  * @author Shanliang JIANG
  * @run clean EmptyDomainNotificationTest
  * @run build EmptyDomainNotificationTest
- * @run main EmptyDomainNotificationTest classic
- * @run main EmptyDomainNotificationTest event
+ * @run main EmptyDomainNotificationTest
  */
 
-import java.util.Collections;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerConnection;
 import javax.management.MBeanServerFactory;
@@ -47,7 +46,6 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class EmptyDomainNotificationTest {
 
@@ -82,25 +80,11 @@
 
     public static void main(String[] args) throws Exception {
 
-        String type = args[0];
-        boolean eventService;
-        if (type.equals("classic"))
-            eventService = false;
-        else if (type.equals("event"))
-            eventService = true;
-        else
-            throw new IllegalArgumentException(type);
-
         final MBeanServer mbs = MBeanServerFactory.createMBeanServer();
 
         final JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
 
-        Map<String, String> env = Collections.singletonMap(
-                RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                Boolean.toString(eventService));
-
-        JMXConnectorServer server =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
+        JMXConnectorServer server = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
         server.start();
 
         JMXConnector client = JMXConnectorFactory.connect(server.getAddress(), null);
--- a/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/ListenerScaleTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -51,8 +51,6 @@
  * been compiled by the second.
  */
 
-import java.util.Collections;
-import java.util.Map;
 import java.util.concurrent.Semaphore;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerConnection;
@@ -67,7 +65,6 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class ListenerScaleTest {
     private static final int WARMUP_WITH_ONE_MBEAN = 1000;
@@ -128,20 +125,12 @@
         };
 
     public static void main(String[] args) throws Exception {
-        test(false);
-        test(true);
-    }
-
-    private static void test(boolean eventService) throws Exception {
         MBeanServer mbs = MBeanServerFactory.newMBeanServer();
         Sender sender = new Sender();
         mbs.registerMBean(sender, testObjectName);
         JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://");
-        Map<String, String> env = Collections.singletonMap(
-                RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                Boolean.toString(eventService));
         JMXConnectorServer cs =
-            JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
+            JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
         cs.start();
         JMXServiceURL addr = cs.getAddress();
         JMXConnector cc = JMXConnectorFactory.connect(addr);
--- a/test/javax/management/remote/mandatory/notif/NotifBufferSizePropertyNameTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/NotifBufferSizePropertyNameTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2004-2005 Sun Microsystems, Inc.  All Rights Reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,11 +31,11 @@
  * @run main NotifBufferSizePropertyNameTest
  */
 
+import java.io.IOException;
 import java.util.*;
 
 import javax.management.*;
 import javax.management.remote.*;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 /**
  * This class tests also the size of a server notification buffer.
@@ -88,9 +88,6 @@
     private static void test(Map env) throws Exception {
         final MBeanServer mbs = MBeanServerFactory.newMBeanServer();
 
-        env = new HashMap((env == null) ? Collections.emptyMap() : env);
-        env.put(RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false");
-
         mbs.registerMBean(new NotificationEmitter(), oname);
         JMXConnectorServer server = JMXConnectorServerFactory.newJMXConnectorServer(
                                                                                url,
--- a/test/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/NotifReconnectDeadlockTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -45,7 +45,6 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 /**
  * "This test checks for a bug whereby reconnection did not work if (a) it was
@@ -74,7 +73,6 @@
         Map env = new HashMap(2);
         env.put("jmx.remote.x.server.connection.timeout", new Long(serverTimeout));
         env.put("jmx.remote.x.client.connection.check.period", new Long(Long.MAX_VALUE));
-        env.put(RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false");
 
         final MBeanServer mbs = MBeanServerFactory.newMBeanServer();
 
--- a/test/javax/management/remote/mandatory/notif/NotificationBufferCreationTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/NotificationBufferCreationTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright 2003-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
@@ -32,8 +32,6 @@
  */
 import java.net.MalformedURLException;
 
-import java.util.Collections;
-import java.util.Map;
 import javax.management.MBeanServerFactory;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerConnection;
@@ -46,7 +44,6 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class NotificationBufferCreationTest {
     private static final MBeanServer mbs =
@@ -89,8 +86,6 @@
         JMXServiceURL u = null;
         try {
             u = new JMXServiceURL(protocol, null, 0);
-            Map<String, String> env = Collections.singletonMap(
-                    RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, "false");
             server =
                 JMXConnectorServerFactory.newJMXConnectorServer(u,
                                                                 null,
--- a/test/javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/NotificationBufferDeadlockTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
+ * 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
@@ -35,9 +35,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
-import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import java.util.Vector;
 import javax.management.*;
@@ -90,7 +88,6 @@
  * If the logic for adding the notification buffer's listener is incorrect
  * we could remove zero or two notifications from an MBean.
  */
-import javax.management.remote.rmi.RMIConnectorServer;
 public class NotificationBufferDeadlockTest {
     public static void main(String[] args) throws Exception {
         System.out.println("Check no deadlock if notif sent while initial " +
@@ -112,13 +109,7 @@
     }
 
     private static void test(String proto) throws Exception {
-        test(proto, false);
-        test(proto, true);
-    }
-
-    private static void test(String proto, boolean eventService) throws Exception {
-        System.out.println("Testing protocol " + proto + " with" +
-                (eventService ? "" : "out") + " event service");
+        System.out.println("Testing protocol " + proto);
         MBeanServer mbs = MBeanServerFactory.newMBeanServer();
         ObjectName testName = newName();
         DeadlockTest test = new DeadlockTest();
@@ -126,11 +117,8 @@
         JMXServiceURL url = new JMXServiceURL("service:jmx:" + proto + ":///");
         JMXConnectorServer cs;
         try {
-            Map<String, String> env = Collections.singletonMap(
-                    RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                    Boolean.toString(eventService));
             cs =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
+                JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
         } catch (MalformedURLException e) {
             System.out.println("...protocol not supported, ignoring");
             return;
--- a/test/javax/management/remote/mandatory/notif/NotificationEmissionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/NotificationEmissionTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -29,16 +29,11 @@
  * @author Luis-Miguel Alventosa
  * @run clean NotificationEmissionTest
  * @run build NotificationEmissionTest
- * @run main NotificationEmissionTest 1 Classic
- * @run main NotificationEmissionTest 2 Classic
- * @run main NotificationEmissionTest 3 Classic
- * @run main NotificationEmissionTest 4 Classic
- * @run main NotificationEmissionTest 5 Classic
- * @run main NotificationEmissionTest 1 EventService
- * @run main NotificationEmissionTest 2 EventService
- * @run main NotificationEmissionTest 3 EventService
- * @run main NotificationEmissionTest 4 EventService
- * @run main NotificationEmissionTest 5 EventService
+ * @run main NotificationEmissionTest 1
+ * @run main NotificationEmissionTest 2
+ * @run main NotificationEmissionTest 3
+ * @run main NotificationEmissionTest 4
+ * @run main NotificationEmissionTest 5
  */
 
 import java.io.File;
@@ -61,15 +56,9 @@
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXPrincipal;
 import javax.management.remote.JMXServiceURL;
-import javax.management.remote.rmi.RMIConnectorServer;
 import javax.security.auth.Subject;
 
 public class NotificationEmissionTest {
-    private final boolean eventService;
-
-    public NotificationEmissionTest(boolean eventService) {
-        this.eventService = eventService;
-    }
 
     public class CustomJMXAuthenticator implements JMXAuthenticator {
         public Subject authenticate(Object credentials) {
@@ -228,13 +217,8 @@
             //
             final Map<String,Object> env = new HashMap<String,Object>();
             env.put("jmx.remote.authenticator", new CustomJMXAuthenticator());
-            env.put(RMIConnectorServer.EVENT_CLIENT_DELEGATE_FORWARDER,
-                    Boolean.toString(eventService));
-            if (prop) {
-                echo("Setting jmx.remote.x.check.notification.emission to " +
-                        propValue);
+            if (prop)
                 env.put("jmx.remote.x.check.notification.emission", propValue);
-            }
 
             // Create the JMXServiceURL
             //
@@ -302,14 +286,11 @@
             // If the check is effective and we're using policy.negative,
             // then we should see the two notifs sent by nb2 (of which one
             // has a getSource() that is nb3), but not the notif sent by nb1.
-            // Otherwise we should see all three notifs.  If we're using the
-            // Event Service with a Security Manager then the logic to
-            // reapply the addNL permission test for every notification is
-            // always enabled, regardless of the value of
-            // jmx.remote.x.check.notification.emission.  Otherwise, the
-            // test is only applied if that property is explicitly true.
+            // Otherwise we should see all three notifs.  The check is only
+            // effective if the property jmx.remote.x.check.notification.emission
+            // is explicitly true and there is a security manager.
             int expectedNotifs =
-                    ((prop || eventService) && sm && !policyPositive) ? 2 : 3;
+                    (prop && sm && !policyPositive) ? 2 : 3;
 
             // Wait for notifications to be emitted
             //
@@ -324,15 +305,14 @@
             mbsc.removeNotificationListener(nb2, li);
 
             int result = 0;
-            List<ObjectName> sources = new ArrayList();
+            List<ObjectName> sources = new ArrayList<ObjectName>();
             sources.add(nb1);
             sources.add(nb2);
             sources.add(nb3);
 
             result = checkNotifs(expectedNotifs, li.notifs, sources);
             if (result > 0) {
-                echo("...SecurityManager=" + sm + "; policy=" + policyPositive +
-                        "; eventService=" + eventService);
+                echo("...SecurityManager=" + sm + "; policy=" + policyPositive);
                 return result;
             }
         } finally {
@@ -362,18 +342,9 @@
     public static void main(String[] args) throws Exception {
 
         echo("\n--- Check the emission of notifications " +
-             "when a Security Manager is installed [" +
-             args[1] + "] ---");
+             "when a Security Manager is installed");
 
-        boolean eventService;
-        if (args[1].equals("Classic"))
-            eventService = false;
-        else if (args[1].equals("EventService"))
-            eventService = true;
-        else
-            throw new IllegalArgumentException(args[1]);
-
-        NotificationEmissionTest net = new NotificationEmissionTest(eventService);
+        NotificationEmissionTest net = new NotificationEmissionTest();
 
         int error = 0;
 
--- a/test/javax/management/remote/mandatory/notif/RMINotifTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/RMINotifTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -25,10 +25,11 @@
  * @test
  * @bug 7654321
  * @summary Tests to receive notifications for opened and closed connections
+ions
  * @author sjiang
  * @run clean RMINotifTest
  * @run build RMINotifTest
- * @run main RMINotifTest classic
+ * @run main RMINotifTest
  * @run main RMINotifTest event
  */
 
@@ -38,8 +39,6 @@
 import java.rmi.RemoteException;
 import java.rmi.registry.LocateRegistry;
 import java.rmi.registry.Registry;
-import java.util.Collections;
-import java.util.Map;
 import java.util.Random;
 import javax.management.MBeanNotificationInfo;
 import javax.management.MBeanServer;
@@ -56,19 +55,10 @@
 import javax.management.remote.JMXConnectorServer;
 import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
-import javax.management.remote.rmi.RMIConnectorServer;
 
 public class RMINotifTest {
 
     public static void main(String[] args) {
-        String eventService;
-        if (args[0].equals("classic"))
-            eventService = "false";
-        else if (args[0].equals("event"))
-            eventService = "true";
-        else
-            throw new IllegalArgumentException(args[0]);
-
         try {
             // create a rmi registry
             Registry reg = null;
@@ -105,10 +95,9 @@
                                   "/jndi/rmi://:" + port + "/server" + port);
             System.out.println("RMIConnectorServer address " + url);
 
-            Map<String, String> env = Collections.singletonMap(
-                    RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE, eventService);
             JMXConnectorServer sServer =
-                JMXConnectorServerFactory.newJMXConnectorServer(url, env, null);
+                JMXConnectorServerFactory.newJMXConnectorServer(url, null,
+                                                                null);
 
             ObjectInstance ss = server.registerMBean(sServer, new ObjectName("Default:name=RmiConnectorServer"));
 
--- a/test/javax/management/remote/mandatory/notif/UnexpectedNotifTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/javax/management/remote/mandatory/notif/UnexpectedNotifTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -63,17 +63,13 @@
         } catch (ClassNotFoundException e) {
             // OK: JMXMP not present so don't test it.
         }
-        for (String proto : protos) {
-            test(proto, false);
-            test(proto, true);
-        }
+        for (String proto : protos)
+            test(proto);
     }
 
-    private static void test(String proto, boolean eventService)
-            throws Exception {
+    private static void test(String proto) throws Exception {
         System.out.println("Unexpected notifications test for protocol " +
-                           proto + " with" +
-                           (eventService ? "" : "out") + " event service");
+                           proto);
         MBeanServer mbs = null;
         try {
             // Create a MBeanServer
@@ -88,12 +84,9 @@
             // Create a connector server
             //
             url = new JMXServiceURL("service:jmx:" + proto + "://");
-            Map<String, String> env = Collections.singletonMap(
-                    RMIConnectorServer.DELEGATE_TO_EVENT_SERVICE,
-                    Boolean.toString(eventService));
 
             server = JMXConnectorServerFactory.newJMXConnectorServer(url,
-                                                                     env,
+                                                                     null,
                                                                      mbs);
 
             mbs.registerMBean(
--- a/test/javax/management/remote/mandatory/version/JMXSpecVersionTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,308 +0,0 @@
-/*
- * 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 6750008
- * @summary Test JMX.getSpecificationVersion
- * @author Eamonn McManus
- */
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.ListIterator;
-import java.util.Set;
-import javax.management.Attribute;
-import javax.management.AttributeList;
-import javax.management.AttributeNotFoundException;
-import javax.management.DynamicMBean;
-import javax.management.InstanceNotFoundException;
-import javax.management.InvalidAttributeValueException;
-import javax.management.JMX;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.MBeanServerDelegate;
-import javax.management.MBeanServerDelegateMBean;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import javax.management.StandardMBean;
-import javax.management.namespace.JMXNamespace;
-import javax.management.namespace.JMXNamespaces;
-import javax.management.namespace.MBeanServerSupport;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-public class JMXSpecVersionTest {
-    private static String failure;
-    private static final Object POISON_PILL = new Object();
-
-    private static class FakeDelegate implements DynamicMBean {
-        private final Object specVersion;
-        private final DynamicMBean delegate = new StandardMBean(
-                new MBeanServerDelegate(), MBeanServerDelegateMBean.class, false);
-
-        FakeDelegate(Object specVersion) {
-            this.specVersion = specVersion;
-        }
-
-        public Object getAttribute(String attribute)
-                throws AttributeNotFoundException, MBeanException,
-                ReflectionException {
-            if ("SpecificationVersion".equals(attribute)) {
-                if (specVersion == POISON_PILL)
-                    throw new AttributeNotFoundException(attribute);
-                else
-                    return specVersion;
-            } else
-                return delegate.getAttribute(attribute);
-        }
-
-        public void setAttribute(Attribute attribute)
-                throws AttributeNotFoundException, InvalidAttributeValueException,
-                MBeanException, ReflectionException {
-            delegate.setAttribute(attribute);
-        }
-
-        public AttributeList getAttributes(String[] attributes) {
-            AttributeList list = delegate.getAttributes(attributes);
-            for (ListIterator<Attribute> it = list.asList().listIterator();
-                 it.hasNext(); ) {
-                Attribute attr = it.next();
-                if (attr.getName().equals("SpecificationVersion")) {
-                    it.remove();
-                    if (specVersion != POISON_PILL) {
-                        attr = new Attribute(attr.getName(), specVersion);
-                        it.add(attr);
-                    }
-                }
-            }
-            return list;
-        }
-
-        public AttributeList setAttributes(AttributeList attributes) {
-            return delegate.setAttributes(attributes);
-        }
-
-        public Object invoke(String actionName, Object[] params,
-                             String[] signature) throws MBeanException,
-                                                        ReflectionException {
-            return delegate.invoke(actionName, params, signature);
-        }
-
-        public MBeanInfo getMBeanInfo() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-    }
-
-    private static class MBeanServerWithVersion extends MBeanServerSupport {
-        private final DynamicMBean delegate;
-
-        public MBeanServerWithVersion(Object specVersion) {
-            this.delegate = new FakeDelegate(specVersion);
-        }
-
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name)
-                throws InstanceNotFoundException {
-            if (MBeanServerDelegate.DELEGATE_NAME.equals(name))
-                return delegate;
-            else
-                throw new InstanceNotFoundException(name);
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            return Collections.singleton(MBeanServerDelegate.DELEGATE_NAME);
-        }
-    }
-
-    private static class EmptyMBeanServer extends MBeanServerSupport {
-        @Override
-        public DynamicMBean getDynamicMBeanFor(ObjectName name) throws InstanceNotFoundException {
-            throw new InstanceNotFoundException(name);
-        }
-
-        @Override
-        protected Set<ObjectName> getNames() {
-            return Collections.emptySet();
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        MBeanServer mbs = MBeanServerFactory.newMBeanServer();
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///");
-        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(
-                url, null, mbs);
-        cs.start();
-
-        String realVersion = (String) mbs.getAttribute(
-                MBeanServerDelegate.DELEGATE_NAME, "SpecificationVersion");
-        assertEquals("Reported local version",
-                realVersion, JMX.getSpecificationVersion(mbs, null));
-        assertEquals("Reported local version >= \"2.0\"",
-                true, (realVersion.compareTo("2.0") >= 0));
-
-        JMXConnector cc = JMXConnectorFactory.connect(cs.getAddress());
-        MBeanServerConnection mbsc = cc.getMBeanServerConnection();
-        assertEquals("Reported remote version",
-                realVersion, JMX.getSpecificationVersion(mbsc, null));
-
-        cc.close();
-        try {
-            String brokenVersion = JMX.getSpecificationVersion(mbsc, null);
-            fail("JMX.getSpecificationVersion succeded over closed connection" +
-                    " (returned " + brokenVersion + ")");
-        } catch (Exception e) {
-            assertEquals("Exception for closed connection",
-                    IOException.class, e.getClass());
-        }
-
-        try {
-            String brokenVersion = JMX.getSpecificationVersion(
-                    new EmptyMBeanServer(), null);
-            fail("JMX.getSpecificationVersion succeded with empty MBean Server" +
-                    " (returned " + brokenVersion + ")");
-        } catch (Exception e) {
-            assertEquals("Exception for empty MBean Server",
-                    IOException.class, e.getClass());
-        }
-
-        try {
-            String brokenVersion = JMX.getSpecificationVersion(null, null);
-            fail("JMX.getSpecificationVersion succeded with null MBean Server" +
-                    " (returned " + brokenVersion + ")");
-        } catch (Exception e) {
-            assertEquals("Exception for null MBean Server",
-                    IllegalArgumentException.class, e.getClass());
-        }
-
-        MBeanServer mbs1_2 = new MBeanServerWithVersion("1.2");
-        String version1_2 = JMX.getSpecificationVersion(mbs1_2, null);
-        assertEquals("Version for 1.2 MBean Server", "1.2", version1_2);
-
-        // It's completely nutty for an MBean Server to return null as the
-        // value of its spec version, and we don't actually say what happens
-        // in that case, but in fact we return the null to the caller.
-        MBeanServer mbs_null = new MBeanServerWithVersion(null);
-        String version_null = JMX.getSpecificationVersion(mbs_null, null);
-        assertEquals("Version for MBean Server that declares null spec version",
-                null, version_null);
-
-        try {
-            MBeanServer mbs1_2_float = new MBeanServerWithVersion(1.2f);
-            String version1_2_float =
-                    JMX.getSpecificationVersion(mbs1_2_float, null);
-            fail("JMX.getSpecificationVersion succeeded with version 1.2f" +
-                    " (returned " + version1_2_float + ")");
-        } catch (Exception e) {
-            assertEquals("Exception for non-string version (1.2f)",
-                    IOException.class, e.getClass());
-        }
-
-        try {
-            MBeanServer mbs_missing = new MBeanServerWithVersion(POISON_PILL);
-            String version_missing =
-                    JMX.getSpecificationVersion(mbs_missing, null);
-            fail("JMX.getSpecificationVersion succeeded with null version" +
-                    " (returned " + version_missing + ")");
-        } catch (Exception e) {
-            assertEquals("Exception for missing version",
-                    IOException.class, e.getClass());
-        }
-
-        ObjectName wildcardNamespaceName = new ObjectName("foo//*//bar//baz:k=v");
-        try {
-            String brokenVersion =
-                    JMX.getSpecificationVersion(mbsc, wildcardNamespaceName);
-            fail("JMX.getSpecificationVersion succeeded with wildcard namespace" +
-                    " (returned " + brokenVersion + ")");
-        } catch (Exception e) {
-            assertEquals("Exception for wildcard namespace",
-                    IllegalArgumentException.class, e.getClass());
-        }
-
-        String sub1_2namespace = "blibby";
-        JMXNamespace sub1_2 = new JMXNamespace(mbs1_2);
-        ObjectName sub1_2name =
-                JMXNamespaces.getNamespaceObjectName(sub1_2namespace);
-        mbs.registerMBean(sub1_2, sub1_2name);
-        String sub1_2namespaceHandlerVersion =
-                JMX.getSpecificationVersion(mbs, sub1_2name);
-        assertEquals("Spec version of namespace handler",
-                realVersion, sub1_2namespaceHandlerVersion);
-        // The namespace handler is in the top-level namespace so its
-        // version should not be 1.2.
-
-        for (String nameInSub : new String[] {"*:*", "d:k=v"}) {
-            ObjectName subName = new ObjectName(sub1_2namespace + "//" + nameInSub);
-            String subVersion = JMX.getSpecificationVersion(mbs, subName);
-            assertEquals("Spec version in 1.2 namespace (" + nameInSub + ")",
-                    "1.2", subVersion);
-        }
-
-        mbs.unregisterMBean(sub1_2name);
-        for (String noSuchNamespace : new String[] {
-            sub1_2namespace + "//*:*", sub1_2namespace + "//d:k=v",
-        }) {
-            try {
-                String brokenVersion = JMX.getSpecificationVersion(
-                        mbs, new ObjectName(noSuchNamespace));
-                fail("JMX.getSpecificationVersion succeeded with missing " +
-                        "namespace (" + noSuchNamespace + " -> " +
-                        brokenVersion);
-            } catch (Exception e) {
-                assertEquals("Exception for missing namespace",
-                        IOException.class, e.getClass());
-            }
-        }
-
-        if (failure != null)
-            throw new Exception("TEST FAILED: " + failure);
-        System.out.println("TEST PASSED");
-    }
-
-    private static void assertEquals(String what, Object expect, Object actual) {
-        if (equal(expect, actual))
-            System.out.println("OK: " + what + ": " + expect);
-        else
-            fail(what + ": expected " + expect + ", got " + actual);
-    }
-
-    private static  boolean equal(Object x, Object y) {
-        if (x == null)
-            return (y == null);
-        else
-            return x.equals(y);
-    }
-
-    private static void fail(String why) {
-        System.out.println("FAILED: " + why);
-        failure = why;
-    }
-}
--- a/test/javax/management/standardmbean/FindMethodTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,384 +0,0 @@
-/*
- * 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 6287328
- * @summary Add methods to StandardMBean to retrieve a method based on
- * MBean{Attribute|Operation}Info
- * @author Jean-Francois Denise
- * @run main FindMethodTest
- */
-
-import java.lang.management.ManagementFactory;
-import java.lang.management.MemoryMXBean;
-import java.lang.management.ThreadMXBean;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import javax.management.MBean;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanParameterInfo;
-import javax.management.MBeanServer;
-import javax.management.ManagedAttribute;
-import javax.management.ManagedOperation;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-public class FindMethodTest {
-
-    private static MBeanServer server =
-            ManagementFactory.getPlatformMBeanServer();
-
-    private static Map<String, Set<Method>> expectedMapping =
-            new HashMap<String, Set<Method>>();
-    private static Set<Method> STATE_SET = new HashSet<Method>();
-    private static Set<Method> ENABLED_SET = new HashSet<Method>();
-    private static Set<Method> DOIT_SET = new HashSet<Method>();
-    private static Set<Method> STATUS_SET = new HashSet<Method>();
-    private static Set<Method> HEAPMEMORYUSAGE_SET = new HashSet<Method>();
-    private static Set<Method> THREADINFO_SET = new HashSet<Method>();
-    private static Set<Method> DOIT_ANNOTATED_SET = new HashSet<Method>();
-    private static Set<Method> IT_ANNOTATED_SET = new HashSet<Method>();
-    private static HashSet<Set<Method>> TEST_MBEAN_SET =
-            new HashSet<Set<Method>>();
-    private static HashSet<Set<Method>> ANNOTATED_MBEAN_SET =
-            new HashSet<Set<Method>>();
-    private static HashSet<Set<Method>> MEMORY_MBEAN_SET =
-            new HashSet<Set<Method>>();
-    private static HashSet<Set<Method>> THREAD_MBEAN_SET =
-            new HashSet<Set<Method>>();
-
-    public interface TestMBean {
-
-        public void doIt();
-
-        public void setState(String str);
-
-        public String getState();
-
-        public boolean isEnabled();
-
-        public void setStatus(int i);
-    }
-
-    public interface FaultyTestMBean {
-
-        public void doIt(String doIt);
-
-        public long getState();
-
-        public void setEnabled(boolean b);
-
-        public int getStatus();
-
-        public String setWrong(int i);
-    }
-
-    @MBean
-    public static class AnnotatedTest {
-        @ManagedOperation
-        public void doItAnnotated() {
-
-        }
-
-        public void dontDoIt() {
-
-        }
-
-        @ManagedAttribute
-        public String getItAnnotated() {
-            return null;
-        }
-        @ManagedAttribute
-        public void setItAnnotated(String str) {
-
-        }
-
-        public String getItNot() {
-            return null;
-        }
-
-    }
-
-    static class Test implements TestMBean {
-
-        public void doIt() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setState(String str) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public String getState() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public boolean isEnabled() {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-
-        public void setStatus(int i) {
-            throw new UnsupportedOperationException("Not supported yet.");
-        }
-    }
-
-
-    static {
-        try {
-            ENABLED_SET.add(TestMBean.class.getDeclaredMethod("isEnabled"));
-
-            STATE_SET.add(TestMBean.class.getDeclaredMethod("getState"));
-            STATE_SET.add(TestMBean.class.getDeclaredMethod("setState",
-                    String.class));
-            STATUS_SET.add(TestMBean.class.getDeclaredMethod("setStatus",
-                    int.class));
-
-            DOIT_SET.add(TestMBean.class.getDeclaredMethod("doIt"));
-
-            DOIT_ANNOTATED_SET.add(AnnotatedTest.class.getDeclaredMethod("doItAnnotated"));
-
-            IT_ANNOTATED_SET.add(AnnotatedTest.class.getDeclaredMethod("getItAnnotated"));
-            IT_ANNOTATED_SET.add(AnnotatedTest.class.getDeclaredMethod("setItAnnotated", String.class));
-
-            THREADINFO_SET.add(ThreadMXBean.class.getDeclaredMethod("dumpAllThreads", boolean.class,
-                    boolean.class));
-
-            HEAPMEMORYUSAGE_SET.add(MemoryMXBean.class.getDeclaredMethod("getHeapMemoryUsage"));
-
-            TEST_MBEAN_SET.add(ENABLED_SET);
-            TEST_MBEAN_SET.add(STATE_SET);
-            TEST_MBEAN_SET.add(STATUS_SET);
-            TEST_MBEAN_SET.add(DOIT_SET);
-
-            ANNOTATED_MBEAN_SET.add(DOIT_ANNOTATED_SET);
-            ANNOTATED_MBEAN_SET.add(IT_ANNOTATED_SET);
-
-            MEMORY_MBEAN_SET.add(HEAPMEMORYUSAGE_SET);
-
-            THREAD_MBEAN_SET.add(THREADINFO_SET);
-
-            expectedMapping.put("State", STATE_SET);
-            expectedMapping.put("Enabled", ENABLED_SET);
-            expectedMapping.put("Status", STATUS_SET);
-            expectedMapping.put("doIt", DOIT_SET);
-            expectedMapping.put("HeapMemoryUsage", HEAPMEMORYUSAGE_SET);
-            expectedMapping.put("dumpAllThreads", THREADINFO_SET);
-            expectedMapping.put("doItAnnotated", DOIT_ANNOTATED_SET);
-            expectedMapping.put("ItAnnotated", IT_ANNOTATED_SET);
-
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            throw new RuntimeException("Initialization failed");
-        }
-    }
-
-    private static void testMBean(ObjectName name, Class<?> itf,
-            HashSet<Set<Method>> expectMappings)
-            throws Exception {
-
-        Set<Set<Method>> expectedMappings =
-                (Set<Set<Method>>) expectMappings.clone();
-
-        MBeanInfo info = server.getMBeanInfo(name);
-        for (MBeanAttributeInfo attr : info.getAttributes()) {
-            Set<Method> expected = expectedMapping.get(attr.getName());
-            if (expected == null) {
-                continue;
-            }
-            if (!expectedMappings.remove(expected)) {
-                throw new Exception("The mapping to use is not the expected " +
-                        "one for " + attr);
-            }
-            System.out.println("Expected : " + expected);
-            Set<Method> found =
-                    StandardMBean.findAttributeAccessors(itf, attr);
-            System.out.println("Found : " + found);
-            if (!found.equals(expected)) {
-                throw new Exception("Mapping error.");
-            }
-        }
-        for (MBeanOperationInfo op : info.getOperations()) {
-            Set<Method> expected = expectedMapping.get(op.getName());
-            if (expected == null) {
-                continue;
-            }
-            if (!expectedMappings.remove(expected)) {
-                throw new Exception("The mapping to use is not the expected " +
-                        "one for " + op);
-            }
-            System.out.println("Expected : " + expected);
-            Method method =
-                    StandardMBean.findOperationMethod(itf, op);
-            Set<Method> found = new HashSet<Method>();
-            found.add(method);
-            System.out.println("Found : " + found);
-            if (!found.equals(expected)) {
-                throw new Exception("Mapping error.");
-            }
-        }
-
-        if (expectedMappings.size() != 0) {
-            throw new Exception("Some mapping have not been found " +
-                    expectedMappings);
-        } else {
-            System.out.println("All mappings have been found");
-        }
-    }
-
-    public static void main(String[] args) throws Exception {
-        // Positive tests
-        Test t = new Test();
-        ObjectName name = ObjectName.valueOf(":type=Test");
-        server.registerMBean(t, name);
-        AnnotatedTest at = new AnnotatedTest();
-        ObjectName annotatedName = ObjectName.valueOf(":type=AnnotatedTest");
-        server.registerMBean(at, annotatedName);
-
-        testMBean(name, TestMBean.class, TEST_MBEAN_SET);
-
-        testMBean(annotatedName, AnnotatedTest.class, ANNOTATED_MBEAN_SET);
-
-        ObjectName memoryName =
-                ObjectName.valueOf(ManagementFactory.MEMORY_MXBEAN_NAME);
-        testMBean(memoryName, MemoryMXBean.class, MEMORY_MBEAN_SET);
-
-        ObjectName threadName =
-                ObjectName.valueOf(ManagementFactory.THREAD_MXBEAN_NAME);
-        testMBean(threadName, ThreadMXBean.class, THREAD_MBEAN_SET);
-
-        // Negative tests
-        try {
-            StandardMBean.findOperationMethod(null,
-                    new MBeanOperationInfo("Test",
-                    TestMBean.class.getDeclaredMethod("doIt")));
-            throw new Exception("Expected exception not found");
-        } catch (IllegalArgumentException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        try {
-            StandardMBean.findOperationMethod(TestMBean.class, null);
-            throw new Exception("Expected exception not found");
-        } catch (IllegalArgumentException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        try {
-            StandardMBean.findAttributeAccessors(null,
-                    new MBeanAttributeInfo("Test", "Test",
-                    TestMBean.class.getDeclaredMethod("getState"),
-                    TestMBean.class.getDeclaredMethod("setState",
-                    String.class)));
-            throw new Exception("Expected exception not found");
-        } catch (IllegalArgumentException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        try {
-            StandardMBean.findAttributeAccessors(TestMBean.class, null);
-            throw new Exception("Expected exception not found");
-        } catch (IllegalArgumentException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        //Wrong operation signature
-        try {
-            StandardMBean.findOperationMethod(TestMBean.class,
-                    new MBeanOperationInfo("FaultyTest",
-                    FaultyTestMBean.class.getDeclaredMethod("doIt",
-                    String.class)));
-            throw new Exception("Expected exception not found");
-        } catch (NoSuchMethodException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        //Wrong attribute accessor
-        try {
-            StandardMBean.findAttributeAccessors(TestMBean.class,
-                    new MBeanAttributeInfo("FaultyTest", "FaultyTest", null,
-                    FaultyTestMBean.class.getDeclaredMethod("setEnabled",
-                    String.class)));
-            throw new Exception("Expected exception not found");
-        } catch (NoSuchMethodException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        //Wrong attribute type
-        try {
-            StandardMBean.findAttributeAccessors(TestMBean.class,
-                    new MBeanAttributeInfo("State", "toto.FaultType",
-                    "FaultyTest", true, true, false));
-            throw new Exception("Expected exception not found");
-        } catch (ClassNotFoundException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        //Wrong operation parameter type
-        try {
-            MBeanParameterInfo[] p = {new MBeanParameterInfo("p1",
-                "toto.FaultType2", "FaultyParameter")
-            };
-            StandardMBean.findOperationMethod(TestMBean.class,
-                    new MBeanOperationInfo("doIt", "FaultyMethod", p, "void",
-                    0));
-            throw new Exception("Expected exception not found");
-        } catch (ClassNotFoundException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        // Check that not annotated attributes are not found
-        try {
-            StandardMBean.findAttributeAccessors(AnnotatedTest.class,
-                    new MBeanAttributeInfo("ItNot", String.class.getName(),
-                    "FaultyTest", true, false, false));
-            throw new Exception("Expected exception not found");
-        } catch (NoSuchMethodException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        // Check that not annotated operations are not found
-        try {
-            StandardMBean.findOperationMethod(AnnotatedTest.class,
-                    new MBeanOperationInfo("dontDoIt","dontDoIt",null,
-                    Void.TYPE.getName(),0));
-            throw new Exception("Expected exception not found");
-        } catch (NoSuchMethodException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-        // Check that wrong getter return type throws Exception
-        try {
-            StandardMBean.findAttributeAccessors(AnnotatedTest.class,
-                    new MBeanAttributeInfo("ItAnnotated", Long.class.getName(),
-                    "FaultyTest", true, false, false));
-            throw new Exception("Expected exception not found");
-        } catch (NoSuchMethodException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-         // Check that wrong setter return type throws Exception
-        try {
-            StandardMBean.findAttributeAccessors(FaultyTestMBean.class,
-                    new MBeanAttributeInfo("Wrong", String.class.getName(),
-                    "FaultyTest", true, true, false));
-            throw new Exception("Expected exception not found");
-        } catch (NoSuchMethodException ex) {
-            System.out.println("OK received expected exception " + ex);
-        }
-    }
-}
--- a/test/javax/management/standardmbean/RegistrationTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * 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 6450834
- * @summary Forward MBeanRegistration calls
- * @author JF Denise
- * @run main RegistrationTest
- */
-
-import java.io.Serializable;
-import java.lang.management.ManagementFactory;
-import javax.management.*;
-
-public class RegistrationTest {
-    static boolean preRegisterCalled;
-    static boolean postRegisterCalled;
-    static boolean preDeregisterCalled;
-    static boolean postDeregisterCalled;
-
-    static void checkResult(boolean expected) throws Exception {
-        if((preRegisterCalled != expected ||
-            postRegisterCalled != expected ||
-            preDeregisterCalled != expected ||
-            postDeregisterCalled != expected))
-            throw new Exception("Mismatch preRegisterCalled = "
-                    + preRegisterCalled + ", postRegisterCalled = "
-                    + postRegisterCalled + ", preDeregisterCalled = "
-                    + preDeregisterCalled + ", postDeregisterCalled = "
-                    + postDeregisterCalled);
-    }
-    static class Wrapped implements MBeanRegistration,Serializable {
-
-        public ObjectName preRegister(MBeanServer server, ObjectName name)
-                throws Exception {
-            preRegisterCalled = true;
-            return name;
-        }
-
-        public void postRegister(Boolean registrationDone) {
-            postRegisterCalled = true;
-        }
-
-        public void preDeregister() throws Exception {
-            preDeregisterCalled = true;
-        }
-
-        public void postDeregister() {
-            postDeregisterCalled = true;
-        }
-
-    }
-
-    public static void main(String[] args) throws Exception {
-       StandardMBean std = new StandardMBean(new Wrapped(),
-               Serializable.class);
-       ObjectName name = ObjectName.valueOf(":type=Test");
-       ManagementFactory.getPlatformMBeanServer().registerMBean(std,name);
-       ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
-       checkResult(false);
-       StandardMBean.Options opt = new StandardMBean.Options();
-       opt.setMBeanRegistrationForwarded(true);
-       std = new StandardMBean(new Wrapped(),
-               Serializable.class, opt );
-       ManagementFactory.getPlatformMBeanServer().registerMBean(std,name);
-       ManagementFactory.getPlatformMBeanServer().unregisterMBean(name);
-       checkResult(true);
-       System.out.println("Test OK");
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JFileChooser/6550546/bug6550546.java	Wed Nov 25 11:08:25 2009 -0800
@@ -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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along 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 6550546
+   @summary Win LAF: JFileChooser -> Look in Drop down should not display any shortcuts created on desktop
+   @author Pavel Porvatov
+   @run main bug6550546
+*/
+
+import sun.awt.OSInfo;
+import sun.awt.shell.ShellFolder;
+
+import javax.swing.*;
+import java.io.File;
+
+public class bug6550546 {
+    public static void main(String[] args) throws Exception {
+        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+            System.out.println("The test is suitable only for Windows, skipped.");
+
+            return;
+        }
+
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                File[] files = (File[]) ShellFolder.get("fileChooserComboBoxFolders");
+
+                for (File file : files) {
+                    if (file instanceof ShellFolder && ((ShellFolder) file).isLink()) {
+                        throw new RuntimeException("Link shouldn't be in FileChooser combobox, " + file.getPath());
+                    }
+                }
+            }
+        });
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JFileChooser/6741890/bug6741890.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,107 @@
+/*
+ * 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 6741890
+   @summary Deadlock in Win32ShellFolderManager2
+   @author Pavel Porvatov
+   @run main bug6741890
+*/
+
+import sun.awt.shell.ShellFolder;
+import sun.awt.OSInfo;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.util.concurrent.Callable;
+
+public class bug6741890 {
+    /**
+     * This mux is used to prevent NPE in the isLink and isFileSystem methods
+     */
+    private static final Object mux = new Object();
+
+    private static final int COUNT = 100000;
+
+    public static void main(String[] args) throws Exception {
+        if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
+            System.out.println("The test is applicable only for Windows. Skipped.");
+
+            return;
+        }
+
+        String tmpDir = System.getProperty("java.io.tmpdir");
+
+        if (tmpDir.length() == 0) { //'java.io.tmpdir' isn't guaranteed to be defined
+            tmpDir = System.getProperty("user.home");
+        }
+
+        final ShellFolder tmpFile = ShellFolder.getShellFolder(new File(tmpDir));
+
+        System.out.println("Temp directory: " + tmpDir);
+
+        System.out.println("Stress test was run");
+
+        Thread thread = new Thread() {
+            public void run() {
+                while (!isInterrupted()) {
+                    ShellFolder.invoke(new Callable<Void>() {
+                        public Void call() throws Exception {
+                            synchronized (mux) {
+                                tmpFile.isFileSystem();
+                                tmpFile.isLink();
+                            }
+
+                            return null;
+                        }
+                    });
+                }
+            }
+        };
+
+        thread.start();
+
+        for (int i = 0; i < COUNT; i++) {
+            synchronized (mux) {
+                clearField(tmpFile, "cachedIsLink");
+                clearField(tmpFile, "cachedIsFileSystem");
+            }
+
+            tmpFile.isFileSystem();
+            tmpFile.isLink();
+        }
+
+        thread.interrupt();
+        thread.join();
+
+        System.out.println("Test passed successfully");
+    }
+
+    private static void clearField(Object o, String fieldName) throws Exception {
+        Field field = o.getClass().getDeclaredField(fieldName);
+
+        field.setAccessible(true);
+
+        field.set(o, null);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JFileChooser/6868611/bug6868611.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along 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 6868611
+   @summary FileSystemView throws NullPointerException
+   @author Pavel Porvatov
+   @run main bug6868611
+*/
+
+import javax.swing.*;
+import javax.swing.filechooser.FileSystemView;
+import java.io.File;
+
+public class bug6868611 {
+    private static final int COUNT = 1000;
+
+    public static void main(String[] args) throws Exception {
+        String tempDirProp = System.getProperty("java.io.tmpdir");
+
+        final String tempDir = tempDirProp == null || !new File(tempDirProp).isDirectory() ?
+            System.getProperty("user.home") : tempDirProp;
+
+        System.out.println("Temp directory: " + tempDir);
+
+        // Create 1000 files
+        for (int i = 0; i < 1000; i++) {
+            new File(tempDir, "temp" + i).createNewFile();
+        }
+
+        // Init default FileSystemView
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                FileSystemView.getFileSystemView().getFiles(new File(tempDir), false);
+            }
+        });
+
+        for (int i = 0; i < COUNT; i++) {
+            Thread thread = new MyThread(tempDir);
+
+            thread.start();
+
+            Thread.sleep((long) (Math.random() * 100));
+
+            thread.interrupt();
+
+            if (i % 100 == 0) {
+                System.out.print("*");
+            }
+        }
+
+        System.out.println();
+
+        // Remove 1000 files
+        for (int i = 0; i < 1000; i++) {
+            new File(tempDir, "temp" + i).delete();
+        }
+    }
+
+    private static class MyThread extends Thread {
+        private final String dir;
+
+        private MyThread(String dir) {
+            this.dir = dir;
+        }
+
+        public void run() {
+            FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+
+            fileSystemView.getFiles(new File(dir), false);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/Security/6657138/ComponentTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,76 @@
+/*
+ * 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 6657138
+ * @summary Verifies that buttons and labels work well after the fix for 6657138
+ * @author Alexander Potochkin
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import java.awt.*;
+
+public class ComponentTest extends JFrame {
+    private static JFrame frame;
+
+    public ComponentTest() {
+        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        setLayout(new FlowLayout());
+        add(new JButton("JButton"));
+        add(new JToggleButton("JToggleButton"));
+        add(new JCheckBox("JCheckBox"));
+        add(new JRadioButton("JRadioButton"));
+        add(new JLabel("JLabel"));
+        pack();
+        setLocationRelativeTo(null);
+    }
+
+
+    public static void main(String[] args) throws Exception {
+        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                frame = new ComponentTest();
+                frame.setVisible(true);
+            }
+        });
+        toolkit.realSync();
+        UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
+        for (final UIManager.LookAndFeelInfo laf : lafs) {
+            SwingUtilities.invokeAndWait(new Runnable() {
+                public void run() {
+                    try {
+                        UIManager.setLookAndFeel(laf.getClassName());
+                    } catch (Exception e) {
+                        new RuntimeException(e);
+                    }
+                    SwingUtilities.updateComponentTreeUI(frame);
+                }
+            });
+            toolkit.realSync();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/Security/6657138/bug6657138.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,103 @@
+/*
+ * 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 6657138
+ * @summary Verifies that buttons and labels don't share their ui's across appContexts
+ * @author Alexander Potochkin
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.*;
+import javax.swing.plaf.ButtonUI;
+import javax.swing.plaf.ComponentUI;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+public class bug6657138 implements Runnable {
+
+    private static Map<JComponent, Map<String, ComponentUI>> componentMap =
+            Collections.synchronizedMap(
+            new HashMap<JComponent, Map<String, ComponentUI>>());
+
+    public void run() {
+        SunToolkit.createNewAppContext();
+        try {
+            testUIMap();
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    private static void testUIMap() throws Exception {
+        UIManager.LookAndFeelInfo[] lafs = UIManager.getInstalledLookAndFeels();
+        Set<JComponent> components = componentMap.keySet();
+        for (JComponent c : components) {
+            Map<String, ComponentUI> uiMap = componentMap.get(c);
+
+            for (UIManager.LookAndFeelInfo laf : lafs) {
+                if ("Nimbus".equals(laf.getName())) {
+                    // for some unclear reasons
+                    // Nimbus ui delegate for a button is null
+                    // when this method is called from the new AppContext
+                    continue;
+                }
+                String className = laf.getClassName();
+                UIManager.setLookAndFeel(className);
+                ComponentUI ui = UIManager.getUI(c);
+                if (ui == null) {
+                    throw new RuntimeException("UI is null for " + c);
+                }
+                if (ui == uiMap.get(laf.getName())) {
+                    throw new RuntimeException(
+                            "Two AppContexts share the same UI delegate! \n" +
+                                    c + "\n" + ui);
+                }
+                uiMap.put(laf.getName(), ui);
+            }
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        componentMap.put(new JButton("JButton"),
+                new HashMap<String, ComponentUI>());
+        componentMap.put(new JToggleButton("JToggleButton"),
+                new HashMap<String, ComponentUI>());
+        componentMap.put(new JRadioButton("JRadioButton"),
+                new HashMap<String, ComponentUI>());
+        componentMap.put(new JCheckBox("JCheckBox"),
+                new HashMap<String, ComponentUI>());
+        componentMap.put(new JCheckBox("JLabel"),
+                new HashMap<String, ComponentUI>());
+        testUIMap();
+        ThreadGroup group = new ThreadGroup("6657138");
+        Thread thread = new Thread(group, new bug6657138());
+        thread.start();
+        thread.join();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/ToolTipManager/Test6657026.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,74 @@
+/*
+ * 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 6657026
+ * @summary Tests shared ToolTipManager in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import sun.awt.SunToolkit;
+import javax.swing.ToolTipManager;
+
+public class Test6657026 implements Runnable {
+
+    private static final int DISMISS = 4000;
+    private static final int INITIAL = 750;
+    private static final int RESHOW = 500;
+
+    public static void main(String[] args) throws InterruptedException {
+        ToolTipManager manager = ToolTipManager.sharedInstance();
+        if (DISMISS != manager.getDismissDelay()) {
+            throw new Error("unexpected dismiss delay");
+        }
+        if (INITIAL != manager.getInitialDelay()) {
+            throw new Error("unexpected initial delay");
+        }
+        if (RESHOW != manager.getReshowDelay()) {
+            throw new Error("unexpected reshow delay");
+        }
+        manager.setDismissDelay(DISMISS + 1);
+        manager.setInitialDelay(INITIAL + 1);
+        manager.setReshowDelay(RESHOW + 1);
+
+        ThreadGroup group = new ThreadGroup("$$$");
+        Thread thread = new Thread(group, new Test6657026());
+        thread.start();
+        thread.join();
+    }
+
+    public void run() {
+        SunToolkit.createNewAppContext();
+        ToolTipManager manager = ToolTipManager.sharedInstance();
+        if (DISMISS != manager.getDismissDelay()) {
+            throw new Error("shared dismiss delay");
+        }
+        if (INITIAL != manager.getInitialDelay()) {
+            throw new Error("shared initial delay");
+        }
+        if (RESHOW != manager.getReshowDelay()) {
+            throw new Error("shared reshow delay");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/UIDefaults/6795356/SwingLazyValueTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,44 @@
+/*
+ * 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 6795356
+ * @summary Checks that SwingLazyValue class correclty works
+ * @author Alexander Potochkin
+ * @run main SwingLazyValueTest
+ */
+
+import sun.swing.SwingLazyValue;
+
+import javax.swing.*;
+
+public class SwingLazyValueTest {
+
+    public static void main(String[] args) throws Exception {
+        if(new SwingLazyValue("javax.swing.JTable$DoubleRenderer").
+                createValue(null) == null) {
+            throw new RuntimeException("SwingLazyValue doesn't work");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/UIDefaults/6795356/TableTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,52 @@
+/*
+ * 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 6795356
+ * @summary Checks that SwingLazyValue class correclty works
+ * @author Alexander Potochkin
+ * @run main/othervm TableTest
+ */
+
+import sun.applet.AppletSecurity;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import java.awt.*;
+
+public class TableTest {
+
+    public static void main(String[] args) throws Exception {
+
+        KeyboardFocusManager.getCurrentKeyboardFocusManager();
+        System.setSecurityManager(new AppletSecurity());
+
+        JTable table = new JTable();
+        TableCellEditor de = table.getDefaultEditor(Double.class);
+        if (de == null) {
+            throw new RuntimeException("Table default editor is null");
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/UIDefaults/6795356/bug6795356.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,100 @@
+/*
+ * 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 6795356
+ * @summary Leak caused by javax.swing.UIDefaults.ProxyLazyValue.acc
+ * @author Alexander Potochkin
+ * @run main bug6795356
+ */
+
+import java.lang.ref.WeakReference;
+import java.security.ProtectionDomain;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.AccessControlContext;
+import java.util.LinkedList;
+import java.util.List;
+import javax.swing.*;
+
+public class bug6795356 {
+    volatile static WeakReference<ProtectionDomain> weakRef;
+
+    public static void main(String[] args) throws Exception {
+
+        ProtectionDomain domain = new ProtectionDomain(null, null);
+
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+            public Object run() {
+
+                // this initialize ProxyLazyValues
+                UIManager.getLookAndFeel();
+
+                return null;
+            }
+        }, new AccessControlContext(new ProtectionDomain[]{domain}));
+
+        weakRef = new WeakReference<ProtectionDomain>(domain);
+        domain = null;
+
+        // Generate OutOfMemory and check the weak ref
+        generateOOME();
+
+        if (weakRef.get() != null) {
+            throw new RuntimeException("Memory leak found!");
+        }
+        System.out.println("Test passed");
+    }
+
+    static void generateOOME() {
+        List<Object> bigLeak = new LinkedList<Object>();
+        boolean oome = false;
+        System.out.print("Filling the heap");
+        try {
+            for(int i = 0; true ; i++) {
+                // Now, use up all RAM
+                bigLeak.add(new byte[1024 * 1024]);
+                System.out.print(".");
+
+                // Give the GC a change at that weakref
+                if (i % 10 == 0) {
+                    System.gc();
+                    try {
+                        Thread.sleep(100);
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        } catch (OutOfMemoryError e) {
+            bigLeak = null;
+            oome = true;
+        }
+        System.out.println("");
+        if (!oome) {
+            throw new RuntimeException("Problem with test case - never got OOME");
+        }
+        System.out.println("Got OOME");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/UIManager/Test6657026.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,59 @@
+/*
+ * 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 6657026
+ * @summary Tests shared UIManager in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.UIManager;
+import javax.swing.UIManager.LookAndFeelInfo;
+
+public class Test6657026 implements Runnable {
+
+    public static void main(String[] args) throws Exception {
+        if (UIManager.getInstalledLookAndFeels().length == 0) {
+            throw new Error("unexpected amount of look&feels");
+        }
+        UIManager.setInstalledLookAndFeels(new LookAndFeelInfo[0]);
+        if (UIManager.getInstalledLookAndFeels().length != 0) {
+            throw new Error("unexpected amount of look&feels");
+        }
+
+        ThreadGroup group = new ThreadGroup("$$$");
+        Thread thread = new Thread(group, new Test6657026());
+        thread.start();
+        thread.join();
+    }
+
+    public void run() {
+        SunToolkit.createNewAppContext();
+        if (UIManager.getInstalledLookAndFeels().length == 0) {
+            throw new Error("shared look&feels");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/plaf/basic/BasicSplitPaneUI/Test6657026.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,82 @@
+/*
+ * 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 6657026
+ * @summary Tests shared BasicSplitPaneUI in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.event.ActionEvent;
+import java.util.Set;
+import javax.swing.JSplitPane;
+import javax.swing.plaf.basic.BasicSplitPaneUI;
+
+public class Test6657026 extends BasicSplitPaneUI implements Runnable {
+
+    public static void main(String[] args) throws InterruptedException {
+        if (new JSplitPane().getFocusTraversalKeys(0).isEmpty()){
+            throw new Error("unexpected traversal keys");
+        }
+        new JSplitPane() {
+            public void setFocusTraversalKeys(int id, Set keystrokes) {
+                keystrokes.clear();
+                super.setFocusTraversalKeys(id, keystrokes);
+            }
+        };
+        if (new JSplitPane().getFocusTraversalKeys(0).isEmpty()) {
+            throw new Error("shared traversal keys");
+        }
+        KEYBOARD_DIVIDER_MOVE_OFFSET = -KEYBOARD_DIVIDER_MOVE_OFFSET;
+
+        ThreadGroup group = new ThreadGroup("$$$");
+        Thread thread = new Thread(group, new Test6657026());
+        thread.start();
+        thread.join();
+    }
+
+    public void run() {
+        SunToolkit.createNewAppContext();
+        if (new JSplitPane().getFocusTraversalKeys(0).isEmpty()) {
+            throw new Error("shared traversal keys");
+        }
+        JSplitPane pane = new JSplitPane();
+        pane.setUI(this);
+
+        createFocusListener().focusGained(null); // allows actions
+        test(pane, "positiveIncrement", 3);
+        test(pane, "negativeIncrement", 0);
+    }
+
+    private static void test(JSplitPane pane, String action, int expected) {
+        ActionEvent event = new ActionEvent(pane, expected, action);
+        pane.getActionMap().get(action).actionPerformed(event);
+        int actual = pane.getDividerLocation();
+        if (actual != expected) {
+            throw new Error(actual + ", but expected " + expected);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/plaf/metal/MetalBorders/Test6657026.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,91 @@
+/*
+ * 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 6657026
+ * @summary Tests constancy of borders
+ * @author Sergey Malenkov
+ */
+
+import java.awt.Insets;
+import javax.swing.border.Border;
+import javax.swing.plaf.metal.MetalBorders.ButtonBorder;
+import javax.swing.plaf.metal.MetalBorders.MenuBarBorder;
+import javax.swing.plaf.metal.MetalBorders.MenuItemBorder;
+import javax.swing.plaf.metal.MetalBorders.PopupMenuBorder;
+
+public class Test6657026 {
+
+    private static final Insets NEGATIVE = new Insets(Integer.MIN_VALUE,
+                                                      Integer.MIN_VALUE,
+                                                      Integer.MIN_VALUE,
+                                                      Integer.MIN_VALUE);
+
+    public static void main(String[] args) {
+        new ButtonBorder() {{borderInsets = NEGATIVE;}};
+        new MenuBarBorder() {{borderInsets = NEGATIVE;}};
+        new MenuItemBorder() {{borderInsets = NEGATIVE;}};
+        new PopupMenuBorder() {{borderInsets = NEGATIVE;}};
+
+        test(create("ButtonBorder"));
+        test(create("MenuBarBorder"));
+        test(create("MenuItemBorder"));
+        test(create("PopupMenuBorder"));
+
+        test(create("Flush3DBorder"));
+        test(create("InternalFrameBorder"));
+        // NOT USED: test(create("FrameBorder"));
+        // NOT USED: test(create("DialogBorder"));
+        test(create("PaletteBorder"));
+        test(create("OptionDialogBorder"));
+        test(create("ScrollPaneBorder"));
+    }
+
+    private static Border create(String name) {
+        try {
+            name = "javax.swing.plaf.metal.MetalBorders$" + name;
+            return (Border) Class.forName(name).newInstance();
+        }
+        catch (Exception exception) {
+            throw new Error("unexpected exception", exception);
+        }
+    }
+
+    private static void test(Border border) {
+        Insets actual = border.getBorderInsets(null);
+        if (NEGATIVE.equals(actual)) {
+            throw new Error("unexpected insets in " + border.getClass());
+        }
+        Insets expected = (Insets) actual.clone();
+        // modify
+        actual.top++;
+        actual.left++;
+        actual.right++;
+        actual.bottom++;
+        // validate
+        if (!expected.equals(border.getBorderInsets(null))) {
+            throw new Error("shared insets in " + border.getClass());
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/plaf/metal/MetalBumps/Test6657026.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,238 @@
+/*
+ * 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 6657026
+ * @summary Tests shared MetalBumps in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import sun.awt.SunToolkit;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Rectangle;
+import java.awt.Shape;
+import java.awt.image.BufferedImage;
+import java.awt.image.ImageObserver;
+import java.text.AttributedCharacterIterator;
+import javax.swing.Icon;
+import javax.swing.plaf.metal.MetalBorders.ToolBarBorder;
+
+public class Test6657026 extends ToolBarBorder implements Runnable {
+
+    public static void main(String[] args) throws Exception {
+        new Test6657026().test();
+
+        ThreadGroup group = new ThreadGroup("$$$");
+        Thread thread = new Thread(group, new Test6657026());
+        thread.start();
+        thread.join();
+    }
+
+    public void run() {
+        SunToolkit.createNewAppContext();
+        test();
+    }
+
+    private void test() {
+        MyGraphics mg = new MyGraphics();
+        Icon icon = bumps;
+        icon.paintIcon(mg.component, mg, 0, 0);
+        if (mg.image != null) {
+            boolean failed = true;
+            int value = mg.image.getRGB(0, 0);
+            for (int x = 0; x < mg.image.getWidth(); x++) {
+                for (int y = 0; y < mg.image.getHeight(); y++) {
+                    int current = mg.image.getRGB(x, y);
+                    if (current != value) {
+                        mg.image.setRGB(x, y, value);
+                        failed = false;
+                    }
+
+                }
+            }
+            if (failed) {
+                throw new Error("shared metal bumps");
+            }
+        }
+    }
+
+    private static class MyGraphics extends Graphics {
+
+        private final Component component = new Component() {};
+        private BufferedImage image;
+
+        public Graphics create() {
+            return null;  // TODO: check
+        }
+
+        public void translate(int x, int y) {
+            // TODO: check
+        }
+
+        public Color getColor() {
+            return null;  // TODO: check
+        }
+
+        public void setColor(Color color) {
+            // TODO: check
+        }
+
+        public void setPaintMode() {
+            // TODO: check
+        }
+
+        public void setXORMode(Color c1) {
+            // TODO: check
+        }
+
+        public Font getFont() {
+            return null;  // TODO: check
+        }
+
+        public void setFont(Font font) {
+            // TODO: check
+        }
+
+        public FontMetrics getFontMetrics(Font font) {
+            return null;  // TODO: check
+        }
+
+        public Rectangle getClipBounds() {
+            return null;  // TODO: check
+        }
+
+        public void clipRect(int x, int y, int width, int height) {
+            // TODO: check
+        }
+
+        public void setClip(int x, int y, int width, int height) {
+            // TODO: check
+        }
+
+        public Shape getClip() {
+            return null;  // TODO: check
+        }
+
+        public void setClip(Shape clip) {
+            // TODO: check
+        }
+
+        public void copyArea(int x, int y, int width, int height, int dx, int dy) {
+            // TODO: check
+        }
+
+        public void drawLine(int x1, int y1, int x2, int y2) {
+            // TODO: check
+        }
+
+        public void fillRect(int x, int y, int width, int height) {
+            // TODO: check
+        }
+
+        public void clearRect(int x, int y, int width, int height) {
+            // TODO: check
+        }
+
+        public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+            // TODO: check
+        }
+
+        public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {
+            // TODO: check
+        }
+
+        public void drawOval(int x, int y, int width, int height) {
+            // TODO: check
+        }
+
+        public void fillOval(int x, int y, int width, int height) {
+            // TODO: check
+        }
+
+        public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+            // TODO: check
+        }
+
+        public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {
+            // TODO: check
+        }
+
+        public void drawPolyline(int[] xPoints, int[] yPoints, int nPoints) {
+            // TODO: check
+        }
+
+        public void drawPolygon(int[] xPoints, int[] yPoints, int nPoints) {
+            // TODO: check
+        }
+
+        public void fillPolygon(int[] xPoints, int[] yPoints, int nPoints) {
+            // TODO: check
+        }
+
+        public void drawString(String str, int x, int y) {
+            // TODO: check
+        }
+
+        public void drawString(AttributedCharacterIterator iterator, int x, int y) {
+            // TODO: check
+        }
+
+        public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
+            return false;  // TODO: check
+        }
+
+        public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
+            return false;  // TODO: check
+        }
+
+        public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {
+            return false;  // TODO: check
+        }
+
+        public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) {
+            return false;  // TODO: check
+        }
+
+        public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
+            if (img instanceof BufferedImage) {
+                this.image = (BufferedImage) img;
+            }
+            return false;  // TODO: check
+        }
+
+        public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) {
+            return false;  // TODO: check
+        }
+
+        public void dispose() {
+            // TODO: check
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/plaf/metal/MetalInternalFrameUI/Test6657026.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,60 @@
+/*
+ * 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 6657026
+ * @summary Tests shared MetalInternalFrameUI in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JPanel;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalInternalFrameUI;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+public class Test6657026 extends MetalInternalFrameUI implements Runnable {
+
+    public static void main(String[] args) throws Exception {
+        UIManager.setLookAndFeel(new MetalLookAndFeel());
+
+        ThreadGroup group = new ThreadGroup("$$$");
+        Thread thread = new Thread(group, new Test6657026());
+        thread.start();
+        thread.join();
+
+        new JInternalFrame().setContentPane(new JPanel());
+    }
+
+    public Test6657026() {
+        super(null);
+    }
+
+    public void run() {
+        SunToolkit.createNewAppContext();
+        IS_PALETTE = JInternalFrame.CONTENT_PANE_PROPERTY;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/plaf/metal/MetalSliderUI/Test6657026.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,67 @@
+/*
+ * 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 6657026
+ * @summary Tests shared MetalSliderUI in different application contexts
+ * @author Sergey Malenkov
+ */
+
+import sun.awt.SunToolkit;
+
+import javax.swing.JSlider;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+import javax.swing.plaf.metal.MetalSliderUI;
+
+public class Test6657026 extends MetalSliderUI implements Runnable {
+
+    public static void main(String[] args) throws Exception {
+        UIManager.setLookAndFeel(new MetalLookAndFeel());
+        JSlider slider = new JSlider();
+        test(slider);
+
+        ThreadGroup group = new ThreadGroup("$$$");
+        Thread thread = new Thread(group, new Test6657026());
+        thread.start();
+        thread.join();
+
+        test(slider);
+    }
+
+    public void run() {
+        SunToolkit.createNewAppContext();
+        JSlider slider = new JSlider();
+        test(slider);
+        tickLength = -10000;
+    }
+
+    private static void test(JSlider slider) {
+        MetalSliderUI ui = (MetalSliderUI) slider.getUI();
+        int actual = ui.getTickLength();
+        if (actual != 11) {
+            throw new Error(actual + ", but expected 11");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/start-Xvfb.sh	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,87 @@
+#!/bin/sh -f
+#
+# 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.
+#
+
+#
+# Original Author: Tim Bell
+#
+usage() {
+   echo "Starts up an Xvfb dummy X server with fvwm2 window manager"
+   echo " usage:"
+   echo "    ${0} display_number_file"
+   echo "        display_number_file gets display number when it's ready"
+   exit
+ }
+#
+currentDir=`pwd`
+rm -f $1
+DD=":$$"
+DISPLAY=${DD}
+export DISPLAY
+cd /tmp
+#
+if [ ! -x "/usr/bin/X11/Xvfb" ]; then
+  # We have Solaris-flavored X windows, and the /usr/openwin Xvfb is
+  # a simple wrapper script around the Xsun server.  Massage the
+  # arguments: server number must be first; others are slightly
+  # different.
+  #
+  # Also the default Visual Class (DirectColor) triggers an awt bug
+  # (probably 4131533/6505852) and some tests will loop endlessly
+  # when they hit the display.  The workaround is:
+  #  1) Ask for PseudoColor instead.
+  #  2) Omit 32-bit depth.
+  /usr/bin/nohup /usr/openwin/bin/Xvfb ${DISPLAY} -dev vfb screen 0 1280x1024x24 pixdepths 8 16 24 defclass PseudoColor > ${currentDir}/nohup.$$ 2>&1 &
+else
+  # Linux...
+  /usr/bin/nohup /usr/bin/X11/Xvfb -fbdir ${currentDir} -pixdepths 8 16 24 32 ${DISPLAY} > ${currentDir}/nohup.$$ 2>&1 &
+fi
+WM="/usr/bin/X11/fvwm2"
+if [ ! -x ${WM} ] ; then
+  WM="/opt/sfw/bin/fvwm2"
+fi
+#
+# Wait for Xvfb to initialize:
+sleep 5
+#
+if [ -x "${WM}" ]; then
+# 2 JCK tests require a window manager
+# mwm fails (key name errors) and twm fails (hangs),
+# but fvwm2 works well.
+  /usr/bin/nohup ${WM} -display ${DISPLAY} -replace -f /dev/null > ${currentDir}/nohup.$$ 2>&1 &
+else
+  echo "Error: ${WM} not found"
+  exit 1
+fi
+#
+# Wait some more to see if the xhost command gets through:
+sleep 10
+# Allow access to all - this is a brute force approach,
+# but I do not see how it could be a security problem...
+DISPLAY="${DD}" xhost +
+#
+echo "Virtual frame buffer started on ${DISPLAY}"
+echo "$$" > $1
+wait
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/java2d/pisces/Renderer/TestNPE.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,59 @@
+/*
+ * 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     6887494
+ *
+ * @summary Verifies that no NullPointerException is thrown in Pisces Renderer
+ *          under certain circumstances.
+ *
+ * @run     main TestNPE
+ */
+
+import java.awt.*;
+import java.awt.geom.*;
+import java.awt.image.BufferedImage;
+
+public class TestNPE {
+
+    private static void paint(Graphics g) {
+        Graphics2D g2d = (Graphics2D) g;
+        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
+                             RenderingHints.VALUE_ANTIALIAS_ON);
+        g2d.setClip(0, 0, 0, 0);
+        g2d.setTransform(
+               new AffineTransform(4.0f, 0.0f, 0.0f, 4.0f, -1248.0f, -744.0f));
+        g2d.draw(new Line2D.Float(131.21428571428572f, 33.0f,
+                                  131.21428571428572f, 201.0f));
+    }
+
+    public static void main(String[] args) {
+        BufferedImage im = new BufferedImage(100, 100,
+                                             BufferedImage.TYPE_INT_ARGB);
+
+        // Trigger exception in main thread.
+        Graphics g = im.getGraphics();
+        paint(g);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/net/www/protocol/http/B6890349.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,68 @@
+/*
+ * 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 6890349
+ * @run main/othervm B6890349
+ * @summary  Light weight HTTP server
+ */
+
+import java.net.*;
+import java.io.*;
+
+public class B6890349 extends Thread {
+    public static final void main(String[] args) throws Exception {
+
+        try {
+            ServerSocket server = new ServerSocket (0);
+            int port = server.getLocalPort();
+            System.out.println ("listening on "  + port);
+            B6890349 t = new B6890349 (server);
+            t.start();
+            URL u = new URL ("http://127.0.0.1:"+port+"/foo\nbar");
+            HttpURLConnection urlc = (HttpURLConnection)u.openConnection ();
+            InputStream is = urlc.getInputStream();
+            throw new RuntimeException ("Test failed");
+        } catch (IOException e) {
+            System.out.println ("OK");
+        }
+    }
+
+    ServerSocket server;
+
+    B6890349 (ServerSocket server) {
+        this.server = server;
+    }
+
+    String resp = "HTTP/1.1 200 Ok\r\nContent-length: 0\r\n\r\n";
+
+    public void run () {
+        try {
+            Socket s = server.accept ();
+            OutputStream os = s.getOutputStream();
+            os.write (resp.getBytes());
+        } catch (IOException e) {
+            System.out.println (e);
+        }
+    }
+}
--- a/test/sun/security/krb5/auto/Action.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/sun/security/krb5/auto/Action.java	Wed Nov 25 11:08:25 2009 -0800
@@ -30,4 +30,3 @@
      */
     byte[] run(Context s, byte[] input) throws Exception;
 }
-
--- a/test/sun/security/krb5/auto/HttpNegotiateServer.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/sun/security/krb5/auto/HttpNegotiateServer.java	Wed Nov 25 11:08:25 2009 -0800
@@ -302,4 +302,3 @@
         }
     }
 }
-
--- a/test/sun/security/krb5/auto/KDC.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/sun/security/krb5/auto/KDC.java	Wed Nov 25 11:08:25 2009 -0800
@@ -466,7 +466,17 @@
             // the krb5.conf config file would be loaded.
             Method stringToKey = EncryptionKey.class.getDeclaredMethod("stringToKey", char[].class, String.class, byte[].class, Integer.TYPE);
             stringToKey.setAccessible(true);
-            return new EncryptionKey((byte[]) stringToKey.invoke(null, getPassword(p), getSalt(p), null, etype), etype, null);
+            Integer kvno = null;
+            // For service whose password ending with a number, use it as kvno
+            if (p.toString().indexOf('/') >= 0) {
+                char[] pass = getPassword(p);
+                if (Character.isDigit(pass[pass.length-1])) {
+                    kvno = pass[pass.length-1] - '0';
+                }
+            }
+            return new EncryptionKey((byte[]) stringToKey.invoke(
+                    null, getPassword(p), getSalt(p), null, etype),
+                    etype, kvno);
         } catch (InvocationTargetException ex) {
             KrbException ke = (KrbException)ex.getCause();
             throw ke;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/krb5/auto/MoreKvno.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,70 @@
+/*
+ * 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 6893158
+ * @summary AP_REQ check should use key version number
+ */
+
+import sun.security.jgss.GSSUtil;
+import sun.security.krb5.PrincipalName;
+import sun.security.krb5.internal.ktab.KeyTab;
+
+public class MoreKvno {
+
+    public static void main(String[] args)
+            throws Exception {
+
+        OneKDC kdc = new OneKDC(null);
+        kdc.writeJAASConf();
+
+        // Rewrite keytab, 3 set of keys with different kvno
+        KeyTab ktab = KeyTab.create(OneKDC.KTAB);
+        PrincipalName p = new PrincipalName(OneKDC.SERVER+"@"+OneKDC.REALM, PrincipalName.KRB_NT_SRV_HST);
+        ktab.addEntry(p, "pass0".toCharArray(), 0);
+        ktab.addEntry(p, "pass2".toCharArray(), 2);
+        ktab.addEntry(p, "pass1".toCharArray(), 1);
+        ktab.save();
+
+        kdc.addPrincipal(OneKDC.SERVER, "pass1".toCharArray());
+        go(OneKDC.SERVER, "com.sun.security.jgss.krb5.accept");
+        kdc.addPrincipal(OneKDC.SERVER, "pass2".toCharArray());
+        // "server" initiate also, check pass2 is used at authentication
+        go(OneKDC.SERVER, "server");
+    }
+
+    static void go(String server, String entry) throws Exception {
+        Context c, s;
+        c = Context.fromUserPass("dummy", "bogus".toCharArray(), false);
+        s = Context.fromJAAS(entry);
+
+        c.startAsClient(server, GSSUtil.GSS_KRB5_MECH_OID);
+        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
+
+        Context.handshake(c, s);
+
+        s.dispose();
+        c.dispose();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/krb5/auto/SSL.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,168 @@
+/*
+ * 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 6894643
+ * @summary Test JSSE Kerberos ciphersuite
+ */
+import java.io.*;
+import java.net.InetAddress;
+import javax.net.ssl.*;
+import java.security.Principal;
+import java.util.Date;
+import sun.security.jgss.GSSUtil;
+
+public class SSL {
+
+    private static final String KRB5_CIPHER = "TLS_KRB5_WITH_3DES_EDE_CBC_SHA";
+    private static final int PORT = 4569;
+    private static final int LOOP_LIMIT = 1;
+    private static final char[] PASS = "secret".toCharArray();
+    private static int loopCount = 0;
+
+    private static String SERVER;
+
+    public static void main(String[] args) throws Exception {
+
+        KDC kdc = KDC.create(OneKDC.REALM);
+        // Run this after KDC, so our own DNS service can be started
+        try {
+            SERVER = InetAddress.getLocalHost().getHostName();
+        } catch (java.net.UnknownHostException e) {
+            SERVER = "localhost";
+        }
+
+        kdc.addPrincipal(OneKDC.USER, OneKDC.PASS);
+        kdc.addPrincipalRandKey("krbtgt/" + OneKDC.REALM);
+        kdc.addPrincipal("host/" + SERVER, PASS);
+        KDC.saveConfig(OneKDC.KRB5_CONF, kdc);
+        System.setProperty("java.security.krb5.conf", OneKDC.KRB5_CONF);
+
+        final Context c = Context.fromUserPass(OneKDC.USER, OneKDC.PASS, false);
+        final Context s = Context.fromUserPass("host/" + SERVER, PASS, true);
+
+        c.startAsClient("host/" + SERVER, GSSUtil.GSS_KRB5_MECH_OID);
+        s.startAsServer(GSSUtil.GSS_KRB5_MECH_OID);
+
+        new Thread(new Runnable() {
+            public void run() {
+                try {
+                    s.doAs(new JsseServerAction(), null);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }).start();
+
+        // Warm the server
+        Thread.sleep(2000);
+
+        c.doAs(new JsseClientAction(), null);
+    }
+
+    // Following codes copied from
+    // http://java.sun.com/javase/6/docs/technotes/guides/security/jgss/lab/part2.html#JSSE
+    private static class JsseClientAction implements Action {
+        public byte[] run(Context s, byte[] input) throws Exception {
+            SSLSocketFactory sslsf =
+                (SSLSocketFactory) SSLSocketFactory.getDefault();
+            SSLSocket sslSocket = (SSLSocket) sslsf.createSocket(SERVER, PORT);
+
+            // Enable only a KRB5 cipher suite.
+            String enabledSuites[] = {KRB5_CIPHER};
+            sslSocket.setEnabledCipherSuites(enabledSuites);
+            // Should check for exception if enabledSuites is not supported
+
+            BufferedReader in = new BufferedReader(new InputStreamReader(
+                sslSocket.getInputStream()));
+            BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
+                sslSocket.getOutputStream()));
+
+            String outStr = "Hello There!\n";
+            out.write(outStr);
+            out.flush();
+            System.out.print("Sending " + outStr);
+
+            String inStr = in.readLine();
+            System.out.println("Received " + inStr);
+
+            String cipherSuiteChosen = sslSocket.getSession().getCipherSuite();
+            System.out.println("Cipher suite in use: " + cipherSuiteChosen);
+            Principal self = sslSocket.getSession().getLocalPrincipal();
+            System.out.println("I am: " + self.toString());
+            Principal peer = sslSocket.getSession().getPeerPrincipal();
+            System.out.println("Server is: " + peer.toString());
+
+            sslSocket.close();
+            return null;
+        }
+    }
+
+    private static class JsseServerAction implements Action {
+        public byte[] run(Context s, byte[] input) throws Exception {
+            SSLServerSocketFactory sslssf =
+                (SSLServerSocketFactory) SSLServerSocketFactory.getDefault();
+            SSLServerSocket sslServerSocket =
+                (SSLServerSocket) sslssf.createServerSocket(PORT);
+
+            // Enable only a KRB5 cipher suite.
+            String enabledSuites[] = {KRB5_CIPHER};
+            sslServerSocket.setEnabledCipherSuites(enabledSuites);
+            // Should check for exception if enabledSuites is not supported
+
+            while (loopCount++ < LOOP_LIMIT) {
+                System.out.println("Waiting for incoming connection...");
+
+                SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
+
+                System.out.println("Got connection from client "
+                    + sslSocket.getInetAddress());
+
+                BufferedReader in = new BufferedReader(new InputStreamReader(
+                    sslSocket.getInputStream()));
+                BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
+                    sslSocket.getOutputStream()));
+
+                String inStr = in.readLine();
+                System.out.println("Received " + inStr);
+
+                String outStr = inStr + " " + new Date().toString() + "\n";
+                out.write(outStr);
+                System.out.println("Sending " + outStr);
+                out.flush();
+
+                String cipherSuiteChosen =
+                    sslSocket.getSession().getCipherSuite();
+                System.out.println("Cipher suite in use: " + cipherSuiteChosen);
+                Principal self = sslSocket.getSession().getLocalPrincipal();
+                System.out.println("I am: " + self.toString());
+                Principal peer = sslSocket.getSession().getPeerPrincipal();
+                System.out.println("Client is: " + peer.toString());
+
+                sslSocket.close();
+            }
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/DisabledAlgorithms/CPBuilder.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,442 @@
+/*
+ * 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 6861062
+ * @summary Disable MD2 support
+ *
+ * @run main/othervm CPBuilder trustAnchor_SHA1withRSA_1024 0 true
+ * @run main/othervm CPBuilder trustAnchor_SHA1withRSA_512  0 true
+ * @run main/othervm CPBuilder intermediate_SHA1withRSA_1024_1024 1 true
+ * @run main/othervm CPBuilder intermediate_SHA1withRSA_1024_512  1 true
+ * @run main/othervm CPBuilder intermediate_SHA1withRSA_512_1024  1 true
+ * @run main/othervm CPBuilder intermediate_SHA1withRSA_512_512  1 true
+ * @run main/othervm CPBuilder intermediate_MD2withRSA_1024_1024  1 false
+ * @run main/othervm CPBuilder intermediate_MD2withRSA_1024_512  1 false
+ * @run main/othervm CPBuilder endentiry_SHA1withRSA_1024_1024  2 true
+ * @run main/othervm CPBuilder endentiry_SHA1withRSA_1024_512  2 true
+ * @run main/othervm CPBuilder endentiry_SHA1withRSA_512_1024  2 true
+ * @run main/othervm CPBuilder endentiry_SHA1withRSA_512_512  2 true
+ * @run main/othervm CPBuilder endentiry_MD2withRSA_1024_1024  2 false
+ * @run main/othervm CPBuilder endentiry_MD2withRSA_1024_512  2 false
+ *
+ * @author Xuelei Fan
+ */
+
+import java.io.*;
+import java.net.SocketException;
+import java.util.*;
+import java.security.Security;
+import java.security.cert.*;
+import sun.security.util.DerInputStream;
+
+public class CPBuilder {
+
+    // SHA1withRSA 1024
+    static String trustAnchor_SHA1withRSA_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" +
+        "AQUAA4GNADCBiQKBgQC8UdC863pFk1Rvd7xUYd60+e9KsLhb6SqOfU42ZA715FcH\n" +
+        "E1TRvQPmYzAnHcO04TrWZQtO6E+E2RCmeBnetBvIMVka688QkO14wnrIrf2tRodd\n" +
+        "rZNZEBzkX+zyXCRo9tKEUDFf9Qze7Ilbb+Zzm9CUfu4M1Oz6iQcXRx7aM0jEAQID\n" +
+        "AQABo4GJMIGGMB0GA1UdDgQWBBTn0C+xmZY/BTab4W9gBp3dGa7WgjBHBgNVHSME\n" +
+        "QDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" +
+        "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" +
+        "DQYJKoZIhvcNAQEFBQADgYEAiCXL2Yp4ruyRXAIJ8zBEaPC9oV2agqgbSbly2z8z\n" +
+        "Ik5SeSRysP+GHBpb8uNyANJnQKv+T0GrJiTLMBjKCOiJl6xzk3EZ2wbQB6G/SQ9+\n" +
+        "UWcsXSC8oGSEPpkj5In/9/UbuUIfT9H8jmdyLNKQvlqgq6kyfnskME7ptGgT95Hc\n" +
+        "tas=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512
+    static String trustAnchor_SHA1withRSA_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBuTCCAWOgAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMFwwDQYJKoZIhvcNAQEB\n" +
+        "BQADSwAwSAJBAM0Kn4ieCdCHsrm78ZMMN4jQEEEqACAMKB7O8j9g4gfz2oAfmHwv\n" +
+        "7JH/hZ0Xen1zUmBbwe+e2J5D/4Fisp9Bn98CAwEAAaOBiTCBhjAdBgNVHQ4EFgQU\n" +
+        "g4Kwd47hdNQBp8grZsRJ5XvhvxAwRwYDVR0jBEAwPoAUg4Kwd47hdNQBp8grZsRJ\n" +
+        "5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMA8G\n" +
+        "A1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0GCSqGSIb3DQEBBQUAA0EAn77b\n" +
+        "FJx+HvyRvjZYCzMjnUct3Ql4iLOkURYDh93J5TXi/l9ajvAMEuwzYj0qZ+Ktm/ia\n" +
+        "U5r+8B9nzx+j2Zh3kw==\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 1024
+    static String intermediate_SHA1withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICUDCCAbmgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDhaFw0yOTA0MjMwMTExNDha\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADgYEAHze3wAcIe84zNOoN\n" +
+        "P8l9EmlVVoU30z3LB3hxq3m/dC/4gE5Z9Z8EG1wJw4qaxlTZ4dif12nbTTdofVhb\n" +
+        "Bd4syjo6fcUA4q7sfg9TFpoHQ+Ap7PgjK99moMKdMy50Xy8s6FPvaVkF89s66Z6y\n" +
+        "e4q7TSwe6QevGOZaL5N/iy2XGEs=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 512
+    static String intermediate_SHA1withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDzCCAbmgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADQQCYNmdkONfuk07XjRze\n" +
+        "WQyq2cfdae4uIdyUfa2rpgYMtSXuQW3/XrQGiz4G6WBXA2wo7folOOpAKYgvHPrm\n" +
+        "w6Dd\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 1024
+    static String intermediate_SHA1withRSA_512_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDDCCAXWgAwIBAgIBBDANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV\n" +
+        "lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA\n" +
+        "AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw\n" +
+        "PoAU59AvsZmWPwU2m+FvYAad3Rmu1oKhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
+        "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" +
+        "CSqGSIb3DQEBBQUAA4GBAE2VOlw5ySLT3gUzKCYEga4QPaSrf6lHHPi2g48LscEY\n" +
+        "h9qQXh4nuIVugReBIEf6N49RdT+M2cgRJo4sZ3ukYLGQzxNuttL5nPSuuvrAR1oG\n" +
+        "LUyzOWcUpKHbVHi6zlTt79RvTKZvLcduLutmtPtLJcM9PdiAI1wEooSgxTwZtB/Z\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 512
+    static String intermediate_SHA1withRSA_512_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIByzCCAXWgAwIBAgIBBTANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV\n" +
+        "lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA\n" +
+        "AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw\n" +
+        "PoAUg4Kwd47hdNQBp8grZsRJ5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
+        "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" +
+        "CSqGSIb3DQEBBQUAA0EAoCf0Zu559qcB4xPpzqkVsYiyW49S4Yc0mmQXb1yoQgLx\n" +
+        "O+DCkjG5d14+t1MsnkhB2izoQUMxQ3vDc1YnA/tEpw==\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 1024
+    static String intermediate_MD2withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICUDCCAbmgAwIBAgIBBjANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEAPtEjwbWuC5kc4DPc\n" +
+        "Ttf/wdbD8ZCdAWzcc3XF9q1TlvwVMNk6mbfM05y6ZVsztKTkwZ4EcvFu/yIqw1EB\n" +
+        "E1zlXQCaWXT3/ZMbqYZV4+mx+RUl8spUCb1tda25jnTg3mTOzB1iztm4gy903EMd\n" +
+        "m8omKDKeCgcw5dR4ITQYvyxe1as=\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 512
+    static String intermediate_MD2withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDzCCAbmgAwIBAgIBBzANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADQQBHok1v6xymtpB7N9xy\n" +
+        "0OmDT27uhmzlP0eOzJvXVxj3Oi9TLQJgCUJ9122MzfRAs1E1uJTtvuu+UmI80NQx\n" +
+        "KQdp\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 1024
+    static String endentiry_SHA1withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICNzCCAaCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTBaFw0yOTA0MjMwMTExNTBaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBTfWD9mRTppcUAlUqGuu/R5t8CB5jANBgkqhkiG\n" +
+        "9w0BAQUFAAOBgQAOfIeasDg91CR3jGfuAEVKwncM1OPFmniAUcdPm74cCAyJ90Me\n" +
+        "dhUElWPGoAuXGfiyZlOlGUYWqEroe/dnkmnotJjLWR+MA4ZyX3O1YI8T4W3deWcC\n" +
+        "J4WMCF7mp17SaYYKX9F0AxwNJFpUkbB41IkTxPr0MmzB1871/pbY8dLAvA==\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 512
+    static String endentiry_SHA1withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIB9jCCAaCgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTBaFw0yOTA0MjMwMTExNTBaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBQ3QIeJNg+2PK+k/ZrrLqaGxnpTjTANBgkqhkiG\n" +
+        "9w0BAQUFAANBADV6X+ea0ftEKXy7yKNAbdIp35893T6AVwbdclomPkeOs86OtoTG\n" +
+        "1BIzWSK9QE7W6Wbf63e2RdcqoLK+DxsuwUg=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 1024
+    static String endentiry_SHA1withRSA_512_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIB8zCCAVygAwIBAgIBBDANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3\n" +
+        "DQEBAQUAA0sAMEgCQQCpfQzhld7w2JhW/aRaLkmrLrc/QAsQE+J4DXioXaajsWPo\n" +
+        "uMmYmuiQolb6OIY/LcivSubKM3G5PkAWoovUPIWLAgMBAAGjTzBNMAsGA1UdDwQE\n" +
+        "AwID6DAdBgNVHQ4EFgQUFWuXLkf4Ji57H9ISycgWi982TUIwHwYDVR0jBBgwFoAU\n" +
+        "31g/ZkU6aXFAJVKhrrv0ebfAgeYwDQYJKoZIhvcNAQEFBQADgYEAUyW8PrEdbzLu\n" +
+        "B+h6UemBOJ024rYq90hJE/5wUEKPvxZ9vPEUgl+io6cGhL3cLfxfh6z5xtEGp4Tb\n" +
+        "NB0Ye3Qi01FBiNDY8s3rQRrmel6VysU8u+0Oi2jmQY6vZXn/zXN5rrTLITCaSicG\n" +
+        "dOMv1xLM83Ee432WWlDwKOUxhzDGpWc=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 512
+    static String endentiry_SHA1withRSA_512_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBsjCCAVygAwIBAgIBBTANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3\n" +
+        "DQEBAQUAA0sAMEgCQQCpfQzhld7w2JhW/aRaLkmrLrc/QAsQE+J4DXioXaajsWPo\n" +
+        "uMmYmuiQolb6OIY/LcivSubKM3G5PkAWoovUPIWLAgMBAAGjTzBNMAsGA1UdDwQE\n" +
+        "AwID6DAdBgNVHQ4EFgQUFWuXLkf4Ji57H9ISycgWi982TUIwHwYDVR0jBBgwFoAU\n" +
+        "N0CHiTYPtjyvpP2a6y6mhsZ6U40wDQYJKoZIhvcNAQEFBQADQQBG4grtrVEHick0\n" +
+        "z/6Lcl/MGyHT0c8KTXE0AMVXG1NRjAicAmYno/yDaJ9OmfymObKZKV9fF7yCW/N/\n" +
+        "TMU6m7N0\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 1024
+    static String endentiry_MD2withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICNzCCAaCgAwIBAgIBBjANBgkqhkiG9w0BAQIFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBTfWD9mRTppcUAlUqGuu/R5t8CB5jANBgkqhkiG\n" +
+        "9w0BAQIFAAOBgQBxKsFf8NNQcXjDoKJJSG4Rk6ikcrhiGYuUI32+XHvs6hnav1Zc\n" +
+        "aJUpy7J4gMj/MnysMh/4AF9+m6zEEjuisXKUbYZhgtJxz+ukGSo163mJ8QJiAlRb\n" +
+        "Iwsy81r08mlSCR6jx2YhDAUxJIPC92R5Vb4CEutB7tWTwwz7vIHq330erA==\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 512
+    static String endentiry_MD2withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIB9jCCAaCgAwIBAgIBBzANBgkqhkiG9w0BAQIFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBQ3QIeJNg+2PK+k/ZrrLqaGxnpTjTANBgkqhkiG\n" +
+        "9w0BAQIFAANBAIX63Ypi9P71RnC/pcMbhD+wekRFsTzU593X3MC7tyBJtEXwvAZG\n" +
+        "iMxXF5A+ohlr7/CrkV7ZTL8PLxnJdY5Y8rQ=\n" +
+        "-----END CERTIFICATE-----";
+
+    static HashMap<String, String> certmap = new HashMap<String, String>();
+    static {
+        certmap.put("trustAnchor_SHA1withRSA_1024",
+                                    trustAnchor_SHA1withRSA_1024);
+        certmap.put("trustAnchor_SHA1withRSA_512",
+                                    trustAnchor_SHA1withRSA_512);
+        certmap.put("intermediate_SHA1withRSA_1024_1024",
+                                    intermediate_SHA1withRSA_1024_1024);
+        certmap.put("intermediate_SHA1withRSA_1024_512",
+                                    intermediate_SHA1withRSA_1024_512);
+        certmap.put("intermediate_SHA1withRSA_512_1024",
+                                    intermediate_SHA1withRSA_512_1024);
+        certmap.put("intermediate_SHA1withRSA_512_512",
+                                    intermediate_SHA1withRSA_512_512);
+        certmap.put("intermediate_MD2withRSA_1024_1024",
+                                    intermediate_MD2withRSA_1024_1024);
+        certmap.put("intermediate_MD2withRSA_1024_512",
+                                    intermediate_MD2withRSA_1024_512);
+        certmap.put("endentiry_SHA1withRSA_1024_1024",
+                                    endentiry_SHA1withRSA_1024_1024);
+        certmap.put("endentiry_SHA1withRSA_1024_512",
+                                    endentiry_SHA1withRSA_1024_512);
+        certmap.put("endentiry_SHA1withRSA_512_1024",
+                                    endentiry_SHA1withRSA_512_1024);
+        certmap.put("endentiry_SHA1withRSA_512_512",
+                                    endentiry_SHA1withRSA_512_512);
+        certmap.put("endentiry_MD2withRSA_1024_1024",
+                                    endentiry_MD2withRSA_1024_1024);
+        certmap.put("endentiry_MD2withRSA_1024_512",
+                                    endentiry_MD2withRSA_1024_512);
+    }
+
+    private static Set<TrustAnchor> generateTrustAnchors()
+            throws CertificateException {
+        // generate certificate from cert string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        HashSet<TrustAnchor> anchors = new HashSet<TrustAnchor>();
+
+        ByteArrayInputStream is =
+            new ByteArrayInputStream(trustAnchor_SHA1withRSA_1024.getBytes());
+        Certificate cert = cf.generateCertificate(is);
+        TrustAnchor anchor = new TrustAnchor((X509Certificate)cert, null);
+        anchors.add(anchor);
+
+        is = new ByteArrayInputStream(trustAnchor_SHA1withRSA_512.getBytes());
+        cert = cf.generateCertificate(is);
+        anchor = new TrustAnchor((X509Certificate)cert, null);
+        anchors.add(anchor);
+
+        return anchors;
+    }
+
+    private static CertStore generateCertificateStore() throws Exception {
+        Collection entries = new HashSet();
+
+        // generate certificate from certificate string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        for (String key : certmap.keySet()) {
+            String certStr = certmap.get(key);
+            ByteArrayInputStream is =
+                        new ByteArrayInputStream(certStr.getBytes());;
+            Certificate cert = cf.generateCertificate(is);
+            entries.add(cert);
+        }
+
+        return CertStore.getInstance("Collection",
+                            new CollectionCertStoreParameters(entries));
+    }
+
+    private static X509CertSelector generateSelector(String name)
+                throws Exception {
+        X509CertSelector selector = new X509CertSelector();
+
+        String certStr = certmap.get(name);
+        if (certStr == null) {
+            return null;
+        }
+
+        // generate certificate from certificate string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        ByteArrayInputStream is = new ByteArrayInputStream(certStr.getBytes());
+        X509Certificate target = (X509Certificate)cf.generateCertificate(is);
+
+        selector.setCertificate(target);
+
+        return selector;
+    }
+
+    private static boolean match(String name, Certificate cert)
+                throws Exception {
+        X509CertSelector selector = new X509CertSelector();
+
+        String certStr = certmap.get(name);
+        if (certStr == null) {
+            return false;
+        }
+
+        // generate certificate from certificate string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        ByteArrayInputStream is = new ByteArrayInputStream(certStr.getBytes());
+        X509Certificate target = (X509Certificate)cf.generateCertificate(is);
+
+        return target.equals(cert);
+    }
+
+    public static void main(String args[]) throws Exception {
+
+        CertPathBuilder builder = CertPathBuilder.getInstance("PKIX");
+
+        X509CertSelector selector = generateSelector(args[0]);
+        if (selector == null) {
+            // no target certificate, ignore it
+            return;
+        }
+
+        Set<TrustAnchor> anchors = generateTrustAnchors();
+        CertStore certs = generateCertificateStore();
+
+        PKIXBuilderParameters params =
+                new PKIXBuilderParameters(anchors, selector);
+        params.addCertStore(certs);
+        params.setRevocationEnabled(false);
+        params.setDate(new Date(109, 9, 1));   // 2009-09-01
+
+        boolean success = Boolean.valueOf(args[2]);
+        try {
+            PKIXCertPathBuilderResult result =
+                        (PKIXCertPathBuilderResult)builder.build(params);
+            if (!success) {
+                throw new Exception("expected algorithm disabled exception");
+            }
+
+            int length = Integer.parseInt(args[1]);
+            List<? extends Certificate> path =
+                                    result.getCertPath().getCertificates();
+            if (length != path.size()) {
+                throw new Exception("unexpected certification path length");
+            }
+
+            if (!path.isEmpty()) {    // the target is not a trust anchor
+                if (!match(args[0], path.get(0))) {
+                    throw new Exception("unexpected certificate");
+                }
+            }
+        } catch (CertPathBuilderException cpbe) {
+            if (success) {
+                throw new Exception("unexpected exception");
+            } else {
+                System.out.println("Get the expected exception " + cpbe);
+            }
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/DisabledAlgorithms/CPValidatorEndEntity.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,363 @@
+/*
+ * 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 6861062
+ * @summary Disable MD2 support
+ *
+ * @author Xuelei Fan
+ */
+
+import java.io.*;
+import java.net.SocketException;
+import java.util.*;
+import java.security.Security;
+import java.security.cert.*;
+
+public class CPValidatorEndEntity {
+
+    // SHA1withRSA 1024
+    static String trustAnchor_SHA1withRSA_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" +
+        "AQUAA4GNADCBiQKBgQC8UdC863pFk1Rvd7xUYd60+e9KsLhb6SqOfU42ZA715FcH\n" +
+        "E1TRvQPmYzAnHcO04TrWZQtO6E+E2RCmeBnetBvIMVka688QkO14wnrIrf2tRodd\n" +
+        "rZNZEBzkX+zyXCRo9tKEUDFf9Qze7Ilbb+Zzm9CUfu4M1Oz6iQcXRx7aM0jEAQID\n" +
+        "AQABo4GJMIGGMB0GA1UdDgQWBBTn0C+xmZY/BTab4W9gBp3dGa7WgjBHBgNVHSME\n" +
+        "QDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" +
+        "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" +
+        "DQYJKoZIhvcNAQEFBQADgYEAiCXL2Yp4ruyRXAIJ8zBEaPC9oV2agqgbSbly2z8z\n" +
+        "Ik5SeSRysP+GHBpb8uNyANJnQKv+T0GrJiTLMBjKCOiJl6xzk3EZ2wbQB6G/SQ9+\n" +
+        "UWcsXSC8oGSEPpkj5In/9/UbuUIfT9H8jmdyLNKQvlqgq6kyfnskME7ptGgT95Hc\n" +
+        "tas=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512
+    static String trustAnchor_SHA1withRSA_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBuTCCAWOgAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMFwwDQYJKoZIhvcNAQEB\n" +
+        "BQADSwAwSAJBAM0Kn4ieCdCHsrm78ZMMN4jQEEEqACAMKB7O8j9g4gfz2oAfmHwv\n" +
+        "7JH/hZ0Xen1zUmBbwe+e2J5D/4Fisp9Bn98CAwEAAaOBiTCBhjAdBgNVHQ4EFgQU\n" +
+        "g4Kwd47hdNQBp8grZsRJ5XvhvxAwRwYDVR0jBEAwPoAUg4Kwd47hdNQBp8grZsRJ\n" +
+        "5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMA8G\n" +
+        "A1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0GCSqGSIb3DQEBBQUAA0EAn77b\n" +
+        "FJx+HvyRvjZYCzMjnUct3Ql4iLOkURYDh93J5TXi/l9ajvAMEuwzYj0qZ+Ktm/ia\n" +
+        "U5r+8B9nzx+j2Zh3kw==\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 1024
+    static String intermediate_SHA1withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICUDCCAbmgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDhaFw0yOTA0MjMwMTExNDha\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADgYEAHze3wAcIe84zNOoN\n" +
+        "P8l9EmlVVoU30z3LB3hxq3m/dC/4gE5Z9Z8EG1wJw4qaxlTZ4dif12nbTTdofVhb\n" +
+        "Bd4syjo6fcUA4q7sfg9TFpoHQ+Ap7PgjK99moMKdMy50Xy8s6FPvaVkF89s66Z6y\n" +
+        "e4q7TSwe6QevGOZaL5N/iy2XGEs=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 512
+    static String intermediate_SHA1withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDzCCAbmgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADQQCYNmdkONfuk07XjRze\n" +
+        "WQyq2cfdae4uIdyUfa2rpgYMtSXuQW3/XrQGiz4G6WBXA2wo7folOOpAKYgvHPrm\n" +
+        "w6Dd\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 1024
+    static String intermediate_SHA1withRSA_512_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDDCCAXWgAwIBAgIBBDANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV\n" +
+        "lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA\n" +
+        "AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw\n" +
+        "PoAU59AvsZmWPwU2m+FvYAad3Rmu1oKhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
+        "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" +
+        "CSqGSIb3DQEBBQUAA4GBAE2VOlw5ySLT3gUzKCYEga4QPaSrf6lHHPi2g48LscEY\n" +
+        "h9qQXh4nuIVugReBIEf6N49RdT+M2cgRJo4sZ3ukYLGQzxNuttL5nPSuuvrAR1oG\n" +
+        "LUyzOWcUpKHbVHi6zlTt79RvTKZvLcduLutmtPtLJcM9PdiAI1wEooSgxTwZtB/Z\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 512
+    static String intermediate_SHA1withRSA_512_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIByzCCAXWgAwIBAgIBBTANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV\n" +
+        "lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA\n" +
+        "AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw\n" +
+        "PoAUg4Kwd47hdNQBp8grZsRJ5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
+        "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" +
+        "CSqGSIb3DQEBBQUAA0EAoCf0Zu559qcB4xPpzqkVsYiyW49S4Yc0mmQXb1yoQgLx\n" +
+        "O+DCkjG5d14+t1MsnkhB2izoQUMxQ3vDc1YnA/tEpw==\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 1024
+    static String intermediate_MD2withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICUDCCAbmgAwIBAgIBBjANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEAPtEjwbWuC5kc4DPc\n" +
+        "Ttf/wdbD8ZCdAWzcc3XF9q1TlvwVMNk6mbfM05y6ZVsztKTkwZ4EcvFu/yIqw1EB\n" +
+        "E1zlXQCaWXT3/ZMbqYZV4+mx+RUl8spUCb1tda25jnTg3mTOzB1iztm4gy903EMd\n" +
+        "m8omKDKeCgcw5dR4ITQYvyxe1as=\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 512
+    static String intermediate_MD2withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDzCCAbmgAwIBAgIBBzANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADQQBHok1v6xymtpB7N9xy\n" +
+        "0OmDT27uhmzlP0eOzJvXVxj3Oi9TLQJgCUJ9122MzfRAs1E1uJTtvuu+UmI80NQx\n" +
+        "KQdp\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 1024
+    static String endentiry_SHA1withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICNzCCAaCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTBaFw0yOTA0MjMwMTExNTBaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBTfWD9mRTppcUAlUqGuu/R5t8CB5jANBgkqhkiG\n" +
+        "9w0BAQUFAAOBgQAOfIeasDg91CR3jGfuAEVKwncM1OPFmniAUcdPm74cCAyJ90Me\n" +
+        "dhUElWPGoAuXGfiyZlOlGUYWqEroe/dnkmnotJjLWR+MA4ZyX3O1YI8T4W3deWcC\n" +
+        "J4WMCF7mp17SaYYKX9F0AxwNJFpUkbB41IkTxPr0MmzB1871/pbY8dLAvA==\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 512
+    static String endentiry_SHA1withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIB9jCCAaCgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTBaFw0yOTA0MjMwMTExNTBaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBQ3QIeJNg+2PK+k/ZrrLqaGxnpTjTANBgkqhkiG\n" +
+        "9w0BAQUFAANBADV6X+ea0ftEKXy7yKNAbdIp35893T6AVwbdclomPkeOs86OtoTG\n" +
+        "1BIzWSK9QE7W6Wbf63e2RdcqoLK+DxsuwUg=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 1024
+    static String endentiry_SHA1withRSA_512_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIB8zCCAVygAwIBAgIBBDANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3\n" +
+        "DQEBAQUAA0sAMEgCQQCpfQzhld7w2JhW/aRaLkmrLrc/QAsQE+J4DXioXaajsWPo\n" +
+        "uMmYmuiQolb6OIY/LcivSubKM3G5PkAWoovUPIWLAgMBAAGjTzBNMAsGA1UdDwQE\n" +
+        "AwID6DAdBgNVHQ4EFgQUFWuXLkf4Ji57H9ISycgWi982TUIwHwYDVR0jBBgwFoAU\n" +
+        "31g/ZkU6aXFAJVKhrrv0ebfAgeYwDQYJKoZIhvcNAQEFBQADgYEAUyW8PrEdbzLu\n" +
+        "B+h6UemBOJ024rYq90hJE/5wUEKPvxZ9vPEUgl+io6cGhL3cLfxfh6z5xtEGp4Tb\n" +
+        "NB0Ye3Qi01FBiNDY8s3rQRrmel6VysU8u+0Oi2jmQY6vZXn/zXN5rrTLITCaSicG\n" +
+        "dOMv1xLM83Ee432WWlDwKOUxhzDGpWc=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 512
+    static String endentiry_SHA1withRSA_512_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBsjCCAVygAwIBAgIBBTANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3\n" +
+        "DQEBAQUAA0sAMEgCQQCpfQzhld7w2JhW/aRaLkmrLrc/QAsQE+J4DXioXaajsWPo\n" +
+        "uMmYmuiQolb6OIY/LcivSubKM3G5PkAWoovUPIWLAgMBAAGjTzBNMAsGA1UdDwQE\n" +
+        "AwID6DAdBgNVHQ4EFgQUFWuXLkf4Ji57H9ISycgWi982TUIwHwYDVR0jBBgwFoAU\n" +
+        "N0CHiTYPtjyvpP2a6y6mhsZ6U40wDQYJKoZIhvcNAQEFBQADQQBG4grtrVEHick0\n" +
+        "z/6Lcl/MGyHT0c8KTXE0AMVXG1NRjAicAmYno/yDaJ9OmfymObKZKV9fF7yCW/N/\n" +
+        "TMU6m7N0\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 1024
+    static String endentiry_MD2withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICNzCCAaCgAwIBAgIBBjANBgkqhkiG9w0BAQIFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBTfWD9mRTppcUAlUqGuu/R5t8CB5jANBgkqhkiG\n" +
+        "9w0BAQIFAAOBgQBxKsFf8NNQcXjDoKJJSG4Rk6ikcrhiGYuUI32+XHvs6hnav1Zc\n" +
+        "aJUpy7J4gMj/MnysMh/4AF9+m6zEEjuisXKUbYZhgtJxz+ukGSo163mJ8QJiAlRb\n" +
+        "Iwsy81r08mlSCR6jx2YhDAUxJIPC92R5Vb4CEutB7tWTwwz7vIHq330erA==\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 512
+    static String endentiry_MD2withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIB9jCCAaCgAwIBAgIBBzANBgkqhkiG9w0BAQIFADAxMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx\n" +
+        "NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt\n" +
+        "cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG\n" +
+        "9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt\n" +
+        "vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v\n" +
+        "z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6\n" +
+        "c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07\n" +
+        "OorBleV92TAfBgNVHSMEGDAWgBQ3QIeJNg+2PK+k/ZrrLqaGxnpTjTANBgkqhkiG\n" +
+        "9w0BAQIFAANBAIX63Ypi9P71RnC/pcMbhD+wekRFsTzU593X3MC7tyBJtEXwvAZG\n" +
+        "iMxXF5A+ohlr7/CrkV7ZTL8PLxnJdY5Y8rQ=\n" +
+        "-----END CERTIFICATE-----";
+
+    private static CertPath generateCertificatePath(String castr,
+            String eestr) throws CertificateException {
+        // generate certificate from cert strings
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        ByteArrayInputStream is;
+
+        is = new ByteArrayInputStream(castr.getBytes());
+        Certificate cacert = cf.generateCertificate(is);
+
+        is = new ByteArrayInputStream(eestr.getBytes());
+        Certificate eecert = cf.generateCertificate(is);
+
+        // generate certification path
+        List<Certificate> list = Arrays.asList(new Certificate[] {
+                        eecert, cacert});
+
+        return cf.generateCertPath(list);
+    }
+
+    private static Set<TrustAnchor> generateTrustAnchors()
+            throws CertificateException {
+        // generate certificate from cert string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        HashSet<TrustAnchor> anchors = new HashSet<TrustAnchor>();
+
+        ByteArrayInputStream is =
+            new ByteArrayInputStream(trustAnchor_SHA1withRSA_1024.getBytes());
+        Certificate cert = cf.generateCertificate(is);
+        TrustAnchor anchor = new TrustAnchor((X509Certificate)cert, null);
+        anchors.add(anchor);
+
+        is = new ByteArrayInputStream(trustAnchor_SHA1withRSA_512.getBytes());
+        cert = cf.generateCertificate(is);
+        anchor = new TrustAnchor((X509Certificate)cert, null);
+        anchors.add(anchor);
+
+        return anchors;
+    }
+
+    public static void main(String args[]) throws Exception {
+        try {
+            validate(endentiry_SHA1withRSA_1024_1024,
+                                    intermediate_SHA1withRSA_1024_1024);
+            validate(endentiry_SHA1withRSA_1024_512,
+                                    intermediate_SHA1withRSA_512_1024);
+            validate(endentiry_SHA1withRSA_512_1024,
+                                    intermediate_SHA1withRSA_1024_1024);
+            validate(endentiry_SHA1withRSA_512_512,
+                                    intermediate_SHA1withRSA_512_1024);
+        } catch (CertPathValidatorException cpve) {
+            throw new Exception(
+                "unexpect exception, it is valid cert", cpve);
+        }
+
+        try {
+            validate(endentiry_MD2withRSA_1024_1024,
+                                    intermediate_SHA1withRSA_1024_1024);
+            throw new Exception("expected algorithm disabled exception");
+        } catch (CertPathValidatorException cpve) {
+            System.out.println("Get the expected exception " + cpve);
+        }
+
+        try {
+            validate(endentiry_MD2withRSA_1024_512,
+                                    intermediate_SHA1withRSA_512_1024);
+            throw new Exception("expected algorithm disabled exception");
+        } catch (CertPathValidatorException cpve) {
+            System.out.println("Get the expected exception " + cpve);
+        }
+    }
+
+    private static void validate(String eecert, String cacert)
+            throws CertPathValidatorException, Exception {
+
+        CertPath path = generateCertificatePath(cacert, eecert);
+        Set<TrustAnchor> anchors = generateTrustAnchors();
+
+        PKIXParameters params = new PKIXParameters(anchors);
+
+        // disable certificate revocation checking
+        params.setRevocationEnabled(false);
+
+        // set the validation time
+        params.setDate(new Date(109, 9, 1));   // 2009-09-01
+
+        CertPathValidator validator = CertPathValidator.getInstance("PKIX");
+
+        validator.validate(path, params);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/DisabledAlgorithms/CPValidatorIntermediate.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,256 @@
+/*
+ * 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 6861062
+ * @summary Disable MD2 support
+ *
+ * @author Xuelei Fan
+ */
+
+import java.io.*;
+import java.net.SocketException;
+import java.util.*;
+import java.security.Security;
+import java.security.cert.*;
+
+public class CPValidatorIntermediate {
+
+    // SHA1withRSA 1024
+    static String trustAnchor_SHA1withRSA_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" +
+        "AQUAA4GNADCBiQKBgQC8UdC863pFk1Rvd7xUYd60+e9KsLhb6SqOfU42ZA715FcH\n" +
+        "E1TRvQPmYzAnHcO04TrWZQtO6E+E2RCmeBnetBvIMVka688QkO14wnrIrf2tRodd\n" +
+        "rZNZEBzkX+zyXCRo9tKEUDFf9Qze7Ilbb+Zzm9CUfu4M1Oz6iQcXRx7aM0jEAQID\n" +
+        "AQABo4GJMIGGMB0GA1UdDgQWBBTn0C+xmZY/BTab4W9gBp3dGa7WgjBHBgNVHSME\n" +
+        "QDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" +
+        "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" +
+        "DQYJKoZIhvcNAQEFBQADgYEAiCXL2Yp4ruyRXAIJ8zBEaPC9oV2agqgbSbly2z8z\n" +
+        "Ik5SeSRysP+GHBpb8uNyANJnQKv+T0GrJiTLMBjKCOiJl6xzk3EZ2wbQB6G/SQ9+\n" +
+        "UWcsXSC8oGSEPpkj5In/9/UbuUIfT9H8jmdyLNKQvlqgq6kyfnskME7ptGgT95Hc\n" +
+        "tas=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512
+    static String trustAnchor_SHA1withRSA_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBuTCCAWOgAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMFwwDQYJKoZIhvcNAQEB\n" +
+        "BQADSwAwSAJBAM0Kn4ieCdCHsrm78ZMMN4jQEEEqACAMKB7O8j9g4gfz2oAfmHwv\n" +
+        "7JH/hZ0Xen1zUmBbwe+e2J5D/4Fisp9Bn98CAwEAAaOBiTCBhjAdBgNVHQ4EFgQU\n" +
+        "g4Kwd47hdNQBp8grZsRJ5XvhvxAwRwYDVR0jBEAwPoAUg4Kwd47hdNQBp8grZsRJ\n" +
+        "5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMA8G\n" +
+        "A1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0GCSqGSIb3DQEBBQUAA0EAn77b\n" +
+        "FJx+HvyRvjZYCzMjnUct3Ql4iLOkURYDh93J5TXi/l9ajvAMEuwzYj0qZ+Ktm/ia\n" +
+        "U5r+8B9nzx+j2Zh3kw==\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 1024
+    static String intermediate_SHA1withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICUDCCAbmgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDhaFw0yOTA0MjMwMTExNDha\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADgYEAHze3wAcIe84zNOoN\n" +
+        "P8l9EmlVVoU30z3LB3hxq3m/dC/4gE5Z9Z8EG1wJw4qaxlTZ4dif12nbTTdofVhb\n" +
+        "Bd4syjo6fcUA4q7sfg9TFpoHQ+Ap7PgjK99moMKdMy50Xy8s6FPvaVkF89s66Z6y\n" +
+        "e4q7TSwe6QevGOZaL5N/iy2XGEs=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 1024 signed with RSA 512
+    static String intermediate_SHA1withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDzCCAbmgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADQQCYNmdkONfuk07XjRze\n" +
+        "WQyq2cfdae4uIdyUfa2rpgYMtSXuQW3/XrQGiz4G6WBXA2wo7folOOpAKYgvHPrm\n" +
+        "w6Dd\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 1024
+    static String intermediate_SHA1withRSA_512_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDDCCAXWgAwIBAgIBBDANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV\n" +
+        "lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA\n" +
+        "AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw\n" +
+        "PoAU59AvsZmWPwU2m+FvYAad3Rmu1oKhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
+        "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" +
+        "CSqGSIb3DQEBBQUAA4GBAE2VOlw5ySLT3gUzKCYEga4QPaSrf6lHHPi2g48LscEY\n" +
+        "h9qQXh4nuIVugReBIEf6N49RdT+M2cgRJo4sZ3ukYLGQzxNuttL5nPSuuvrAR1oG\n" +
+        "LUyzOWcUpKHbVHi6zlTt79RvTKZvLcduLutmtPtLJcM9PdiAI1wEooSgxTwZtB/Z\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512 signed with RSA 512
+    static String intermediate_SHA1withRSA_512_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIByzCCAXWgAwIBAgIBBTANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV\n" +
+        "lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA\n" +
+        "AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw\n" +
+        "PoAUg4Kwd47hdNQBp8grZsRJ5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" +
+        "VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G\n" +
+        "CSqGSIb3DQEBBQUAA0EAoCf0Zu559qcB4xPpzqkVsYiyW49S4Yc0mmQXb1yoQgLx\n" +
+        "O+DCkjG5d14+t1MsnkhB2izoQUMxQ3vDc1YnA/tEpw==\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 1024
+    static String intermediate_MD2withRSA_1024_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICUDCCAbmgAwIBAgIBBjANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEAPtEjwbWuC5kc4DPc\n" +
+        "Ttf/wdbD8ZCdAWzcc3XF9q1TlvwVMNk6mbfM05y6ZVsztKTkwZ4EcvFu/yIqw1EB\n" +
+        "E1zlXQCaWXT3/ZMbqYZV4+mx+RUl8spUCb1tda25jnTg3mTOzB1iztm4gy903EMd\n" +
+        "m8omKDKeCgcw5dR4ITQYvyxe1as=\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 1024 signed with RSA 512
+    static String intermediate_MD2withRSA_1024_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICDzCCAbmgAwIBAgIBBzANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla\n" +
+        "MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz\n" +
+        "cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8\n" +
+        "BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg\n" +
+        "bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82\n" +
+        "AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl\n" +
+        "UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw\n" +
+        "HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw\n" +
+        "AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADQQBHok1v6xymtpB7N9xy\n" +
+        "0OmDT27uhmzlP0eOzJvXVxj3Oi9TLQJgCUJ9122MzfRAs1E1uJTtvuu+UmI80NQx\n" +
+        "KQdp\n" +
+        "-----END CERTIFICATE-----";
+
+    private static CertPath generateCertificatePath(String certStr)
+            throws CertificateException {
+        // generate certificate from cert strings
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        ByteArrayInputStream is;
+
+        is = new ByteArrayInputStream(certStr.getBytes());
+        Certificate cert = cf.generateCertificate(is);
+
+        // generate certification path
+        List<Certificate> list = Arrays.asList(new Certificate[] {cert});
+
+        return cf.generateCertPath(list);
+    }
+
+    private static Set<TrustAnchor> generateTrustAnchors()
+            throws CertificateException {
+        // generate certificate from cert string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+        HashSet<TrustAnchor> anchors = new HashSet<TrustAnchor>();
+
+        ByteArrayInputStream is =
+            new ByteArrayInputStream(trustAnchor_SHA1withRSA_1024.getBytes());
+        Certificate cert = cf.generateCertificate(is);
+        TrustAnchor anchor = new TrustAnchor((X509Certificate)cert, null);
+        anchors.add(anchor);
+
+        is = new ByteArrayInputStream(trustAnchor_SHA1withRSA_512.getBytes());
+        cert = cf.generateCertificate(is);
+        anchor = new TrustAnchor((X509Certificate)cert, null);
+        anchors.add(anchor);
+
+        return anchors;
+    }
+
+    public static void main(String args[]) throws Exception {
+        try {
+            validate(intermediate_SHA1withRSA_1024_1024);
+            validate(intermediate_SHA1withRSA_1024_512);
+            validate(intermediate_SHA1withRSA_512_1024);
+            validate(intermediate_SHA1withRSA_512_512);
+        } catch (CertPathValidatorException cpve) {
+            throw new Exception(
+                "unexpect exception, it is valid cert", cpve);
+        }
+
+        try {
+            validate(intermediate_MD2withRSA_1024_1024);
+            throw new Exception("expected algorithm disabled exception");
+        } catch (CertPathValidatorException cpve) {
+            System.out.println("Get the expected exception " + cpve);
+        }
+
+        try {
+            validate(intermediate_MD2withRSA_1024_512);
+            throw new Exception("expected algorithm disabled exception");
+        } catch (CertPathValidatorException cpve) {
+            System.out.println("Get the expected exception " + cpve);
+        }
+    }
+
+    private static void validate(String intermediate)
+            throws CertPathValidatorException, Exception {
+
+        CertPath path = generateCertificatePath(intermediate);
+        Set<TrustAnchor> anchors = generateTrustAnchors();
+
+        PKIXParameters params = new PKIXParameters(anchors);
+
+        // disable certificate revocation checking
+        params.setRevocationEnabled(false);
+
+        // set the validation time
+        params.setDate(new Date(109, 9, 1));   // 2009-09-01
+
+        CertPathValidator validator = CertPathValidator.getInstance("PKIX");
+
+        validator.validate(path, params);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/DisabledAlgorithms/CPValidatorTrustAnchor.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,169 @@
+/*
+ * 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 6861062
+ * @summary Disable MD2 support
+ *
+ * @author Xuelei Fan
+ */
+
+import java.io.*;
+import java.net.SocketException;
+import java.util.*;
+import java.security.Security;
+import java.security.cert.*;
+
+public class CPValidatorTrustAnchor {
+
+    static String selfSignedCertStr = null;
+
+    // SHA1withRSA 1024
+    static String trustAnchor_SHA1withRSA_1024 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" +
+        "AQUAA4GNADCBiQKBgQC8UdC863pFk1Rvd7xUYd60+e9KsLhb6SqOfU42ZA715FcH\n" +
+        "E1TRvQPmYzAnHcO04TrWZQtO6E+E2RCmeBnetBvIMVka688QkO14wnrIrf2tRodd\n" +
+        "rZNZEBzkX+zyXCRo9tKEUDFf9Qze7Ilbb+Zzm9CUfu4M1Oz6iQcXRx7aM0jEAQID\n" +
+        "AQABo4GJMIGGMB0GA1UdDgQWBBTn0C+xmZY/BTab4W9gBp3dGa7WgjBHBgNVHSME\n" +
+        "QDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" +
+        "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" +
+        "DQYJKoZIhvcNAQEFBQADgYEAiCXL2Yp4ruyRXAIJ8zBEaPC9oV2agqgbSbly2z8z\n" +
+        "Ik5SeSRysP+GHBpb8uNyANJnQKv+T0GrJiTLMBjKCOiJl6xzk3EZ2wbQB6G/SQ9+\n" +
+        "UWcsXSC8oGSEPpkj5In/9/UbuUIfT9H8jmdyLNKQvlqgq6kyfnskME7ptGgT95Hc\n" +
+        "tas=\n" +
+        "-----END CERTIFICATE-----";
+
+    // SHA1withRSA 512
+    static String trustAnchor_SHA1withRSA_512 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIBuTCCAWOgAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMFwwDQYJKoZIhvcNAQEB\n" +
+        "BQADSwAwSAJBAM0Kn4ieCdCHsrm78ZMMN4jQEEEqACAMKB7O8j9g4gfz2oAfmHwv\n" +
+        "7JH/hZ0Xen1zUmBbwe+e2J5D/4Fisp9Bn98CAwEAAaOBiTCBhjAdBgNVHQ4EFgQU\n" +
+        "g4Kwd47hdNQBp8grZsRJ5XvhvxAwRwYDVR0jBEAwPoAUg4Kwd47hdNQBp8grZsRJ\n" +
+        "5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMA8G\n" +
+        "A1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0GCSqGSIb3DQEBBQUAA0EAn77b\n" +
+        "FJx+HvyRvjZYCzMjnUct3Ql4iLOkURYDh93J5TXi/l9ajvAMEuwzYj0qZ+Ktm/ia\n" +
+        "U5r+8B9nzx+j2Zh3kw==\n" +
+        "-----END CERTIFICATE-----";
+
+    // MD2withRSA 2048
+    static String trustAnchor_MD2withRSA_2048 =
+        "-----BEGIN CERTIFICATE-----\n" +
+        "MIIDQzCCAiugAwIBAgIBADANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ\n" +
+        "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDdaFw0zMDA3MTcwMTExNDda\n" +
+        "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIIBIjANBgkqhkiG9w0B\n" +
+        "AQEFAAOCAQ8AMIIBCgKCAQEArF5pINc5s+aUlmdYlxtAQ3V4TXFnP/XOYHxjfLuX\n" +
+        "eKO/kh78LMvbDisTPQ2yo9YEawwwbUU40xcuzgi0axXgKveHXYdUmTr0hEapq3rv\n" +
+        "g/q2EbOjyXvq4qK2RDoVCN8R3wXiytnY2OFALTx6zc2tW4imJ20svdNVtWhv2syj\n" +
+        "ZTmmRXAeFUbD4qKWAFij0I6pnSgVssvWzeyJUNemym+oiYyaSd7n5j1RNAqUKioo\n" +
+        "K/T0FOOiuPGMqottgx5YRHa6yapCP5QVWRQ+WBIYJY3Wyq7N+Es20LT6761Pk3to\n" +
+        "EFCzM7+zqT/c+pC079HOKXz+m2us+HKp5BKWNnbvgaYPOQIDAQABo4GJMIGGMB0G\n" +
+        "A1UdDgQWBBSrSukJf+mO5LTRasAGD9RRs7SASTBHBgNVHSMEQDA+gBSrSukJf+mO\n" +
+        "5LTRasAGD9RRs7SASaEjpCEwHzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1w\n" +
+        "bGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEC\n" +
+        "BQADggEBAHvsv+DqMJeIW/D+ltkhw37OdMzkMPp4E6Hbp03O3GZ5LfNGczHCb2uL\n" +
+        "sr5T7e/jaBFn6QfmqbOAYAHJSNq2bNNtTbatnHBLuVx13cfxmwk89Cg/tFeoUdcf\n" +
+        "m5hzurB6Ub6SsYMOxZHUYp/KxM9x9a7llC1bK3SKXwd4rVDlXh8DOBvdQNr5Q3yq\n" +
+        "JjY86bSXO14VzNxL/1rqHiszQdPyR/28SBsQVYSi0Zeyc4Yy1ui/cXu1+PWYw3YZ\n" +
+        "QUPHTnkVdPGwRiUqeZIcps+q+ePlQQmDu5qiLD6d8gsyGyY/RvCHWKO5Y9DuX9hs\n" +
+        "he/AhCWQx+TQYGLu0liQqLkGZydyRnA=\n" +
+        "-----END CERTIFICATE-----";
+
+    private static CertPath generateCertificatePath()
+            throws CertificateException {
+        // generate certificate from cert strings
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        ByteArrayInputStream is;
+
+        is = new ByteArrayInputStream(selfSignedCertStr.getBytes());
+        Certificate selfSignedCert = cf.generateCertificate(is);
+
+        // generate certification path
+        List<Certificate> list = Arrays.asList(new Certificate[] {
+                        selfSignedCert});
+
+        return cf.generateCertPath(list);
+    }
+
+    private static Set<TrustAnchor> generateTrustAnchors()
+            throws CertificateException {
+        // generate certificate from cert string
+        CertificateFactory cf = CertificateFactory.getInstance("X.509");
+
+        ByteArrayInputStream is =
+                    new ByteArrayInputStream(selfSignedCertStr.getBytes());
+        Certificate selfSignedCert = cf.generateCertificate(is);
+
+        // generate a trust anchor
+        TrustAnchor anchor =
+            new TrustAnchor((X509Certificate)selfSignedCert, null);
+
+        return Collections.singleton(anchor);
+    }
+
+    public static void main(String args[]) throws Exception {
+        try {
+            validate(trustAnchor_SHA1withRSA_1024);
+            validate(trustAnchor_SHA1withRSA_512);
+        } catch (CertPathValidatorException cpve) {
+            throw new Exception(
+                "unexpect exception, it is valid cert", cpve);
+        }
+
+        try {
+            validate(trustAnchor_MD2withRSA_2048);
+            throw new Exception("expected algorithm disabled exception");
+        } catch (CertPathValidatorException cpve) {
+            System.out.println("Get the expected exception " + cpve);
+        }
+    }
+
+    private static void validate(String trustAnchor)
+            throws CertPathValidatorException, Exception {
+        selfSignedCertStr = trustAnchor;
+
+        CertPath path = generateCertificatePath();
+        Set<TrustAnchor> anchors = generateTrustAnchors();
+
+        PKIXParameters params = new PKIXParameters(anchors);
+
+        // disable certificate revocation checking
+        params.setRevocationEnabled(false);
+
+        // set the validation time
+        params.setDate(new Date(109, 9, 1));   // 2009-09-01
+
+        CertPathValidator validator = CertPathValidator.getInstance("PKIX");
+
+        validator.validate(path, params);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/DisabledAlgorithms/README	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,640 @@
+/*
+ * 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.
+ */
+
+                  Certificates and CRLs
+
+Here lists the Certificates, which was generated by generate.sh, used in the
+test cases.
+
+The generate.sh depends on openssl, and it should be run under ksh. The
+script will create many directories and files, please run it in a
+directory outside of JDK workspace.
+
+1. root certifiate and key (SHA1withRSA 1024, root_cert_sha1_1024.pem)
+-----BEGIN CERTIFICATE-----
+MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa
+MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB
+AQUAA4GNADCBiQKBgQC8UdC863pFk1Rvd7xUYd60+e9KsLhb6SqOfU42ZA715FcH
+E1TRvQPmYzAnHcO04TrWZQtO6E+E2RCmeBnetBvIMVka688QkO14wnrIrf2tRodd
+rZNZEBzkX+zyXCRo9tKEUDFf9Qze7Ilbb+Zzm9CUfu4M1Oz6iQcXRx7aM0jEAQID
+AQABo4GJMIGGMB0GA1UdDgQWBBTn0C+xmZY/BTab4W9gBp3dGa7WgjBHBgNVHSME
+QDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEwHzELMAkGA1UEBhMCVVMxEDAO
+BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw
+DQYJKoZIhvcNAQEFBQADgYEAiCXL2Yp4ruyRXAIJ8zBEaPC9oV2agqgbSbly2z8z
+Ik5SeSRysP+GHBpb8uNyANJnQKv+T0GrJiTLMBjKCOiJl6xzk3EZ2wbQB6G/SQ9+
+UWcsXSC8oGSEPpkj5In/9/UbuUIfT9H8jmdyLNKQvlqgq6kyfnskME7ptGgT95Hc
+tas=
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,DF5249E009A0FD79
+
+rc316yLipp/vH0i6rhEbEwZpZ+HfKIXnnp/bIIZv2+4lyGUDWrxN0Hk0TcSgWEKm
+dRGI2fsyWjTgaiHwwmusofXPAjB3s0I2rUUAHXk8/sEuiLLTICx2UAL8k6R33CSQ
+NKR8t+TluBW3Us71vibWauuMHa5860KiiLWdhkQVLin7m/JBGLtz0zQ0/lZ8CgEm
+p7eDupPi8FBClCyVewdpmKjgI2KPI4fVIZLMzLeGcWLaOQPN1ERcFWQ1CS/qjfMb
+F4rtpZ+AzCqP75XPhitT2CnZgaVDxHBtAZQVPuKONMdijKphjqiT/Sd86Gx6OEVE
+EwwmQya2Q/5aCuH96S00mj00oeIZ7ZtUcVQcch+saJy4vpuxK8pFcEDKmgsvL9+8
+Hho9RUXVUKRH67uA1NjQSK5+syEIj5sJCDcxOda4QGXeIq9ygaZswxF3nfvffrsa
+S6IVBXrx0G+Ascu29SHoI+zi3feQszQJIzijHoTTq6FacLHUWzfVuaYa47uaj5qa
+VYsMVCzi1eX486o7YKPKWiclNczQN86v5n9+c9uggXY12wSOmnf6BB1Ds+oL8JlU
+IZa67lAyg6G9joAb9rTXN2EE5OTArcFuImK8GHse/3wkIPMglBNnfwpvjC1U+vQm
+F7iXp+OxnZ5d9sBcrTBEZ9BDlTVlpiZI7EeS1oC8x6DDTdbJR/40Y3wJIDMI9q9T
+O5EnyXqbmQziO0Tgal43w6mMTUnhG34kqovwxy03mAOZb3yz/RgWlez9wQmPseiI
+2p2fQIjCPbGFNJt3rdyXOW/BRCii0970HEZeov/TVV/A0vUVajNAjA==
+-----END RSA PRIVATE KEY-----
+
+2. root certifiate and key (SHA1withRSA 512, root_cert_sha1_512.pem)
+-----BEGIN CERTIFICATE-----
+MIIBuTCCAWOgAwIBAgIBADANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDRaFw0zMDA3MTcwMTExNDRa
+MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMFwwDQYJKoZIhvcNAQEB
+BQADSwAwSAJBAM0Kn4ieCdCHsrm78ZMMN4jQEEEqACAMKB7O8j9g4gfz2oAfmHwv
+7JH/hZ0Xen1zUmBbwe+e2J5D/4Fisp9Bn98CAwEAAaOBiTCBhjAdBgNVHQ4EFgQU
+g4Kwd47hdNQBp8grZsRJ5XvhvxAwRwYDVR0jBEAwPoAUg4Kwd47hdNQBp8grZsRJ
+5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMA8G
+A1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0GCSqGSIb3DQEBBQUAA0EAn77b
+FJx+HvyRvjZYCzMjnUct3Ql4iLOkURYDh93J5TXi/l9ajvAMEuwzYj0qZ+Ktm/ia
+U5r+8B9nzx+j2Zh3kw==
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,B8BDE38F08C6BB76
+
+eJzx2oZE0UXxWpzssSWtKBOCbm3ZXR6iBKX8iKoDUB5SzzmKr+XzxI7kyv92y0pe
+rNTuuCWpBsLdlz7h8Ipn4pBDYswGU5F9MQOEgIYx60OvGhZODHGRzJ05FXTeCmmu
+LLp6lGW4SWALcd8g/gJUn1/vp7f1VzQ7RwXWBn4/b34RRYtwr3E6nl4Hc2tEI1in
+OL+lCdAAyxjGK7KYFHJQK+1E8tYNrer3cejQDcNysGx4o0H123vfp3NtJ6U7LXyi
+D21y3zmPueJos8LluJiLRsONcrcI3mIfpPBsO+Yl2EJtzS9V6Aaq/YdPkwPHH6Y5
+lazGMPXq/nffb12fWLL7m5aFb3FNLwWi/qwEynWCEv7Vl/6kLk+aHhjTnYkLvLNH
+9maQFn6j0S3wqogRfW9BDbfC3fRHP6+8YjEEmQ0RTfE=
+-----END RSA PRIVATE KEY-----
+
+3. root certifiate and key (MD2withRSA 2048, root_cert_md2_2048.pem)
+-----BEGIN CERTIFICATE-----
+MIIDQzCCAiugAwIBAgIBADANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDdaFw0zMDA3MTcwMTExNDda
+MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIIBIjANBgkqhkiG9w0B
+AQEFAAOCAQ8AMIIBCgKCAQEArF5pINc5s+aUlmdYlxtAQ3V4TXFnP/XOYHxjfLuX
+eKO/kh78LMvbDisTPQ2yo9YEawwwbUU40xcuzgi0axXgKveHXYdUmTr0hEapq3rv
+g/q2EbOjyXvq4qK2RDoVCN8R3wXiytnY2OFALTx6zc2tW4imJ20svdNVtWhv2syj
+ZTmmRXAeFUbD4qKWAFij0I6pnSgVssvWzeyJUNemym+oiYyaSd7n5j1RNAqUKioo
+K/T0FOOiuPGMqottgx5YRHa6yapCP5QVWRQ+WBIYJY3Wyq7N+Es20LT6761Pk3to
+EFCzM7+zqT/c+pC079HOKXz+m2us+HKp5BKWNnbvgaYPOQIDAQABo4GJMIGGMB0G
+A1UdDgQWBBSrSukJf+mO5LTRasAGD9RRs7SASTBHBgNVHSMEQDA+gBSrSukJf+mO
+5LTRasAGD9RRs7SASaEjpCEwHzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1w
+bGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEC
+BQADggEBAHvsv+DqMJeIW/D+ltkhw37OdMzkMPp4E6Hbp03O3GZ5LfNGczHCb2uL
+sr5T7e/jaBFn6QfmqbOAYAHJSNq2bNNtTbatnHBLuVx13cfxmwk89Cg/tFeoUdcf
+m5hzurB6Ub6SsYMOxZHUYp/KxM9x9a7llC1bK3SKXwd4rVDlXh8DOBvdQNr5Q3yq
+JjY86bSXO14VzNxL/1rqHiszQdPyR/28SBsQVYSi0Zeyc4Yy1ui/cXu1+PWYw3YZ
+QUPHTnkVdPGwRiUqeZIcps+q+ePlQQmDu5qiLD6d8gsyGyY/RvCHWKO5Y9DuX9hs
+he/AhCWQx+TQYGLu0liQqLkGZydyRnA=
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,3910D329AD49ECFC
+
+6K0OU3Xrl2H6kz7x7EHXkM0/Wd6jXBBwWsaroUIGnbIMmljJXPfgcuDUu6f5Imk1
+ndoU0GWjxa1QNjteAQQtFoLDP8rienLs0b969OcAxB0EOffQFkEfsfXdyEIgdwkD
+ETczwDIyd8Wj62ClydJES3jKB9Nc9kMIlsoZ+h24TyJeeRsHAtMrz+mlOHsUWDQ5
+FyYZelnx+fQ5maD3bura7xLiNl8CvgWz0wt2Wt4djdMGhQ3OWd0/GWweP+2xnL6n
+5tDJ5On50+Z5T8Jhx62yg+wQiBKAYnYw6OX3skJwWknuAvYz3Z3e12DHFx6w5EAU
+K7lg7fHMqHNirUkJOlYzgJ21ybV4uQmFRNQJwI9h6GVfdZWPEU+Ni42AlNgNYskF
+K19dONNNt0Gwkcm2VOYzwYGDyaQW2YIGDk1fbZdVSu/h/lyOC/RmorGWroAbYsyB
+/GUIilcLtQHPGI8XuojTS2/UWcKactpceN3UOnQkus3/smViEqqB/NQ/lcozgs0o
+7ZG6H6to7w1yb5VR2d7B2bS7MNJt1AsOB5ydAMYIccdHDTI7CfRK6axQ70O/JPnJ
+WLY2e41ig2uAWk/3fRb8L6d3keVcN7y4WnkXPbHhulqtxQo78iSQQAf7tDMBxWKx
+C5LQW3CxLkHKp6g22SDxl2LjJyu5nDbtIh3Pq+BCoA25uqXC4rPoWwV7EWYv8Z+Y
+E6dS98SEa+cDhpllvGzbTKgcP1VqtQbb9VT92UT1mFrklqRuQIxROeCe4wjp5TKo
+D2losUDdzpqBHkBNo2I8qZkgybeCvWEq73my2+JG1AAIFFB1kzfBNaBDGiGSuUuS
+5peV8156aaLg5pxdieoRJ3Y7eaWN1wH5CnRnafoB+lxSUsQO1a7y2LbpedrKjs+2
+AryPHQw7HLd8IQevmvd7BhJLdvlt+kXzWID/pUsSAYvI7aP4daQJuAt/kwmU27Gd
+wqhV8Tjbb84vFGmqGHtb2YbKfUrsPUNOLBF+U4SDAgBhEyhINQZyRDcqqoywO5Dr
+sV46nTEfwAgt88KFt2CEhiyvoJbtCj1iMJeAzuljwF4z4RzB1i3TK0MaJYID2rxB
+E1vK9EZIssk/NeImN2YCbuqOhU58jtOwYh3ruS+mZQm1APvJF9N4tCCVQsjWC6zY
+4eqs7T6VDFH4AaT7b3J3rTsEpWIDUfagetZs5kR9SiWJC7dU7r53gGg4avVyIIHD
++MYCS+auD9/nmVf4iYstVgJFMUJXC2EUOLi0r8KmDkCILl/K3X/W7QwFTnC07gLh
+/9HjWFJ0R6cyODzvE8NGPMeuJGUT2F+mA1vaAC/PBGz+61AF0BjWTZ7x2sH+tSPP
+/GVEaCgyzrKRX5XX+7DulTcmFj1JNfMmtbDaJa9WnwOI4qszBGrAcYeYTHXR6Yov
+Ux/P6RStfa+UwSjo8i3nfdgLk+RXCpN0srMjSmiQx8d5R/kISqXKDtQfS5M6gsoh
+ROz+6zZP8Gh8yakr1p4C6JUSiLDYP5qXzxr8bp+oxvpY7anEDAqx21HyExEAu+gy
+IrNl75FWqV8BbKxoFfe9LqyDaryXXA8oy6F+4BT/zRrxp+dym9pbd+OZR423BIij
+-----END RSA PRIVATE KEY-----
+
+4. subca certificate and key (SHA1withRSA 1024, root_cert_sha1_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIICUDCCAbmgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDhaFw0yOTA0MjMwMTExNDha
+MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz
+cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8
+BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg
+bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82
+AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl
+UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw
+HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw
+AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADgYEAHze3wAcIe84zNOoN
+P8l9EmlVVoU30z3LB3hxq3m/dC/4gE5Z9Z8EG1wJw4qaxlTZ4dif12nbTTdofVhb
+Bd4syjo6fcUA4q7sfg9TFpoHQ+Ap7PgjK99moMKdMy50Xy8s6FPvaVkF89s66Z6y
+e4q7TSwe6QevGOZaL5N/iy2XGEs=
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,0480E76FD259323B
+
+npiifBm1mHq1Z9QgAV5T35Xbnea9VnwqYQWNfRRKmpfYSdkQJ0few18YtnfZwh9e
+LKCWx+lq1V4yDG4SbxXDq71Dyvx1vZY+w4h+6M1+6KGFG1VDBfN3e5aLgK8EG9pZ
+yHZH7iB7HiQXH5q53jL6NUZn55C3XEk1sErpK7R1c0Y8Qp2TGiu+lck3K+zR9GiO
+5aJMKbShReB0Nfy3JJNKRFSd95QMTTjbq6iIvhN8O02bo4I4I3HTyD8qyR7ViiHl
+FmOukjwn4fjJvK0WYKYUjod8oEiMdR2nr73eOGZBAnEorDGQ8VnnCAleSv74is1k
+W7M07UP7EJJq9hSZfeMqk5QivtWrqvWG1SWxpTowKTEAyTn7u5U13k0DiRcsg0WT
+4mSMiLOhUNgIWcHElbTQPSVDcVznhNk0dWPDwKoUjp+orCuH+NvHKBAu+hnuip3e
+Ji7WGrHXI7QxAr5qr5ogl5x4yH4drIbq9fUea3NTuGPuPyu9fWjOSDmqPRKRMJFR
+UxxVFcyrW8iSBV5cvB7M1ADS40y6l4ryYmKjXbsOI4Ci8LJWJ4ZB61WQP7TvPQGS
+mNFmTTB2dwbpimr4KjV9j2bA9x0jAsjlcQZ5j1GOeyYCEDGKDJw0XD/zI+j0dpVc
+eu8YtuJGTyO1h+HiI3D9LrMuyUxxckvFHKe00+4xMz1hpqVo/kxe6gqf/9ES4M/h
+6/NeTzeqyJF2rgxK6KJJdmaKVYI+bvAQ3cKl+RZmgOjx4eig58N5uthqFgU7rQ+e
+GM9/y8C9WpPqITcJlY7I/7AkqvYDBwBsH/9mf4g9OUbC1Ah+MX8UIQ==
+-----END RSA PRIVATE KEY-----
+
+
+5. subca certificate and key (SHA1withRSA 1024, root_cert_sha1_512.pem signed)
+-----BEGIN CERTIFICATE-----
+MIICDzCCAbmgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla
+MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz
+cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8
+BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg
+bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82
+AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl
+UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw
+HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw
+AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQEFBQADQQCYNmdkONfuk07XjRze
+WQyq2cfdae4uIdyUfa2rpgYMtSXuQW3/XrQGiz4G6WBXA2wo7folOOpAKYgvHPrm
+w6Dd
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,0480E76FD259323B
+
+npiifBm1mHq1Z9QgAV5T35Xbnea9VnwqYQWNfRRKmpfYSdkQJ0few18YtnfZwh9e
+LKCWx+lq1V4yDG4SbxXDq71Dyvx1vZY+w4h+6M1+6KGFG1VDBfN3e5aLgK8EG9pZ
+yHZH7iB7HiQXH5q53jL6NUZn55C3XEk1sErpK7R1c0Y8Qp2TGiu+lck3K+zR9GiO
+5aJMKbShReB0Nfy3JJNKRFSd95QMTTjbq6iIvhN8O02bo4I4I3HTyD8qyR7ViiHl
+FmOukjwn4fjJvK0WYKYUjod8oEiMdR2nr73eOGZBAnEorDGQ8VnnCAleSv74is1k
+W7M07UP7EJJq9hSZfeMqk5QivtWrqvWG1SWxpTowKTEAyTn7u5U13k0DiRcsg0WT
+4mSMiLOhUNgIWcHElbTQPSVDcVznhNk0dWPDwKoUjp+orCuH+NvHKBAu+hnuip3e
+Ji7WGrHXI7QxAr5qr5ogl5x4yH4drIbq9fUea3NTuGPuPyu9fWjOSDmqPRKRMJFR
+UxxVFcyrW8iSBV5cvB7M1ADS40y6l4ryYmKjXbsOI4Ci8LJWJ4ZB61WQP7TvPQGS
+mNFmTTB2dwbpimr4KjV9j2bA9x0jAsjlcQZ5j1GOeyYCEDGKDJw0XD/zI+j0dpVc
+eu8YtuJGTyO1h+HiI3D9LrMuyUxxckvFHKe00+4xMz1hpqVo/kxe6gqf/9ES4M/h
+6/NeTzeqyJF2rgxK6KJJdmaKVYI+bvAQ3cKl+RZmgOjx4eig58N5uthqFgU7rQ+e
+GM9/y8C9WpPqITcJlY7I/7AkqvYDBwBsH/9mf4g9OUbC1Ah+MX8UIQ==
+-----END RSA PRIVATE KEY-----
+
+
+6. subca certificate and key (SHA1withRSA 512, root_cert_sha1_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIICDDCCAXWgAwIBAgIBBDANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla
+MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz
+cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV
+lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA
+AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw
+PoAU59AvsZmWPwU2m+FvYAad3Rmu1oKhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD
+VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G
+CSqGSIb3DQEBBQUAA4GBAE2VOlw5ySLT3gUzKCYEga4QPaSrf6lHHPi2g48LscEY
+h9qQXh4nuIVugReBIEf6N49RdT+M2cgRJo4sZ3ukYLGQzxNuttL5nPSuuvrAR1oG
+LUyzOWcUpKHbVHi6zlTt79RvTKZvLcduLutmtPtLJcM9PdiAI1wEooSgxTwZtB/Z
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,0A94F7EA4C89CA33
+
+tfKdAZVSrpeS/hU4+mGYcGGx3nNqrE+CzDAfLadVuXz5ju5p9oFhLTZj99wK+uHn
+prrWmDNOdYKRBJn7h40WV6zi4lR3JgnuYNxH8fxO3PI+HQ9IuvdoTyqUeXTP4Zj1
+BCnr1k1D2WGDXvnh+saq9qRpMKThjK/OF0YmDa07PI5NOBdMA3EmkNYfwib2GfBV
+el4FVkfnPQkLGahTh3SC62TzPlnsAgirCeua7ZLPqN3fkZkYbXZd9op2D31n7cBP
+zztg0ah8WF4gPOd/BBZeR9XDog5qm/wzyBj0F6ClHRPjpGYhAm2Vw66xOBlGFYI9
+lVmFQzrPcDNlFTybzhl5C6Qy4cPQh+QErDWxljVI52oYYmY/KRmUGGL7hEG8ZGOn
+EUgFrEJyAY7w4wpBC5n9SotwyPXhwKQ1uCBq+1zElPw=
+-----END RSA PRIVATE KEY-----
+
+7. subca certificate and key (SHA1withRSA 512, root_cert_sha1_512.pem signed)
+-----BEGIN CERTIFICATE-----
+MIIByzCCAXWgAwIBAgIBBTANBgkqhkiG9w0BAQUFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla
+MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz
+cy0xMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKubXYoEHZpZkhzA9XX+NrpqJ4SV
+lOMBoL3aWExQpJIgrUaZfbGMBBozIHBJMMayokguHbJvq4QigEgLuhfJNqsCAwEA
+AaOBiTCBhjAdBgNVHQ4EFgQUN0CHiTYPtjyvpP2a6y6mhsZ6U40wRwYDVR0jBEAw
+PoAUg4Kwd47hdNQBp8grZsRJ5XvhvxChI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD
+VQQKEwdFeGFtcGxlggEAMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgIEMA0G
+CSqGSIb3DQEBBQUAA0EAoCf0Zu559qcB4xPpzqkVsYiyW49S4Yc0mmQXb1yoQgLx
+O+DCkjG5d14+t1MsnkhB2izoQUMxQ3vDc1YnA/tEpw==
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,0A94F7EA4C89CA33
+
+tfKdAZVSrpeS/hU4+mGYcGGx3nNqrE+CzDAfLadVuXz5ju5p9oFhLTZj99wK+uHn
+prrWmDNOdYKRBJn7h40WV6zi4lR3JgnuYNxH8fxO3PI+HQ9IuvdoTyqUeXTP4Zj1
+BCnr1k1D2WGDXvnh+saq9qRpMKThjK/OF0YmDa07PI5NOBdMA3EmkNYfwib2GfBV
+el4FVkfnPQkLGahTh3SC62TzPlnsAgirCeua7ZLPqN3fkZkYbXZd9op2D31n7cBP
+zztg0ah8WF4gPOd/BBZeR9XDog5qm/wzyBj0F6ClHRPjpGYhAm2Vw66xOBlGFYI9
+lVmFQzrPcDNlFTybzhl5C6Qy4cPQh+QErDWxljVI52oYYmY/KRmUGGL7hEG8ZGOn
+EUgFrEJyAY7w4wpBC5n9SotwyPXhwKQ1uCBq+1zElPw=
+-----END RSA PRIVATE KEY-----
+
+8. subca certificate and key (MD2withRSA 1024, root_cert_sha1_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIICUDCCAbmgAwIBAgIBBjANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla
+MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz
+cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8
+BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg
+bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82
+AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl
+UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBTn0C+xmZY/BTab4W9gBp3dGa7WgqEjpCEw
+HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw
+AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADgYEAPtEjwbWuC5kc4DPc
+Ttf/wdbD8ZCdAWzcc3XF9q1TlvwVMNk6mbfM05y6ZVsztKTkwZ4EcvFu/yIqw1EB
+E1zlXQCaWXT3/ZMbqYZV4+mx+RUl8spUCb1tda25jnTg3mTOzB1iztm4gy903EMd
+m8omKDKeCgcw5dR4ITQYvyxe1as=
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,0480E76FD259323B
+
+npiifBm1mHq1Z9QgAV5T35Xbnea9VnwqYQWNfRRKmpfYSdkQJ0few18YtnfZwh9e
+LKCWx+lq1V4yDG4SbxXDq71Dyvx1vZY+w4h+6M1+6KGFG1VDBfN3e5aLgK8EG9pZ
+yHZH7iB7HiQXH5q53jL6NUZn55C3XEk1sErpK7R1c0Y8Qp2TGiu+lck3K+zR9GiO
+5aJMKbShReB0Nfy3JJNKRFSd95QMTTjbq6iIvhN8O02bo4I4I3HTyD8qyR7ViiHl
+FmOukjwn4fjJvK0WYKYUjod8oEiMdR2nr73eOGZBAnEorDGQ8VnnCAleSv74is1k
+W7M07UP7EJJq9hSZfeMqk5QivtWrqvWG1SWxpTowKTEAyTn7u5U13k0DiRcsg0WT
+4mSMiLOhUNgIWcHElbTQPSVDcVznhNk0dWPDwKoUjp+orCuH+NvHKBAu+hnuip3e
+Ji7WGrHXI7QxAr5qr5ogl5x4yH4drIbq9fUea3NTuGPuPyu9fWjOSDmqPRKRMJFR
+UxxVFcyrW8iSBV5cvB7M1ADS40y6l4ryYmKjXbsOI4Ci8LJWJ4ZB61WQP7TvPQGS
+mNFmTTB2dwbpimr4KjV9j2bA9x0jAsjlcQZ5j1GOeyYCEDGKDJw0XD/zI+j0dpVc
+eu8YtuJGTyO1h+HiI3D9LrMuyUxxckvFHKe00+4xMz1hpqVo/kxe6gqf/9ES4M/h
+6/NeTzeqyJF2rgxK6KJJdmaKVYI+bvAQ3cKl+RZmgOjx4eig58N5uthqFgU7rQ+e
+GM9/y8C9WpPqITcJlY7I/7AkqvYDBwBsH/9mf4g9OUbC1Ah+MX8UIQ==
+-----END RSA PRIVATE KEY-----
+
+
+9. subca certificate and key (MD2withRSA 1024, root_cert_sha1_512.pem signed)
+-----BEGIN CERTIFICATE-----
+MIICDzCCAbmgAwIBAgIBBzANBgkqhkiG9w0BAQIFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDYwMTExNDlaFw0yOTA0MjMwMTExNDla
+MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz
+cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVOqnlZspyAEr90ELFaUo8
+BF0O2Kn0yTdUeyiLOth4RA3qxWrjxJq45VmEBjZpEzPHfnp3PhnfmLcLfhoPONFg
+bcHzlkj75ZaKCgHoyV456fMBmj348fcoUkH2WdSQ82pmxHOiHqquYNUSTimFIq82
+AayhbKqDmhfx5lJdYNqd5QIDAQABo4GJMIGGMB0GA1UdDgQWBBTfWD9mRTppcUAl
+UqGuu/R5t8CB5jBHBgNVHSMEQDA+gBSDgrB3juF01AGnyCtmxEnle+G/EKEjpCEw
+HzELMAkGA1UEBhMCVVMxEDAOBgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUw
+AwEB/zALBgNVHQ8EBAMCAgQwDQYJKoZIhvcNAQECBQADQQBHok1v6xymtpB7N9xy
+0OmDT27uhmzlP0eOzJvXVxj3Oi9TLQJgCUJ9122MzfRAs1E1uJTtvuu+UmI80NQx
+KQdp
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,0480E76FD259323B
+
+npiifBm1mHq1Z9QgAV5T35Xbnea9VnwqYQWNfRRKmpfYSdkQJ0few18YtnfZwh9e
+LKCWx+lq1V4yDG4SbxXDq71Dyvx1vZY+w4h+6M1+6KGFG1VDBfN3e5aLgK8EG9pZ
+yHZH7iB7HiQXH5q53jL6NUZn55C3XEk1sErpK7R1c0Y8Qp2TGiu+lck3K+zR9GiO
+5aJMKbShReB0Nfy3JJNKRFSd95QMTTjbq6iIvhN8O02bo4I4I3HTyD8qyR7ViiHl
+FmOukjwn4fjJvK0WYKYUjod8oEiMdR2nr73eOGZBAnEorDGQ8VnnCAleSv74is1k
+W7M07UP7EJJq9hSZfeMqk5QivtWrqvWG1SWxpTowKTEAyTn7u5U13k0DiRcsg0WT
+4mSMiLOhUNgIWcHElbTQPSVDcVznhNk0dWPDwKoUjp+orCuH+NvHKBAu+hnuip3e
+Ji7WGrHXI7QxAr5qr5ogl5x4yH4drIbq9fUea3NTuGPuPyu9fWjOSDmqPRKRMJFR
+UxxVFcyrW8iSBV5cvB7M1ADS40y6l4ryYmKjXbsOI4Ci8LJWJ4ZB61WQP7TvPQGS
+mNFmTTB2dwbpimr4KjV9j2bA9x0jAsjlcQZ5j1GOeyYCEDGKDJw0XD/zI+j0dpVc
+eu8YtuJGTyO1h+HiI3D9LrMuyUxxckvFHKe00+4xMz1hpqVo/kxe6gqf/9ES4M/h
+6/NeTzeqyJF2rgxK6KJJdmaKVYI+bvAQ3cKl+RZmgOjx4eig58N5uthqFgU7rQ+e
+GM9/y8C9WpPqITcJlY7I/7AkqvYDBwBsH/9mf4g9OUbC1Ah+MX8UIQ==
+-----END RSA PRIVATE KEY-----
+
+
+a. end entity certificate and key
+            (SHA1withRSA 1024, subca_cert_sha1_1024_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIICNzCCAaCgAwIBAgIBAjANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx
+NTBaFw0yOTA0MjMwMTExNTBaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt
+cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG
+9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt
+vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v
+z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6
+c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07
+OorBleV92TAfBgNVHSMEGDAWgBTfWD9mRTppcUAlUqGuu/R5t8CB5jANBgkqhkiG
+9w0BAQUFAAOBgQAOfIeasDg91CR3jGfuAEVKwncM1OPFmniAUcdPm74cCAyJ90Me
+dhUElWPGoAuXGfiyZlOlGUYWqEroe/dnkmnotJjLWR+MA4ZyX3O1YI8T4W3deWcC
+J4WMCF7mp17SaYYKX9F0AxwNJFpUkbB41IkTxPr0MmzB1871/pbY8dLAvA==
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,1FE5A37B770AF83D
+
+042bWtt4q0cB8pRuPUlMVncTP/WAz+mmPw3jXI3LFOBZeK6zFEDpI5M9c2JO+rqp
+Za5UkYuIg69V7LngriqRynkRGGQp3xASMLr5NVbKHTE/Ol/iIuxKaCkumZmGXB/z
+8bxQF5XN4tbKT4s3sWWmmKMicg6MHvySi3QVRG11PHRu/q7CEFPzJKRQ3fpaNcKD
+NTBI5F6GP9ENa/eog4WGENjXS0v4Wa3IfaOhjKXrSxjLUqLH0C8g5WWg5IrXXtuI
+pgyJ2kkE3Y/ChU7p7R42we6tBZqF5SiL5kFDn86DmHgCslTiZkIoE5i644sp03Sd
+XkHyHu0VIeYp3nDwRA7S98837W4F6i1BnXA5f3EaE3rNGjsxK8zL2pvdCcDYbese
+ETfba16HMzLXe1b4RSI3gwhlQ2MNKBwvskkQESf/Ew1DskBY0MCYFxo6hIp6LqMo
+HAl5kvCwvuYL2jBdQhkKxU+Leu5Ei8Ie9XYNVy4yUeUAMnSUkVaEs/I8z+Mk8oYq
+4QWqOc66XLcI13coDoxmv54kye3RjqdmZI8mg/3LCFotwceDuXyD43/vVhoTPEnp
+CqXafV2pw4y95skMHmktI2qvSahaM4P6GGXl8HqmP3b+8V5mxMhNtVnuUha2kouw
+DLNFUTg1cCLahM5SRolyA/XTGh7JOkJMYWPeJwN7l3K+lBtHHfj6DHtKEjUcyZFd
++Z55pDoAERumB6+BCnt6X2/0kEDV219RmsgxkGTWdFs+M7Y6EYYRtlinH4nqL6UD
+eHWitYIatAHOvdHeNrbXN9L5P3tsUB4HzFa46WWtKqRtbCVTuPVZdw==
+-----END RSA PRIVATE KEY-----
+
+b. end entity certificate and key
+            (SHA1withRSA 1024, subca_cert_sha1_512_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIIB9jCCAaCgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx
+NTBaFw0yOTA0MjMwMTExNTBaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt
+cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG
+9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt
+vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v
+z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6
+c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07
+OorBleV92TAfBgNVHSMEGDAWgBQ3QIeJNg+2PK+k/ZrrLqaGxnpTjTANBgkqhkiG
+9w0BAQUFAANBADV6X+ea0ftEKXy7yKNAbdIp35893T6AVwbdclomPkeOs86OtoTG
+1BIzWSK9QE7W6Wbf63e2RdcqoLK+DxsuwUg=
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,1FE5A37B770AF83D
+
+042bWtt4q0cB8pRuPUlMVncTP/WAz+mmPw3jXI3LFOBZeK6zFEDpI5M9c2JO+rqp
+Za5UkYuIg69V7LngriqRynkRGGQp3xASMLr5NVbKHTE/Ol/iIuxKaCkumZmGXB/z
+8bxQF5XN4tbKT4s3sWWmmKMicg6MHvySi3QVRG11PHRu/q7CEFPzJKRQ3fpaNcKD
+NTBI5F6GP9ENa/eog4WGENjXS0v4Wa3IfaOhjKXrSxjLUqLH0C8g5WWg5IrXXtuI
+pgyJ2kkE3Y/ChU7p7R42we6tBZqF5SiL5kFDn86DmHgCslTiZkIoE5i644sp03Sd
+XkHyHu0VIeYp3nDwRA7S98837W4F6i1BnXA5f3EaE3rNGjsxK8zL2pvdCcDYbese
+ETfba16HMzLXe1b4RSI3gwhlQ2MNKBwvskkQESf/Ew1DskBY0MCYFxo6hIp6LqMo
+HAl5kvCwvuYL2jBdQhkKxU+Leu5Ei8Ie9XYNVy4yUeUAMnSUkVaEs/I8z+Mk8oYq
+4QWqOc66XLcI13coDoxmv54kye3RjqdmZI8mg/3LCFotwceDuXyD43/vVhoTPEnp
+CqXafV2pw4y95skMHmktI2qvSahaM4P6GGXl8HqmP3b+8V5mxMhNtVnuUha2kouw
+DLNFUTg1cCLahM5SRolyA/XTGh7JOkJMYWPeJwN7l3K+lBtHHfj6DHtKEjUcyZFd
++Z55pDoAERumB6+BCnt6X2/0kEDV219RmsgxkGTWdFs+M7Y6EYYRtlinH4nqL6UD
+eHWitYIatAHOvdHeNrbXN9L5P3tsUB4HzFa46WWtKqRtbCVTuPVZdw==
+-----END RSA PRIVATE KEY-----
+
+c. end entity certificate and key
+            (SHA1withRSA 512, subca_cert_sha1_1024_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIIB8zCCAVygAwIBAgIBBDANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx
+NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt
+cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3
+DQEBAQUAA0sAMEgCQQCpfQzhld7w2JhW/aRaLkmrLrc/QAsQE+J4DXioXaajsWPo
+uMmYmuiQolb6OIY/LcivSubKM3G5PkAWoovUPIWLAgMBAAGjTzBNMAsGA1UdDwQE
+AwID6DAdBgNVHQ4EFgQUFWuXLkf4Ji57H9ISycgWi982TUIwHwYDVR0jBBgwFoAU
+31g/ZkU6aXFAJVKhrrv0ebfAgeYwDQYJKoZIhvcNAQEFBQADgYEAUyW8PrEdbzLu
+B+h6UemBOJ024rYq90hJE/5wUEKPvxZ9vPEUgl+io6cGhL3cLfxfh6z5xtEGp4Tb
+NB0Ye3Qi01FBiNDY8s3rQRrmel6VysU8u+0Oi2jmQY6vZXn/zXN5rrTLITCaSicG
+dOMv1xLM83Ee432WWlDwKOUxhzDGpWc=
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,153918982D82A26E
+
+5w5MNd16M1draSfIFAuWNfP3869l9y8vMI1kOcxqsxjeG6YfgKUyu6PEYlj1R7d1
+/+UwVs9RGm3V7AwV4G1Qpnd+jaMLpgPVMP12sHPnslBE4SQe9bAZ+X5i2/5uesHv
+bF7OBMqsYW8+Kgsy1Ac0pBx/8yoFYdD3KYFnIP20kV2Xxy4PtQQ6tHJ33dGslTNU
+qrcJsyUyYj6wORlb7huuP5Ua8f28Xs/KvnNJG0094kC1WHi3Raf4AoD/rvraVtCQ
+5jrK9se8D6su+S3SEW0YndxivbNx3xJu2O72e7lS6yb5ht3U7xNSSWTffIlW1okI
+zjscK0iv9S+x452mLIFUgkmriVJLFfjTMRCbhS1J6q9FXLDdre/2O18FO2TvwRIE
+6Bwt2utfOAGccRHLsdgcXkv+ngCTCkuCnmh2XZWqmvA=
+-----END RSA PRIVATE KEY-----
+
+d. end entity certificate and key
+            (SHA1withRSA 512, subca_cert_sha1_512_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIIBsjCCAVygAwIBAgIBBTANBgkqhkiG9w0BAQUFADAxMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx
+NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt
+cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTBcMA0GCSqGSIb3
+DQEBAQUAA0sAMEgCQQCpfQzhld7w2JhW/aRaLkmrLrc/QAsQE+J4DXioXaajsWPo
+uMmYmuiQolb6OIY/LcivSubKM3G5PkAWoovUPIWLAgMBAAGjTzBNMAsGA1UdDwQE
+AwID6DAdBgNVHQ4EFgQUFWuXLkf4Ji57H9ISycgWi982TUIwHwYDVR0jBBgwFoAU
+N0CHiTYPtjyvpP2a6y6mhsZ6U40wDQYJKoZIhvcNAQEFBQADQQBG4grtrVEHick0
+z/6Lcl/MGyHT0c8KTXE0AMVXG1NRjAicAmYno/yDaJ9OmfymObKZKV9fF7yCW/N/
+TMU6m7N0
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,153918982D82A26E
+
+5w5MNd16M1draSfIFAuWNfP3869l9y8vMI1kOcxqsxjeG6YfgKUyu6PEYlj1R7d1
+/+UwVs9RGm3V7AwV4G1Qpnd+jaMLpgPVMP12sHPnslBE4SQe9bAZ+X5i2/5uesHv
+bF7OBMqsYW8+Kgsy1Ac0pBx/8yoFYdD3KYFnIP20kV2Xxy4PtQQ6tHJ33dGslTNU
+qrcJsyUyYj6wORlb7huuP5Ua8f28Xs/KvnNJG0094kC1WHi3Raf4AoD/rvraVtCQ
+5jrK9se8D6su+S3SEW0YndxivbNx3xJu2O72e7lS6yb5ht3U7xNSSWTffIlW1okI
+zjscK0iv9S+x452mLIFUgkmriVJLFfjTMRCbhS1J6q9FXLDdre/2O18FO2TvwRIE
+6Bwt2utfOAGccRHLsdgcXkv+ngCTCkuCnmh2XZWqmvA=
+-----END RSA PRIVATE KEY-----
+
+e. end entity certificate and key
+            (MD2withRSA 1024, subca_cert_sha1_1024_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIICNzCCAaCgAwIBAgIBBjANBgkqhkiG9w0BAQIFADAxMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx
+NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt
+cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG
+9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt
+vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v
+z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6
+c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07
+OorBleV92TAfBgNVHSMEGDAWgBTfWD9mRTppcUAlUqGuu/R5t8CB5jANBgkqhkiG
+9w0BAQIFAAOBgQBxKsFf8NNQcXjDoKJJSG4Rk6ikcrhiGYuUI32+XHvs6hnav1Zc
+aJUpy7J4gMj/MnysMh/4AF9+m6zEEjuisXKUbYZhgtJxz+ukGSo163mJ8QJiAlRb
+Iwsy81r08mlSCR6jx2YhDAUxJIPC92R5Vb4CEutB7tWTwwz7vIHq330erA==
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,1FE5A37B770AF83D
+
+042bWtt4q0cB8pRuPUlMVncTP/WAz+mmPw3jXI3LFOBZeK6zFEDpI5M9c2JO+rqp
+Za5UkYuIg69V7LngriqRynkRGGQp3xASMLr5NVbKHTE/Ol/iIuxKaCkumZmGXB/z
+8bxQF5XN4tbKT4s3sWWmmKMicg6MHvySi3QVRG11PHRu/q7CEFPzJKRQ3fpaNcKD
+NTBI5F6GP9ENa/eog4WGENjXS0v4Wa3IfaOhjKXrSxjLUqLH0C8g5WWg5IrXXtuI
+pgyJ2kkE3Y/ChU7p7R42we6tBZqF5SiL5kFDn86DmHgCslTiZkIoE5i644sp03Sd
+XkHyHu0VIeYp3nDwRA7S98837W4F6i1BnXA5f3EaE3rNGjsxK8zL2pvdCcDYbese
+ETfba16HMzLXe1b4RSI3gwhlQ2MNKBwvskkQESf/Ew1DskBY0MCYFxo6hIp6LqMo
+HAl5kvCwvuYL2jBdQhkKxU+Leu5Ei8Ie9XYNVy4yUeUAMnSUkVaEs/I8z+Mk8oYq
+4QWqOc66XLcI13coDoxmv54kye3RjqdmZI8mg/3LCFotwceDuXyD43/vVhoTPEnp
+CqXafV2pw4y95skMHmktI2qvSahaM4P6GGXl8HqmP3b+8V5mxMhNtVnuUha2kouw
+DLNFUTg1cCLahM5SRolyA/XTGh7JOkJMYWPeJwN7l3K+lBtHHfj6DHtKEjUcyZFd
++Z55pDoAERumB6+BCnt6X2/0kEDV219RmsgxkGTWdFs+M7Y6EYYRtlinH4nqL6UD
+eHWitYIatAHOvdHeNrbXN9L5P3tsUB4HzFa46WWtKqRtbCVTuPVZdw==
+-----END RSA PRIVATE KEY-----
+
+f. end entity certificate and key
+            (MD2withRSA 1024, subca_cert_sha1_512_1024.pem signed)
+-----BEGIN CERTIFICATE-----
+MIIB9jCCAaCgAwIBAgIBBzANBgkqhkiG9w0BAQIFADAxMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMTAeFw0wOTA4MDYwMTEx
+NTFaFw0yOTA0MjMwMTExNTFaMEExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFt
+cGxlMRAwDgYDVQQLEwdDbGFzcy0xMQ4wDAYDVQQDEwVBbGljZTCBnzANBgkqhkiG
+9w0BAQEFAAOBjQAwgYkCgYEAy6/2g3rxQzJEvTyOnBcEnZthmAD0AnP6LG8b35jt
+vh71LHbF1FhkOT42Rfg20aBfWTMRf+FeOJBXpD4gCNjQA40vy8FaQxgYNAf7ho5v
+z6yAEE6SG7YviE+XGcvpQo47w8c6QSQjpBzdw7JxwbVlzUT7pF8x3RnXlGhWnWv6
+c1ECAwEAAaNPME0wCwYDVR0PBAQDAgPoMB0GA1UdDgQWBBSaXXERsow2Wm/6uT07
+OorBleV92TAfBgNVHSMEGDAWgBQ3QIeJNg+2PK+k/ZrrLqaGxnpTjTANBgkqhkiG
+9w0BAQIFAANBAIX63Ypi9P71RnC/pcMbhD+wekRFsTzU593X3MC7tyBJtEXwvAZG
+iMxXF5A+ohlr7/CrkV7ZTL8PLxnJdY5Y8rQ=
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,1FE5A37B770AF83D
+
+042bWtt4q0cB8pRuPUlMVncTP/WAz+mmPw3jXI3LFOBZeK6zFEDpI5M9c2JO+rqp
+Za5UkYuIg69V7LngriqRynkRGGQp3xASMLr5NVbKHTE/Ol/iIuxKaCkumZmGXB/z
+8bxQF5XN4tbKT4s3sWWmmKMicg6MHvySi3QVRG11PHRu/q7CEFPzJKRQ3fpaNcKD
+NTBI5F6GP9ENa/eog4WGENjXS0v4Wa3IfaOhjKXrSxjLUqLH0C8g5WWg5IrXXtuI
+pgyJ2kkE3Y/ChU7p7R42we6tBZqF5SiL5kFDn86DmHgCslTiZkIoE5i644sp03Sd
+XkHyHu0VIeYp3nDwRA7S98837W4F6i1BnXA5f3EaE3rNGjsxK8zL2pvdCcDYbese
+ETfba16HMzLXe1b4RSI3gwhlQ2MNKBwvskkQESf/Ew1DskBY0MCYFxo6hIp6LqMo
+HAl5kvCwvuYL2jBdQhkKxU+Leu5Ei8Ie9XYNVy4yUeUAMnSUkVaEs/I8z+Mk8oYq
+4QWqOc66XLcI13coDoxmv54kye3RjqdmZI8mg/3LCFotwceDuXyD43/vVhoTPEnp
+CqXafV2pw4y95skMHmktI2qvSahaM4P6GGXl8HqmP3b+8V5mxMhNtVnuUha2kouw
+DLNFUTg1cCLahM5SRolyA/XTGh7JOkJMYWPeJwN7l3K+lBtHHfj6DHtKEjUcyZFd
++Z55pDoAERumB6+BCnt6X2/0kEDV219RmsgxkGTWdFs+M7Y6EYYRtlinH4nqL6UD
+eHWitYIatAHOvdHeNrbXN9L5P3tsUB4HzFa46WWtKqRtbCVTuPVZdw==
+-----END RSA PRIVATE KEY-----
+
+h. root CRL issuer
+-----BEGIN CERTIFICATE-----
+MIICKzCCAZSgAwIBAgIBCjANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDgxNjMwNTdaFw0yOTA0MjUxNjMwNTda
+MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB
+AQUAA4GNADCBiQKBgQCy6RoQ6nMdeGJ6ijfjqDu3tDmeGLgnvfBcUKvcsvz9Ji3m
+oGnTzECo1oLV+A4/TJxOlak+ZiQ5KVyvfMcXLJeT6dRpXQZ+uc6TT3SkBq94VFzX
+qkk08z42JNdk1s5uyW8nRfg7+xntajQVrysoPYNDhu21cPnjDkRiBsIdS7+75QID
+AQABo3cwdTAdBgNVHQ4EFgQUGcJU6xWo66kI1QBvlfTQKxxmx9IwRwYDVR0jBEAw
+PoAU59AvsZmWPwU2m+FvYAad3Rmu1oKhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD
+VQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjANBgkqhkiG9w0BAQQFAAOBgQBx
+uKL59VInPdCi+8JL4B+S5YjlPL4ZOBHTjS0JlNxtjbGZdfs+3E9PUAdqhMJO4vq7
+XD+hGtgZtwSqGaSUYAtpLdoCr7vvPkcrxYTG2Ak+UiTbZhmJeSswKgFaCmjjdMCy
+y64UP2DQfn6Zi0wCfeao0m9s3zRLuJpgaQGiSHTQKA==
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,41E4237825CE0148
+
+9nbfd7dsaS+fkFYrU1+wTcevjdRLF/j9DUVQh/2bsFlVEYgeL8A+XpvpbXHYBd7H
+oBreofDNseibHe4EgISGPK8RymjYutQqPpbHwXd25jlUuUapvvuCj8V6qnhgpqEo
+zXL1Nd2c6KZgdySosyWy8JfIBZJ3kwiSkXVwzs8R4bAGrg1VS80GuszvCv8Fzjoc
+LuesX6fViE9yFzLsyOvn/W12DKhTXwiXTQYLUupM8zI9Kpozbea52ZIPMJ9HEiaY
+JgwNj05w33VxTe/tq3R9vS2Ee6aM4odi6CQEheLsUAnyE0BTsITKzwwTI25WTv25
+W+gwSF3V49a34MojTdlORq5iH0b3rYl7OMdk+99elJSkyQIbVwwOCFrKuSXYXvV7
+s9iMPFUbi+bZ3oP6zM5kVUcH6KyVeYfkuLf2+k1vPlav8/W5v+WfnvUNOBx76Ira
+BzVPYmm2V+YFiFL1hugm5Wv+yyx8QcfgXbvhNHoIEj7hh6Ac48FhtqEcBHjuT/gy
+7atJJUdOH6hhmD34hkHGnhcDE15ZOczxTLRC9450h5HKsZ0FILRlCBZLmiedycs2
+zqhUpR4jzDG9jKrlDU4ErfMgPLjveZc3/VT3bc+TYfuC8szCaQ5XX1JVcabZ+HQw
+pwmA1ONZDVsFzwbJy9+5bgXX+wLD5kaez8EHNDS5PgqgL0UdrWjdRi6e1RwlTDEw
+g/d7TZm/iQeL1iUIfkPA1f0ByYIiyd3XQqiQ/Mf1C16lQkhTHDwofFJdL8otT2Ha
+dk6fa7lBOnrpbRKUdpJpYfyqHg80BYNPu6BacVXlYqtJtkFK04qHbA==
+-----END RSA PRIVATE KEY-----
+
+i. CRL issued by root CRL issuer
+-----BEGIN X509 CRL-----
+MIH2MGECAQEwDQYJKoZIhvcNAQEFBQAwHzELMAkGA1UEBhMCVVMxEDAOBgNVBAoT
+B0V4YW1wbGUXDTA5MDgwODE2MzU1MFoXDTI4MTAwNzE2MzU1MFqgDjAMMAoGA1Ud
+FAQDAgEAMA0GCSqGSIb3DQEBBQUAA4GBAJCd7e25MruuWJP/KmenGC6CR22pQuG+
+XhRaAtpHkNRls8+TfBxm2PtRrXCAcDb68kNLdwvlAlCUwmL6HOx4VB3r+8QRUlDa
+T48wVp1ojGU2b2XbPtXiYZBXW6hBsFHGDJM/IAGJPE2PbVYGlBc23A9V9WyPyThi
+9XXG1iOTIJ6u
+-----END X509 CRL-----
+
+j. subca CRL issuer
+-----BEGIN CERTIFICATE-----
+MIICPTCCAaagAwIBAgIBCzANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ
+MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA4MDgxNjMwNThaFw0yOTA0MjUxNjMwNTha
+MDExCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMRAwDgYDVQQLEwdDbGFz
+cy0xMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8KICP0bdOZVlR9gZu7TgD
+znXgSMER1IQtompgr1mWeZjX4LmRck3/ogHoxwC4RbNPKI3KIihcVdFHw2jgvE0M
+mpf2lI50tmhnLitM8P0/q8xUU/KncipADo4hkM5TbpjPeGUBTGLKzGrq7yyT9Uli
+Z74rrp1mS59TxcEI2YQMIQIDAQABo3cwdTAdBgNVHQ4EFgQUDGgpD4L8V3aBJPLx
+C7diZ0M0wWMwRwYDVR0jBEAwPoAU59AvsZmWPwU2m+FvYAad3Rmu1oKhI6QhMB8x
+CzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjAN
+BgkqhkiG9w0BAQQFAAOBgQCcXqRge5UuW0duf/XnUWP4hrm4Q9EHJaiHZDYxI+WW
+Ca3OXdsrpgGi+RSgeMtQzlZ7YAwyYVV91U4BnX6s/97Vp5xbR3wr8Qbx67inM8Lp
+Tuo+e0nyTxwlwi9cSyy5MfJ8jfzaD+n8akhV+sx0Mmiv77YlrShP24lod55gJHKC
+vQ==
+-----END CERTIFICATE-----
+
+-----BEGIN RSA PRIVATE KEY-----
+Proc-Type: 4,ENCRYPTED
+DEK-Info: DES-EDE3-CBC,16EC4E2C0855BD5C
+
+dJHcUsnACMhfESAalWrWrfARnUgGhpp3vupjePUiBJ86YmKaNNr6GAwDukg3EJvs
+tboO1QQziLSf9pP7gw82Vp5YctEkk7vJVvCcq3QkZAsjNUHf3m3ne2qg8HngufzY
+IS/C3EtKuMr3oqa7P8wvMcsBs1G1ga/YqCWoKzowXhybaYPe20fwUNRtgqgdS5Gy
+bAzQB9R+Ua2tCaXb3CBYnrczsYFPhjuULr4qbWgHVBWhnkS3OIz71WqcCoXmvD3s
+bsjoZRCJUM6Zavyzs0kVGZogiPdr+KUyzjNNsnxle5cEET6nqkYR16UT/Fvemz9Q
+szh/y0gCi1nZb6cw5e9BJyF1GlobzxWyMwwY9L4vZNaBNaVRun+6dRWy0svaPuEy
+fV/9Y0/la9scyA5yNHz8xud3Njhj2ghyG5Nqbs3N/pPXRVdh7WNFBnc+L/SIBhhB
+/Ha9+OZdqyuMf3G+I1+WVADQr8xQP8/yLEvybZYtssjnuCmQSLPDDQFnp2Z3spax
++AT+T4dRimMjf0mZK/NlRJU9PWqMHzsJGBY1A903oAiiHiRFD10z8vyPBigSDF2W
+ct6a8WI1prKho6HbMqeIlSPk+HkdCGZedNNbvRlKl4Y56IsHGAhb3wvQ+94049P9
+wu5thK69jNb7ie3YEefAZTb5kD0h+oB8BILOJ5B29C04JdDe6P6hjGKD7x3nRhHM
+nyCUMB/fhYpoXdDhz8CeJ77hFt2zFZRstlDctQsDqLkC0AdvlOFsEFqGM4AkBGcV
+f6Y+ykNQB3vEWPZsWqVXHB2vQvk00R55tgu+R5JJ45NLG2TqyOp/4A==
+-----END RSA PRIVATE KEY-----
+
+k. CRL issued by subca CRL issuer
+-----BEGIN X509 CRL-----
+MIIBLTCBlwIBATANBgkqhkiG9w0BAQIFADAxMQswCQYDVQQGEwJVUzEQMA4GA1UE
+ChMHRXhhbXBsZTEQMA4GA1UECxMHQ2xhc3MtMRcNMDkwODA4MTYzNTUxWhcNMjgx
+MDA3MTYzNTUxWjAiMCACAQIXDTA5MDgwODE2MzU1MFowDDAKBgNVHRUEAwoBBKAO
+MAwwCgYDVR0UBAMCAQAwDQYJKoZIhvcNAQECBQADgYEAbIs7ws4/M24NYrIO0XY6
+UVxni0ZoQa+1R7NwU6unr4jFEVD+W/b+JEMfm0RUmpSa7HrUYsw+NycD3m5CD6VJ
+U4iuGGeJvHdrYJiPIYkEiFQnhAGOj8oS/nWtPvDKbuBMZI9atKkypby9At8h9URq
+1g/KSIM3rd1PYADdcPsok4I=
+-----END X509 CRL-----
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/DisabledAlgorithms/generate.sh	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,255 @@
+#
+# 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.
+#
+
+#!/bin/ksh
+#
+# needs ksh to run the script.
+set -e
+
+OPENSSL=openssl
+
+# generate a self-signed root certificate
+if [ ! -f root/finished ]; then
+    if [ ! -d root ]; then
+        mkdir root
+    fi
+
+    # SHA1withRSA 1024
+    ${OPENSSL} req -x509 -newkey rsa:1024 -keyout root/root_key_1024.pem \
+        -out root/root_cert_sha1_1024.pem -subj "/C=US/O=Example" \
+        -config openssl.cnf -reqexts cert_issuer -days 7650 -sha1 \
+        -passin pass:passphrase -passout pass:passphrase
+
+    # SHA1withRSA 512
+    ${OPENSSL} req -x509 -newkey rsa:512 -keyout root/root_key_512.pem \
+        -out root/root_cert_sha1_512.pem -subj "/C=US/O=Example" \
+        -config openssl.cnf -reqexts cert_issuer -days 7650 -sha1 \
+        -passin pass:passphrase -passout pass:passphrase
+
+    # MD2withRSA 2048
+    ${OPENSSL} req -x509 -newkey rsa:2048 -keyout root/root_key_2048.pem \
+        -out root/root_cert_md2_2048.pem -subj "/C=US/O=Example" \
+        -config openssl.cnf -reqexts cert_issuer -days 7650 -md2 \
+        -passin pass:passphrase -passout pass:passphrase
+
+    openssl req -newkey rsa:1024 -keyout root/root_crlissuer_key.pem \
+        -out root/root_crlissuer_req.pem -subj "/C=US/O=Example" -days 7650 \
+        -passin pass:passphrase -passout pass:passphrase
+
+    openssl x509 -req -in root/root_crlissuer_req.pem -extfile openssl.cnf \
+        -extensions crl_issuer -CA root/root_cert_sha1_1024.pem \
+        -CAkey root/root_key_1024.pem -out root/root_crlissuer_cert.pem \
+        -CAcreateserial -CAserial root/root_cert.srl -days 7200 \
+        -passin pass:passphrase
+
+    touch root/finished
+fi
+
+
+# generate subca cert issuer
+if [ ! -f subca/finished ]; then
+    if [ ! -d subca ]; then
+        mkdir subca
+    fi
+
+    # RSA 1024
+    ${OPENSSL} req -newkey rsa:1024 -keyout subca/subca_key_1024.pem \
+        -out subca/subca_req_1024.pem -subj "/C=US/O=Example/OU=Class-1" \
+        -days 7650 -passin pass:passphrase -passout pass:passphrase
+
+    # RSA 512
+    ${OPENSSL} req -newkey rsa:512 -keyout subca/subca_key_512.pem \
+        -out subca/subca_req_512.pem -subj "/C=US/O=Example/OU=Class-1" \
+        -days 7650 -passin pass:passphrase -passout pass:passphrase
+
+    # SHA1withRSA 1024 signed with RSA 1024
+    ${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \
+        -extensions cert_issuer -CA root/root_cert_sha1_1024.pem \
+        -CAkey root/root_key_1024.pem -out subca/subca_cert_sha1_1024_1024.pem \
+        -CAcreateserial -sha1 \
+        -CAserial root/root_cert.srl -days 7200 -passin pass:passphrase
+
+    # SHA1withRSA 1024 signed with RSA 512
+    ${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \
+        -extensions cert_issuer -CA root/root_cert_sha1_512.pem \
+        -CAkey root/root_key_512.pem -out subca/subca_cert_sha1_1024_512.pem \
+        -CAcreateserial -sha1 \
+        -CAserial root/root_cert.srl -days 7200 -passin pass:passphrase
+
+    # SHA1withRSA 512 signed with RSA 1024
+    ${OPENSSL} x509 -req -in subca/subca_req_512.pem -extfile openssl.cnf \
+        -extensions cert_issuer -CA root/root_cert_sha1_1024.pem \
+        -CAkey root/root_key_1024.pem -out subca/subca_cert_sha1_512_1024.pem \
+        -CAcreateserial -sha1 \
+        -CAserial root/root_cert.srl -days 7200 -passin pass:passphrase
+
+    # SHA1withRSA 512 signed with RSA 512
+    ${OPENSSL} x509 -req -in subca/subca_req_512.pem -extfile openssl.cnf \
+        -extensions cert_issuer -CA root/root_cert_sha1_512.pem \
+        -CAkey root/root_key_512.pem -out subca/subca_cert_sha1_512_512.pem \
+        -CAcreateserial -sha1 \
+        -CAserial root/root_cert.srl -days 7200 -passin pass:passphrase
+
+    # MD2withRSA 1024 signed with RSA 1024
+    ${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \
+        -extensions cert_issuer -CA root/root_cert_sha1_1024.pem \
+        -CAkey root/root_key_1024.pem -out subca/subca_cert_md2_1024_1024.pem \
+        -CAcreateserial -md2 \
+        -CAserial root/root_cert.srl -days 7200 -passin pass:passphrase
+
+    # MD2withRSA 1024 signed with RSA 512
+    ${OPENSSL} x509 -req -in subca/subca_req_1024.pem -extfile openssl.cnf \
+        -extensions cert_issuer -CA root/root_cert_sha1_512.pem \
+        -CAkey root/root_key_512.pem -out subca/subca_cert_md2_1024_512.pem \
+        -CAcreateserial -md2 \
+        -CAserial root/root_cert.srl -days 7200 -passin pass:passphrase
+
+    openssl req -newkey rsa:1024 -keyout subca/subca_crlissuer_key.pem \
+        -out subca/subca_crlissuer_req.pem -subj "/C=US/O=Example/OU=Class-1" \
+        -days 7650 -passin pass:passphrase -passout pass:passphrase
+
+    openssl x509 -req -in subca/subca_crlissuer_req.pem -extfile openssl.cnf \
+        -extensions crl_issuer -CA root/root_cert_sha1_1024.pem \
+        -CAkey root/root_key_1024.pem -out subca/subca_crlissuer_cert.pem \
+        -CAcreateserial -CAserial root/root_cert.srl -days 7200 \
+        -passin pass:passphrase
+
+    touch subca/finished
+fi
+
+
+# generate certifiacte for Alice
+if [ ! -f subca/alice/finished ]; then
+    if [ ! -d subca/alice ]; then
+        mkdir -p subca/alice
+    fi
+
+    # RSA 1024
+    ${OPENSSL} req -newkey rsa:1024 -keyout subca/alice/alice_key_1024.pem \
+        -out subca/alice/alice_req_1024.pem \
+        -subj "/C=US/O=Example/OU=Class-1/CN=Alice" -days 7650 \
+        -passin pass:passphrase -passout pass:passphrase
+
+    # RSA 512
+    ${OPENSSL} req -newkey rsa:512 -keyout subca/alice/alice_key_512.pem \
+        -out subca/alice/alice_req_512.pem \
+        -subj "/C=US/O=Example/OU=Class-1/CN=Alice" -days 7650 \
+        -passin pass:passphrase -passout pass:passphrase
+
+    # SHA1withRSA 1024 signed with RSA 1024
+    ${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \
+        -extfile openssl.cnf -extensions ee_of_subca \
+        -CA subca/subca_cert_sha1_1024_1024.pem \
+        -CAkey subca/subca_key_1024.pem \
+        -out subca/alice/alice_cert_sha1_1024_1024.pem -CAcreateserial -sha1 \
+        -CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase
+
+    # SHA1withRSA 1024 signed with RSA 512
+    ${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \
+        -extfile openssl.cnf -extensions ee_of_subca \
+        -CA subca/subca_cert_sha1_512_1024.pem \
+        -CAkey subca/subca_key_512.pem \
+        -out subca/alice/alice_cert_sha1_1024_512.pem -CAcreateserial -sha1 \
+        -CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase
+
+    # SHA1withRSA 512 signed with RSA 1024
+    ${OPENSSL} x509 -req -in subca/alice/alice_req_512.pem \
+        -extfile openssl.cnf -extensions ee_of_subca \
+        -CA subca/subca_cert_sha1_1024_1024.pem \
+        -CAkey subca/subca_key_1024.pem \
+        -out subca/alice/alice_cert_sha1_512_1024.pem -CAcreateserial -sha1 \
+        -CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase
+
+    # SHA1withRSA 512 signed with RSA 512
+    ${OPENSSL} x509 -req -in subca/alice/alice_req_512.pem \
+        -extfile openssl.cnf -extensions ee_of_subca \
+        -CA subca/subca_cert_sha1_512_1024.pem \
+        -CAkey subca/subca_key_512.pem \
+        -out subca/alice/alice_cert_sha1_512_512.pem -CAcreateserial -sha1 \
+        -CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase
+
+    # MD2withRSA 1024 signed with RSA 1024
+    ${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \
+        -extfile openssl.cnf -extensions ee_of_subca \
+        -CA subca/subca_cert_sha1_1024_1024.pem \
+        -CAkey subca/subca_key_1024.pem \
+        -out subca/alice/alice_cert_md2_1024_1024.pem -CAcreateserial -md2 \
+        -CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase
+
+    # MD2withRSA 1024 signed with RSA 512
+    ${OPENSSL} x509 -req -in subca/alice/alice_req_1024.pem \
+        -extfile openssl.cnf -extensions ee_of_subca \
+        -CA subca/subca_cert_sha1_512_1024.pem \
+        -CAkey subca/subca_key_512.pem \
+        -out subca/alice/alice_cert_md2_1024_512.pem -CAcreateserial -md2 \
+        -CAserial subca/subca_cert.srl -days 7200 -passin pass:passphrase
+
+    touch subca/alice/finished
+fi
+
+if [ ! -f root/revoked ]; then
+    if [ ! -d root ]; then
+        mkdir root
+    fi
+
+    if [ ! -f root/index.txt ]; then
+        touch root/index.txt
+        echo 00 > root/crlnumber
+    fi
+
+    openssl ca -gencrl -config openssl.cnf -name ca_top -crldays 7000 -md sha1 \
+        -crl_reason superseded -keyfile root/root_crlissuer_key.pem \
+        -cert root/root_crlissuer_cert.pem -out root/top_crl.pem \
+        -passin pass:passphrase
+
+    touch root/revoked
+fi
+
+if [ ! -f subca/revoked ]; then
+    if [ ! -d subca ]; then
+        mkdir subca
+    fi
+
+    if [ ! -f subca/index.txt ]; then
+        touch subca/index.txt
+        echo 00 > subca/crlnumber
+    fi
+
+    # revoke alice's SHA1withRSA 1024 signed with RSA 1024
+    openssl ca -revoke subca/alice/alice_cert_sha1_1024_1024.pem \
+        -config openssl.cnf \
+        -name ca_subca -crl_reason superseded \
+        -keyfile subca/subca_crlissuer_key.pem \
+        -cert subca/subca_crlissuer_cert.pem -passin pass:passphrase
+
+    openssl ca -gencrl -config openssl.cnf \
+        -name ca_subca -crldays 7000 -md md2 \
+        -crl_reason superseded -keyfile subca/subca_crlissuer_key.pem \
+        -cert subca/subca_crlissuer_cert.pem \
+        -out subca/subca_crl.pem \
+        -passin pass:passphrase
+
+    touch subca/revoked
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/provider/certpath/DisabledAlgorithms/openssl.cnf	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,206 @@
+#
+# 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.
+#
+
+#
+# OpenSSL configuration file.
+#
+
+HOME                = .
+RANDFILE            = $ENV::HOME/.rnd
+
+[ ca ]
+default_ca          = CA_default
+
+[ CA_default ]
+dir                 = ./top
+certs               = $dir/certs
+crl_dir             = $dir/crl
+database            = $dir/index.txt
+unique_subject      = no
+new_certs_dir       = $dir/newcerts
+certificate         = $dir/cacert.pem
+serial              = $dir/serial
+crlnumber           = $dir/crlnumber
+crl                 = $dir/crl.pem
+private_key         = $dir/private/cakey.pem
+RANDFILE            = $dir/private/.rand
+x509_extensions     = v3_ca
+
+name_opt            = ca_default
+cert_opt            = ca_default
+
+default_days        = 7650
+default_crl_days    = 30
+default_md          = sha1
+preserve            = no
+
+policy              = policy_anything
+
+[ ca_top ]
+dir                 = ./root
+certs               = $dir/certs
+crl_dir             = $dir/crl
+database            = $dir/index.txt
+unique_subject      = no
+new_certs_dir       = $dir/newcerts
+certificate         = $dir/cacert.pem
+serial              = $dir/serial
+crlnumber           = $dir/crlnumber
+crl                 = $dir/crl.pem
+private_key         = $dir/private/cakey.pem
+RANDFILE            = $dir/private/.rand
+
+x509_extensions     = v3_ca
+
+name_opt            = ca_default
+cert_opt            = ca_default
+
+default_days        = 7650
+default_crl_days    = 30
+default_md          = sha1
+preserve            = no
+
+policy              = policy_anything
+
+[ ca_subca ]
+dir                 = ./subca
+certs               = $dir/certs
+crl_dir             = $dir/crl
+database            = $dir/index.txt
+unique_subject      = no
+new_certs_dir       = $dir/newcerts
+
+certificate         = $dir/cacert.pem
+serial              = $dir/serial
+crlnumber           = $dir/crlnumber
+crl                 = $dir/crl.pem
+private_key         = $dir/private/cakey.pem
+RANDFILE            = $dir/private/.rand
+
+x509_extensions     = usr_cert
+
+name_opt            = ca_default
+cert_opt            = ca_default
+
+default_days        = 7650
+default_crl_days    = 30
+default_md          = sha1
+preserve            = no
+
+policy              = policy_anything
+
+[ policy_match ]
+countryName         = match
+stateOrProvinceName = match
+organizationName    = match
+organizationalUnitName  = optional
+commonName          = supplied
+emailAddress        = optional
+
+[ policy_anything ]
+countryName         = optional
+stateOrProvinceName = optional
+localityName        = optional
+organizationName    = optional
+organizationalUnitName  = optional
+commonName          = supplied
+emailAddress        = optional
+
+[ req ]
+default_bits        = 1024
+default_keyfile     = privkey.pem
+distinguished_name  = req_distinguished_name
+attributes          = req_attributes
+x509_extensions     = v3_ca
+
+string_mask = nombstr
+
+[ req_distinguished_name ]
+countryName         = Country Name (2 letter code)
+countryName_default = NO
+countryName_min     = 2
+countryName_max     = 2
+
+stateOrProvinceName = State or Province Name (full name)
+stateOrProvinceName_default  = A-State
+
+localityName        = Locality Name (eg, city)
+
+0.organizationName  = Organization Name (eg, company)
+0.organizationName_default   = Internet Widgits Pty Ltd
+
+organizationalUnitName       = Organizational Unit Name (eg, section)
+
+commonName              = Common Name (eg, YOUR name)
+commonName_max          = 64
+
+emailAddress            = Email Address
+emailAddress_max        = 64
+
+[ req_attributes ]
+challengePassword       = A challenge password
+challengePassword_min   = 4
+challengePassword_max   = 20
+unstructuredName        = An optional company name
+
+
+[ usr_cert ]
+keyUsage                = nonRepudiation, digitalSignature, keyEncipherment
+
+subjectKeyIdentifier    = hash
+authorityKeyIdentifier  = keyid,issuer
+
+[ v3_req ]
+basicConstraints        = CA:FALSE
+keyUsage                = nonRepudiation, digitalSignature, keyEncipherment
+subjectAltName          = email:example@openjdk.net, RID:1.2.3.4:true
+
+[ v3_ca ]
+subjectKeyIdentifier    = hash
+authorityKeyIdentifier  = keyid:always,issuer:always
+basicConstraints        = critical,CA:true
+keyUsage                = keyCertSign
+
+[ cert_issuer ]
+subjectKeyIdentifier    = hash
+authorityKeyIdentifier  = keyid:always,issuer:always
+basicConstraints        = critical,CA:true
+keyUsage                = keyCertSign
+
+
+[ crl_issuer ]
+subjectKeyIdentifier    = hash
+authorityKeyIdentifier  = keyid:always,issuer:always
+keyUsage                = cRLSign
+
+
+[ crl_ext ]
+authorityKeyIdentifier  = keyid:always,issuer:always
+
+[ ee_of_subca ]
+keyUsage    = nonRepudiation, digitalSignature, keyEncipherment, keyAgreement
+
+subjectKeyIdentifier    = hash
+authorityKeyIdentifier  = keyid,issuer
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/tools/jarsigner/ec.sh	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,73 @@
+#
+# Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+# CA 95054 USA or visit www.sun.com if you need additional information or
+# have any questions.
+#
+
+# @test
+# @bug 6870812
+# @summary enhance security tools to use ECC algorithm
+#
+
+if [ "${TESTJAVA}" = "" ] ; then
+  JAVAC_CMD=`which javac`
+  TESTJAVA=`dirname $JAVAC_CMD`/..
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  Windows_* )
+    FS="\\"
+    ;;
+  * )
+    FS="/"
+    ;;
+esac
+
+KS=ec.jks
+JFILE=ec.jar
+
+KT="$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS"
+JAR=$TESTJAVA${FS}bin${FS}jar
+JARSIGNER=$TESTJAVA${FS}bin${FS}jarsigner
+
+rm $KS $JFILE
+echo A > A
+$JAR cvf $JFILE A
+
+$KT -alias a -dname CN=a -keyalg ec -genkey -validity 300 || exit 11
+$KT -alias b -dname CN=b -keyalg ec -genkey -validity 300 || exit 12
+$KT -alias c -dname CN=c -keyalg ec -genkey -validity 300 || exit 13
+$KT -alias x -dname CN=x -keyalg ec -genkey -validity 300 || exit 14
+
+$JARSIGNER -keystore $KS -storepass changeit $JFILE a -debug -strict || exit 21
+$JARSIGNER -keystore $KS -storepass changeit $JFILE b -debug -strict -sigalg SHA1withECDSA || exit 22
+$JARSIGNER -keystore $KS -storepass changeit $JFILE c -debug -strict -sigalg SHA512withECDSA || exit 23
+
+$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE a -debug -strict || exit 31
+$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE b -debug -strict || exit 32
+$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE c -debug -strict || exit 33
+
+# Not signed by x, should exit with non-zero
+$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE x -debug -strict && exit 34
+
+exit 0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/tools/keytool/readjar.sh	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,56 @@
+#
+# 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 6890872
+# @summary keytool -printcert to recognize signed jar files
+#
+
+if [ "${TESTJAVA}" = "" ] ; then
+  JAVAC_CMD=`which javac`
+  TESTJAVA=`dirname $JAVAC_CMD`/..
+fi
+
+# set platform-dependent variables
+OS=`uname -s`
+case "$OS" in
+  Windows_* )
+    FS="\\"
+    ;;
+  * )
+    FS="/"
+    ;;
+esac
+
+KS=readjar.jks
+rm $KS
+$TESTJAVA${FS}bin${FS}keytool -storepass changeit -keypass changeit -keystore $KS \
+        -alias x -dname CN=X -genkeypair
+$TESTJAVA${FS}bin${FS}jar cvf readjar.jar $KS
+$TESTJAVA${FS}bin${FS}jarsigner -storepass changeit -keystore $KS readjar.jar x
+
+$TESTJAVA${FS}bin${FS}keytool -printcert -jarfile readjar.jar || exit 1
+$TESTJAVA${FS}bin${FS}keytool -printcert -jarfile readjar.jar -rfc || exit 1
+
+exit 0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/sun/security/util/DerValue/BadValue.java	Wed Nov 25 11:08:25 2009 -0800
@@ -0,0 +1,119 @@
+/*
+ * 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 6864911
+ * @summary ASN.1/DER input stream parser needs more work
+ */
+
+import java.io.*;
+import sun.security.util.*;
+import sun.misc.IOUtils;
+
+public class BadValue {
+
+    public static void main(String[] args) throws Exception {
+
+        // Test IOUtils.readFully
+
+        // We have 4 bytes
+        InputStream in = new ByteArrayInputStream(new byte[10]);
+        byte[] bs = IOUtils.readFully(in, 4, true);
+        if (bs.length != 4 || in.available() != 6) {
+            throw new Exception("First read error");
+        }
+        // But only 6 left
+        bs = IOUtils.readFully(in, 10, false);
+        if (bs.length != 6 || in.available() != 0) {
+            throw new Exception("Second read error");
+        }
+        // MAX read as much as it can
+        in = new ByteArrayInputStream(new byte[10]);
+        bs = IOUtils.readFully(in, Integer.MAX_VALUE, true);
+        if (bs.length != 10 || in.available() != 0) {
+            throw new Exception("Second read error");
+        }
+        // MAX ignore readAll
+        in = new ByteArrayInputStream(new byte[10]);
+        bs = IOUtils.readFully(in, Integer.MAX_VALUE, false);
+        if (bs.length != 10 || in.available() != 0) {
+            throw new Exception("Second read error");
+        }
+        // 20>10, readAll means failure
+        in = new ByteArrayInputStream(new byte[10]);
+        try {
+            bs = IOUtils.readFully(in, 20, true);
+            throw new Exception("Third read error");
+        } catch (EOFException e) {
+            // OK
+        }
+        int bignum = 10 * 1024 * 1024;
+        bs = IOUtils.readFully(new SuperSlowStream(bignum), -1, true);
+        if (bs.length != bignum) {
+            throw new Exception("Fourth read error");
+        }
+
+        // Test DerValue
+        byte[] input = {0x04, (byte)0x84, 0x40, 0x00, 0x42, 0x46, 0x4b};
+        try {
+            new DerValue(new ByteArrayInputStream(input));
+        } catch (IOException ioe) {
+            // This is OK
+        }
+    }
+}
+
+/**
+ * An InputStream contains a given number of bytes, but only returns one byte
+ * per read.
+ */
+class SuperSlowStream extends InputStream {
+    private int p;
+    /**
+     * @param Initial capacity
+     */
+    public SuperSlowStream(int capacity) {
+        p = capacity;
+    }
+    @Override
+    public int read() throws IOException {
+        if (p > 0) {
+            p--;
+            return 0;
+        } else {
+            return -1;
+        }
+    }
+    @Override
+    public int read(byte b[], int off, int len) throws IOException {
+        if (len == 0) return 0;
+        if (p > 0) {
+            p--;
+            b[off] = 0;
+            return 1;
+        } else {
+            return -1;
+        }
+    }
+}
--- a/test/sun/util/logging/PlatformLoggerTest.java	Mon Nov 23 10:04:47 2009 +0000
+++ b/test/sun/util/logging/PlatformLoggerTest.java	Wed Nov 25 11:08:25 2009 -0800
@@ -28,7 +28,7 @@
  *          logging is enabled.  Also validate some basic PlatformLogger
  *          operations.
  *
- * @build PlatformLoggerTest
+ * @compile -XDignore.symbol.file PlatformLoggerTest.java
  * @run main PlatformLoggerTest
  */